The java.lang.StrictMath.sin() is an in-built function in Java which returns the trigonometric sine of an angle.
Syntax:
public static double sin(double ang)
Parameters: This function accepts a single parameter ang which is a double variable which represents an angle (in radians) whose trigonometric tangent is to be returned by the function.
Return Value: This method returns the sine of the angle passed as argument to the function. The following cases are considered :
- The function returns NaN if the argument is NaN or infinity.
- The function returns zero with the sign same as that of the argument if the argument is zero.
Examples:
Input : ang = 0.5235987755982988(30 degree) Output : 0.49999999999999994 Input : ang = 0.7853981633974483(45 degree) Output : 0.7071067811865475
Below programs illustrate the working of java.lang.StrictMath.sin() function in Java:
Program 1:
// Java Program to illustrate sin() 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 sine of the angle System.out.println("Sine value of 60 degrees : " + StrictMath.sin(ang)); } } |
Sine value of 60 degrees : 0.8660254037844386
Program 2:
// Java Program to illustrate sin() 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); System.out.println(rad); // Display the trigonometric sine of the angle System.out.println("Sine value of 77.128 degrees : " + StrictMath.sin(rad)); } } |
1.3461375454781863 Sine value of 77.128 degrees : 0.9748701783788553
Reference: https://docs.oracle.com/javase/8/docs/api/java/lang/StrictMath.html#sin()
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- StrictMath tan() Method in Java
- StrictMath log() Method In Java
- StrictMath exp() Method in Java
- StrictMath pow() Method in Java
- StrictMath multiplyExact() Method in Java
- StrictMath nextDown() Method in Java
- StrictMath rint() Method in Java
- StrictMath sqrt() Method in Java
- StrictMath round() method in Java
- StrictMath random() Method in Java
- StrictMath fma() method in Java with Examples
- StrictMath signum() Method in Java
- StrictMath tanh() Method in Java
- StrictMath nextAfter() Method in Java
- StrictMath nextUp() Method in Java
- StrictMath getExponent() Method In Java
- StrictMath log10() Method in Java
- StrictMath log1p() Method in Java
- StrictMath atan() Method in Java
- StrictMath hypot() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

