acos() in Java

acos(): This function is available in the Math library of Java.

Syntax:

double java.lang.Math.acos(double a)

This function takes one argument of type double.

It returns the arc cosine of a value, the returned angle is in the range 0.0 through pi or we can say [0,π].

Special case:

1.If the argument is NaN or its absolute value is greater than 1, then the result is NaN.

Note: The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic. 

Parameters: One parameter is required for this function.

a: value whose arc cosine is to be returned. 

Note: This function returns the arc cosine of the argument.

Approach

Java

public class Acos {
    public static void main(String[] args) {

        double a = 0.45;
        System.out.println(Math.acos(a));
        
    }
}

Output:

1.1040309877476002

No comments:

Post a Comment