tan() in Java

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

Syntax:

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

This method takes one argument of type double as its parameter. This method returns the trigonometric tangent of an angle. 

Special cases:

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

2.If the argument is zero, then the result is a zero with the same sign as the argument.

Parameters: One parameter is required for this method.

a: an angle, in radians.

Returns: the tangent of the argument.

For Example:

Math.tan(0.5) = > It returns 0.5463024898437905

Approach

Java

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

        double a = 0.5;
        System.out.println(Math.tan(a));

    }
}

Output:

0.5463024898437905

No comments:

Post a Comment