The implementation can be found here(*).

The sin function is approximated by a 13-degree polynomial. That is, a function on the shape

       c12x12 + c11x11 + ... + c1x1 + c0x0

on the interval [0,ฯ€/4]

The description of the algorithm looks as follows:

33 * Algorithm
34 *      1. Since sin(-x) = -sin(x), we need only to consider positive x.
35 *      2. if x < 2^-27 (hx<0x3e400000 0), return x with inexact if x!=0.
36 *      3. sin(x) is approximated by a polynomial of degree 13 on
37 *         [0,pi/4]
38 *                               3            13
39 *              sin(x) ~ x + S1*x + ... + S6*x
40 *         where
41 *
42 *      |sin(x)         2     4     6     8     10     12  |     -58
43 *      |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x  +S6*x   )| <= 2
44 *      |  x                                               |
45 *
46 *      4. sin(x+y) = sin(x) + sin'(x')*y
47 *                  ~ sin(x) + (1-x*x/2)*y
48 *         For better accuracy, let
49 *                   3      2      2      2      2
50 *              r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6))))
51 *         then                   3    2
52 *              sin(x) = x + (S1*x + (x *(r-y/2)+y))
53 */

(*) Disclamer: Talking about OpenJDK here

Answer from aioobe on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ ref_math_sin.asp
Java Math sin() Method
Java Examples Java Videos Java ... ... System.out.println(Math.sin(3)); System.out.println(Math.sin(-3)); System.out.println(Math.sin(0)); System.out.println(Math.sin(Math.PI)); System.out.println(Math.sin(Math.PI/2));...
๐ŸŒ
Programiz
programiz.com โ€บ java-programming โ€บ library โ€บ math โ€บ sin
Java Math sin()
Note: If the argument is zero, then the result of the sin() method is also zero with the same sign as the argument. import java.lang.Math; class Main { public static void main(String[] args) { // create variable in Degree double a = 30; double b = 45; // convert to radians a = Math.toRadians(a); b = Math.toRadians(b); // print the sine value System.out.println(Math.sin(a)); // 0.49999999999999994 System.out.println(Math.sin(b)); // 0.7071067811865475 // sin() with 0 as its argument System.out.println(Math.sin(0.0)); // 0.0 } }
Discussions

math - How is sine implemented in Java? - Stack Overflow
I found this question about sin in Java, but that's asking why the sin function isn't wrapped in native code. I'm asking something entirely different. I want to know how the function was implemented. (Since it's wrapped in native code, I can't see it.) Did they simply implement it from the Taylor series expansion: ... I can't look at the code for the Math.sine() function, since it gets wrapped up in native code. ... Math.PI is a constant. ... Try Googling for "fdlibm source... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Differences between Math.sin() and StrictMath.sin()
JVM generates native platform specific code in Math. Modern processors have separate instructions for many trigonometry functions, those are much faster. JVM makes use of them if possible. StrictMath is the "default" if those native don't exist. And it does the math in software. (hence the slower runtime) More on reddit.com
๐ŸŒ r/java
12
38
June 29, 2013
Java's 13th order polynomial has somehow beat my third-order polynomial in computational efficiency. How did they do it?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
๐ŸŒ r/learnprogramming
7
1
June 1, 2023
I translated the C Donut source code into Java because I was bored
You should try making this a donut shape too, Java will allow it! You can shorten some expressions by doing static imports (e.g. import static java.lang.System.out, import static java.lang.Math.sin, etc.) More on reddit.com
๐ŸŒ r/ProgrammerHumor
7
28
July 6, 2020
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-math-sin-method-examples
Java Math sin() method with Examples - GeeksforGeeks
July 11, 2025 - // 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)); } }
๐ŸŒ
Tabnine
tabnine.com โ€บ home page โ€บ code โ€บ java โ€บ java.lang.math
java.lang.Math.sin java code examples | Tabnine
* @param radians the angle in radians */ public Vector2 rotateRad (float radians) { float cos = (float)Math.cos(radians); float sin = (float)Math.sin(radians); float newX = this.x * cos - this.y * sin; float newY = this.x * sin + this.y * cos; ...
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ java math sin()
Java Math sin() | Scaler Topics
April 14, 2024 - The built-in java.lang.Math.sin() function returns the sine value of the argument supplied. The argument is expected to be in radians. If the argument is NaN (Not-a-Number) or infinity, the function will return NaN as the outcome.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ trigonometric-functions-in-java-with-examples
Trigonometric Functions in Java with Examples - GeeksforGeeks
December 29, 2025 - Example 1 : Program demonstrating ... 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); ...
Find elsewhere
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ java โ€บ number_sin.htm
Java - sin() Method
September 30, 2019 - public class Test { public static void main(String args[]) { double degrees = 45.0; double radians = Math.toRadians(degrees); System.out.format("The value of pi is %.4f%n", Math.PI); System.out.format("The sine of %.1f degrees is %.4f%n", degrees, Math.sin(radians)); } } This will produce the ...
๐ŸŒ
Reddit
reddit.com โ€บ r/java โ€บ differences between math.sin() and strictmath.sin()
r/java on Reddit: Differences between Math.sin() and StrictMath.sin()
June 29, 2013 -

...besides the obvious? So a couple years ago I was working on a hobby project and I had to use sin() a lot (it could be several billions of calls). So I was looking at ways to speed it up. One of the things I did was to look at the source. Math.sin's (which I was using) body was:
public static double sin(double a)
{
return StrictMath.sin(a);
}

So I thought, why not just use StrictMath.sin() instead and save a call/return? Turns out the execution time increased, every time. I asked my professor and he didn't know. So I asked the java forums, and I never got a definite answer. So now I figure I'll ask here as the thought came up. Does anyone know? I assume there's some trickery going on (like the source for Math.java isn't the actual implementation or some such).

๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ standard-library โ€บ java โ€บ lang โ€บ Math โ€บ sin
Java Math sin() - Calculate Sine Value | Vultr Docs
December 3, 2024 - This code snippet converts 90 degrees to radians and calculates the sine value. The Math.sin() method requires the angle in radians, thus necessitating the conversion.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ java โ€บ lang โ€บ math_sin.htm
Java - Math tan(double x) method
March 24, 2009 - package com.tutorialspoint; public class MathDemo { public static void main(String[] args) { // get a double number double x = 45.0; // convert it to radian x = Math.toRadians(x); // print the trigonometric sine for this double System.out.println("Math.sin(" + x + ")=" + Math.sin(x)); } }
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ algorithms โ€บ using math.sin with degrees
Using Math.sin with Degrees | Baeldung
January 25, 2024 - Whenever we are using any of Javaโ€™s trigonometric functions, we should first think about what is the unit of our input. We can see this principle in action by taking a look at the Math.sin method, one of the many that Java provides:
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ java โ€บ math methods โ€บ .sin()
Java | Math Methods | .sin() | Codecademy
July 28, 2021 - The Math.sin() method returns the trigonometric sine of an angle argument, given in radians. ... Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more! ... Learn to code in Java โ€” a robust programming language used ...
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2022 โ€บ 10 โ€บ java-math-sin-method
Java Math.sin() Method
December 17, 2022 - public class JavaExample { public static void main(String[] args) { double degrees = -90; double degrees2 = 90; double degrees3 = 180; double degrees4 = -180; System.out.println(Math.sin(Math.toRadians(degrees))); System.out.println(Math.sin(Math.toRadians(degrees2))); System.out.println(M...
๐ŸŒ
Princeton CS
introcs.cs.princeton.edu โ€บ java โ€บ 13flow โ€บ Sin.java.html
Sin.java
December 2, 2024 - * ******************************************************************************/ public class Sin { public static void main(String[] args) { double x = Double.parseDouble(args[0]); // convert x to an angle between -2 PI and 2 PI x = x % (2 * Math.PI); // compute the Taylor series approximation ...
๐ŸŒ
AlphaCodingSkills
alphacodingskills.com โ€บ java โ€บ notes โ€บ java-math-sin.php
Java Math sin() Method - AlphaCodingSkills
June 17, 2012 - In the example below, sin() method ... of an angle. import java.lang.*; public class MyClass { public static void main(String[] args) { System.out.println(Math.sin(Math.PI/6)); System.out.println(Math.sin(Math.PI/4)); System.out.println(Math.sin(Math.PI/3)); } }...
๐ŸŒ
PREP INSTA
prepinsta.com โ€บ home โ€บ java tutorial โ€บ java math sin() method
Java Math sin() Method | prepinsta
July 20, 2023 - public class Main{ public static void main(String[] args) { double angle = Math.toRadians(30); // convert degrees to radians double sine = Math.sin(angle); // calculate sine of angle System.out.println("Sine of 30 degrees: " + sine); } } ... ...
๐ŸŒ
Java Tutorial HQ
javatutorialhq.com โ€บ java tutorial โ€บ java.lang โ€บ math โ€บ sin() method example
Java Math sin() method example
September 30, 2019 - Below is a java code demonstrates the use of sin() method of Math class. The example presented might be simple however it shows the behaviour of the sin() method. package com.javatutorialhq.java.examples; import java.util.Scanner; /* * This example source code demonstrates the use of * sin() method of Math class */ public class MathSineExample { public static void main(String[] args) { // Ask for user input System.out.print("Enter an angle in degrees:"); // use scanner to read the console input Scanner scan = new Scanner(System.in); // Assign the user to String variable String s = scan.nextLin
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ java-sin-function
Java sin Function
March 28, 2025 - Java sin function is a Math Library function that is used to calculate the Trigonometry Sine for given expression. Syntax Math.sin (double x)