This section explains the algorithms. Studying the algorithms is educational because you learn a lot about the symmetries, identities and other properties of the functions and how they are exploited to make accurate evaluations of the functions.
sine (sin) cosine (cos) tangent (tan) arcsine (arcsin) arccosine (arccos) arctangent (arctan) base 10 logarithm (log) natural logarithm (ln) exponential with base e (exp or e x ) square root (sqrt) power ( y x )
For x ≤ π/4 radians (i.e. 45°) this polynomial is accurate to within ±0.00004.
For x ≤ π/4 radians (i.e. 45°) this polynomial is accurate to within ±0.000004.
to replace a calculation of the tangent of some angle by a calculation involving an angle that is half as big. The argument of the tangent function is now less than 22.5°.
For x ≤ π/8 radians (i.e. 22.5°) this polynomial is accurate to within ±0.000006.
and substitute the result into the trig identity of step 4:
Putting them together we get the equation:
We can use this equation to replace the calculation of the arcsine of some quantity x by the calculation of the arctangent of some related quantity. Click here to see the arctangent algorithm.
Putting them together we get the equation:
We can use this equation to replace the calculation of the arccosine of some quantity x by the calculation of the arctangent of some related quantity. Click here to see the arctangent algorithm.
Alternatively we can calculate angle θ using the arccosine:
In either case we have reduced the problem to calculating arctangent. Using the algorithm for calculating the arctangent (given below), this becomes:
to replace the arctangent of a value bigger than 1 by the arctangent of a value smaller than 1. This equation follows from the fact that angles B and S in the triangle shown are given by:
to replace the arctangent of a value x bigger than
For x ≤
Substitute this back into the original arctangent and then convert the answer to degrees:
log (x) = log (m) + p,where p is an integer and m (the new argument of the base 10 logarithm function) is a number between 1 and 10.
to reduce the argument of the base 10 logarithm function even further, to a value between 1 and
log (x) = 0.43429448 ln (x)(This follows from the fact that 1 / ln (10) = 0.43429448). Putting steps 1, 2 and 3 together gives:
where
Substitute this back into the result from step 3:
log (900) = 0.86858896 · 1.098 + 2 = 2.954
ln (x) = ln (m) + 2.3025851 p,where p is an integer and m (the new argument of the natural logarithm function) is a number between 1 and 10.
to reduce the argument of the natural logarithm function even further, to a value between 1 and
where
Substitute this back into the result from step 2:
ln (9000) = 2 · 1.098 + 3 · 2.3025851 = 9.104
For r between −½ and +½ this polynomial is accurate to within ±0.00003.
Multiply the two factors to get the answer:
This formula is easily derived by solving the equation:
for x2. This equation is just a statement that the slope of the curve at the blue dot (which is derived using calculus) equals the slope of the slanted side of the yellow triangle.
We have shown the calculation for x2 in detail. We have also shown the 6th decimal place in red. On the 6th iteration there is no change in this decimal place so we can stop and give x6 as the answer. Since we know that the exact answer is 30 we can see how the number of correct digits roughly doubles with every iteration.
x1 50 x2 ![]()
x3 30.2352941176471 x4 30.0009155413138 x5 30.0000000139698 x6 30.0000000000000
This equation follows from the identity e ln (x) = x and the exponention property of exponents.