cos() in Java

cos(): This method is available in the Math class of Java.

Syntax:

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

This method takes one argument of type double. This method returns the trigonometric cosine of an angle. 

Special cases:

1. If the argument is NaN or an infinity, then the result is NaN.

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

Parameters: One parameter is required for this method.

a: an angle, in radians.

Returns: The cosine of the argument.

Approach

Java

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

        double a = 1.5;
        System.out.println(Math.cos(a));

    }
}

Output:

0.0707372016677029


No comments:

Post a Comment