.tan()
Published Oct 21, 2022
Contribute to Docs
The Math.tan()
method returns the tangent of an angle given in radians. The function accepts all real numbers except the values where cos(x)
is equal to zero.
Syntax
Math.tan(double x)
Here, x
is the argument passed to the function. Math.tan()
accepts all real numbers as arguments.
- If the argument is
NaN
or aninfinity
, then the result returned is NaN. - If the argument is
zero
, then the result is also zero with same sign.
Example
This example uses .tan()
to return the tangent for (x)
:
// Main.javapublic class Main {public static void main(String[] args) {double x = Math.PI / 2.0; // RadiansSystem.out.println(Math.tan(x));x = 0.0;System.out.println(Math.tan(x));}}
This will produce the following output:
1.61977519054386150.0
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.