Trigonometric Functions in Java with Examples Last Updated : 27 May, 2019 Comments Improve Suggest changes Like Article Like Report The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. Java.lang.Math.sin() Method : is an inbuilt method which returns the sine of the value passed as an argument. The value passed in this function should be in radians. If the argument is NaN or an infinity, then the result is NaN. If the argument is zero, then the result is a zero with the same sign as the argument. Syntax : Math.sin(double radians) Parameters : The method takes one mandatory argument in radians. Returns : It returns a double value. The returned value is the sine of the specified double value passed. Example 1 : Program demonstrating the use of sin() Java // Java program for sin() method import java.util.*; class GFG { // Driver Code public static void main(String args[]) { double degrees = 45.0; // convert degrees to radians double radians = Math.toRadians(degrees); // sin() method to get the sine value double sinValue = Math.sin(radians); // prints the sine value System.out.println("sin(" + degrees + ") = " + sinValue); } } Output: sin(45.0) = 0.7071067811865475 Java.lang.Math.cos() : is an inbuilt method which returns the cosine of the value passed as an argument. The value passed in this function should be in radians. If the argument is NaN or an infinity, then the result is NaN. Syntax : Math.cos(double radians) Parameters : The method takes one mandatory argument in radians. Returns : It returns a double value. The returned value is the cosine of the specified double value passed. Example 2 : Program demonstrating the use of cos() Java // Java program for cos() method import java.util.*; class GFG { // Driver Code public static void main(String args[]) { double degrees = 45.0; // convert degrees to radians double radians = Math.toRadians(degrees); // cos() method to get the cosine value double cosValue = Math.cos(radians); // prints the cosine value System.out.println("cos(" + degrees + ") = " + cosValue); } } Output: cos(45.0) = 0.7071067811865476 Java.lang.Math.tan() : is an inbuilt method which returns the tangent of the value passed as an argument. The value passed in this function should be in radians. If the argument is NaN or an infinity, then the result is NaN. If the argument is zero, then the result is a zero with the same sign as the argument. Syntax : Math.tan(double radians) Parameters : The method takes one mandatory argument in radians. Returns : It returns a double value. The returned value is the tangent of the specified double value passed. Example 3 : Program demonstrating the use of tan() Java // Java program for tan() method import java.util.*; class GFG { // Driver Code public static void main(String args[]) { double degrees = 45.0; // convert degrees to radians double radians = Math.toRadians(degrees); // cos() method to get the tangent value double tanValue = Math.tan(radians); // prints the tangent value System.out.println("tan(" + degrees + ") = " + tanValue); } } Output: tan(45.0) = 0.9999999999999999 Comment More infoAdvertise with us Next Article Trigonometric Functions in Java with Examples S Striver Follow Improve Article Tags : Misc Java Java-lang package Practice Tags : JavaMisc Similar Reads StrictMath cos() Method in Java with Examples All methods of java.lang.StrictMath class : Set 1, Set 2The java.lang.StrictMath.cos() is an inbuilt method in Java which is used to return the cosine value of a given angle. The method returns NaN when the given argument is NaN or infinity.Syntax: public static double cos(double num) Parameters: Th 2 min read StrictMath asin() Method in Java With Examples The java.lang.StrictMath.asin() is an inbuilt method of StrictMath class which is used to return the arc sine of a specified value. The returned angle is in within the range of -pi/2 and pi/2. The method gives rise to two special results: If the absolute value of the argument is greater than 1 or th 2 min read Java Math sin() method with Examples 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 st 2 min read 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 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 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 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 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 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 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 Like