# Trigonometric methods in Java

Java 8Object Oriented ProgrammingProgramming

#### Complete Java Programming Fundamentals With Sample Projects

98 Lectures 7.5 hours

#### Get your Java dream job! Beginners interview preparation

85 Lectures 6 hours

#### Core Java bootcamp program with Hands on practice

Featured

99 Lectures 17 hours

The java.lang.Math class contains methods for performing basic numeric operations such as the trigonometry, logarithm, etc.

The following are some of the methods.

Sr.NoMethods & Description
1static double abs(double a)
This method returns the absolute value of a double value.
2static float abs(float a)
This method returns the absolute value of a float value.
3static int abs(int a)
This method returns the absolute value of an int value.
4static long abs(long a)
This method returns the absolute value of a long value.
5static double acos(double a)
This method returns the arc cosine of a value; the returned angle is in the range 0.0 through pi.
6static double asin(double a)
This method returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2.

Let us see an example of acos() method.

## Example

Live Demo

public class Demo {
public static void main(String args[]) {
double val = Math.PI / 2;
System.out.println("Math.acos(" + val + ") = " + Math.acos(val));
}
}

## Output

Math.acos(0.027415567780803774) = 1.5433773235341761

Let us see an example of asin() method.

## Example

Live Demo

public class Demo {
public static void main(String args[]) {
double val = Math.PI / 2;
System.out.println("Math.asin(" + val + ") = " + Math.asin(val));
}
}

## Output

Math.asin(0.027415567780803774) = 0.02741900326072046

Let us see an example of log() method.

## Example

Live Demo

public class Demo {
public static void main(String args[]) {
double val1 = 39564.9;
double val2 = 1;
System.out.println("Math.log(" + val1 + ") = " + Math.log(val1));
System.out.println("Math.log(" + val2 + ") = " + Math.log(val2));
}
}

## Output

Math.log(39564.9) = 10.585697640553684
Math.log(1.0) = 0.0