This example demonstrates how to use the trigonometric methods of the `Math`

class. You can see the use of method such as `Math.sin()`

, `Math.cos()`

, `Math.tan()`

, etc.

package org.kodejava.example.math; public class TrigonometricExample { public static void main(String[] args) { double radians = 1.0d; double sine = Math.sin(radians); double cosine = Math.cos(radians); double tan = Math.tan(radians); double asine = Math.asin(sine); double acosine = Math.acos(cosine); double atan = Math.atan(tan); System.out.println("Sine of " + radians + " = " + sine); System.out.println("Cosine of " + radians + " = " + cosine); System.out.println("Tangent of " + radians + " = " + tan); System.out.println("Arcsine of " + sine + " = " + asine); System.out.println("Arccosine of " + cosine + " = " + acosine); System.out.println("Arctangent of " + tan + " = " + atan); } }

The output of the program are:

Sine of 1.0 = 0.8414709848078965 Cosine of 1.0 = 0.5403023058681398 Tangent of 1.0 = 1.5574077246549023 Arcsine of 0.8414709848078965 = 1.0 Arccosine of 0.5403023058681398 = 1.0 Arctangent of 1.5574077246549023 = 1.0

### Wayan Saryada

Programmer, runner, recreational diver, currently living in the island of Bali, Indonesia. Mostly programming in Java, creating web based application with Spring Framework, Hibernate / JPA.

#### Latest posts by Wayan Saryada (see all)

- How to format LocalDate object using Jackson? - February 16, 2017
- How to pretty print JSON string using Jackson? - February 15, 2017
- How to convert java.time.LocalDate to java.util.Date? - February 14, 2017