Java Math sin() method with Examples Last Updated : 28 Jul, 2021 Comments Improve Suggest changes Like Article Like Report The java.lang.Math.sin() returns the trigonometry sine of an angle in between 0.0 and pi. If the argument is NaN or infinity, then the result is NaN. If the argument is zero, then the result is a zero with the same sign as the argument. The value returned will be between -1 and 1. Syntax : public static double sin(double a) ; Parameter: The value whose sine is to be returned. Return type: This method returns the sine value of the argument. Implementation: Here we will be proposing 2 examples one in which we will simply be showcasing the working of Math.sin() method of java.lang package method and secondary be edge case of the first example specific taken where argument is NaN or infinity. Example 1 Java // Java program to demonstrate working // of java.lang.Math.sin() method import java.lang.Math; class Gfg { // driver code public static void main(String args[]) { double a = 30; // converting values to radians double b = Math.toRadians(a); System.out.println(Math.sin(b)); a = 45; // converting values to radians b = Math.toRadians(a); System.out.println(Math.sin(b)); a = 60; // converting values to radians b = Math.toRadians(a); System.out.println(Math.sin(b)); a = 90; // converting values to radians b = Math.toRadians(a); System.out.println(Math.sin(b)); } } Output: 0.49999999999999994 0.7071067811865475 0.8660254037844386 1.0 Example 2 Java // Java program to demonstrate working of Math.cos() method // of java.lang package considering infinity case // Importing classes from java.lang package import java.lang.Math; public class GFG { // Main driver method public static void main(String[] args) { double positiveInfinity = Double.POSITIVE_INFINITY; double negativeInfinity = Double.NEGATIVE_INFINITY; double nan = Double.NaN; double result; // Here argument is negative infinity, // output will be NaN result = Math.sin(negativeInfinity); System.out.println(result); // Here argument is positive infinity, // output will also be NaN result = Math.sin(positiveInfinity); System.out.println(result); // Here argument is NaN, output will be NaN result = Math.sin(nan); System.out.println(result); } } Output: NaN NaN NaN Comment More infoAdvertise with us Next Article Java Math sin() method with Examples B barykrg Follow Improve Article Tags : Misc Java Technical Scripter java-math Practice Tags : JavaMisc Similar Reads Java Math sinh() method with Examples In Java, the sinh() method is a part of the java.util.Math class. This method is used to calculate the hyperbolic sine of a given value. In this article, we are going to discuss how this method works for regular values and for special cases such as infinity and NaN.Mathematical Definition:The hyperb 3 min read Java Math tan() method with Examples The Math.tan() method of java.lang.Math class calculates the trigonometric tangent of an angle. Suppose there is a right-angled triangle, so tan(angle) is the opposite side divided by the adjacent side. If the argument is NaN or an infinity, then the result returned is NaN.If the argument is zero, t 2 min read Java Math tanh() method with Examples In Java, the tanh() method is a part of the java.lang.Math class. This method returns the hyperbolic tangent of a double value passed to it as an argument. Mathematical Definition:The hyperbolic tangent of any value a is defined as:((ea - e-a)/2)/((ea + e-a)/2)where, e is Euler's number, whose value 2 min read Java Math cos() method with Examples In Java, the Math.cos() method returns the trigonometric cosine of an angle. This method calculates the cosine of the angle, which must be provided in radians. If the argument is NaN or an infinity, then the result returned is NaN. The returned result will always be within the range of [-1, 1]. In t 3 min read Java Math acos() method with Examples The Math.acos() method returns the arc cosine of an angle between 0.0 and pi (0.0, pi). Arc cosine is also called as inverse of a cosine. If the argument is NaN or its absolute value is greater than 1, then the result is NaN.Syntax of Math acos() Methodpublic static double acos(double a)Parameter: a 2 min read Java Math asin() method with Example The asin() method of java.lang.Math class, computes the arc sine also called as an inverse of a sine of a given value. This method is useful when we have the sine of an angle and we need to find the angle. This method returns the arc sine of an angle in between -pi/2 and pi/2.If the argument is NaN 2 min read Math class methods in Java with Examples | Set 2 java.math class and its methods | Set 1 java.math class methods discussed in this article : abs() : java.math.abs() method returns the absolute value of any type of argument passed. This method can handle all the data types. Special Case : Result is positive zero, if the argument is positive zero or 6 min read Java toRadians() method with Example The java.lang.Math.toRadians() is used to convert an angle measured in degrees to an approximately equivalent angle measured in radians. Note: The conversion from degrees to radian is generally inexact. Syntax: public static double toRadians(double deg) Parameter: deg : This parameter is an angle in 1 min read Java atan() method with Examples The Math.atan() method in Java is used to calculate the arc tangent of a given value. This method is part of the java.lang.Math package. In this article, we are going to discuss the working of this method with regular values and for special cases such as infinity and NaN. This method is very useful 3 min read Java toDegrees() method with Example The toDegrees() method comes under the java.lang.Math package. This method is used to convert an angle from radians to its equivalent degrees. This method is useful in mathematical computations where angle conversion is required, for example, trigonometry, geometry etc.Note: The conversion from radi 2 min read Like