Saturday, December 13, 2025
HomeLanguagesJavaStrictMath tan() Method in Java

StrictMath tan() Method in Java

The java.lang.StrictMath.tan() is an in-built function in Java which returns the trigonometric tangent of an angle.

Syntax:

public static double tan(double ang)

Parameters: This function accepts a single parameter ang which is a double variable representing an angle (in radians) whose trigonometric tangent is to be returned by the function.

Return Value: This method returns the tangent of the angle passed as argument to the function. It gives rise to special cases:

  • The method returns NaN if the argument is NaN or an infinity.
  • The result is zero with the same sign as the argument, if the argument is zero.

Examples:

Input : ang = 0.5235987755982988(30 degree)
Output : 0.5773502691896257

Input : ang = 0.7853981633974483(45 degree)
Output : 0.9999999999999999

Below programs illustrate the java.lang.StrictMath.tan() function in Java:

Program 1:




// Java Program to illustrate 
// StrictMath.tan() function
  
import java.io.*;
import java.math.*;
import java.lang.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        double ang = (60 * Math.PI) / 180;
  
        // Display the trigonometric tangent of the angle
        System.out.println("tangent value of 60 degrees : "
                           + StrictMath.tan(ang));
    }
}


Output:

tangent value of 60 degrees : 1.7320508075688767

Program 2:




// Java Program to illustrate 
// StrictMath.tan() function
  
import java.io.*;
import java.math.*;
import java.lang.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        double ang = 77.128;
        // Convert the angle to its equivalent radian
        double rad = StrictMath.toRadians(ang);
  
        // Display the trigonometric tangent of the angle
        System.out.println("tangent value of 77.128 degrees : "
                           + StrictMath.tan(rad));
    }
}


Output:

tangent value of 77.128 degrees : 4.376055350774854

Reference: https://docs.oracle.com/javase/8/docs/api/java/lang/StrictMath.html#tan()

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32446 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6814 POSTS0 COMMENTS
Nicole Veronica
11952 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12030 POSTS0 COMMENTS
Shaida Kate Naidoo
6949 POSTS0 COMMENTS
Ted Musemwa
7200 POSTS0 COMMENTS
Thapelo Manthata
6897 POSTS0 COMMENTS
Umr Jansen
6882 POSTS0 COMMENTS