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.

sin cos tan arcsin arccos arctan log ln exp square root power

**Use periodicity:**If*x*is in the range 0≤*x*≤360° then go on to step 2. Otherwise, reduce*x*so that it lies in the range 0≤*x*≤360° by adding or subtracting a suitable multiple of 360° from it (we are assuming that angle*x*is measured in degrees). This new*x*has the same value of the sin function that the original*x*has.-
**Use symmetry:**If*x*is in quadrant 1 then go on to step 3. Otherwise if it is in quadrant 2 call it*x*_{2}, if it is in quadrant 3 call it*x*_{3}, and if it is in quadrant 4 call it*x*_{4}.

The graph shows that four angles:*x*,*x*_{2},*x*_{3}, and*x*_{4}, all have the same value of the sin function (except for a − sign.) Thus instead of calculating the sin of*x*_{2},*x*_{3}, or*x*_{4}we can calculate the sin of*x*(the red one in quadrant 1) and just attach a − sign to the answer if the angle was in quadrant 3 or 4. Here are some examples. In each case the quadrant 1 angle is found by using the symmetry of the sin function:

- sin (110°) = sin (70°)
- sin (200°) = − sin (20°) ← attach a − sign
- sin (330°) = − sin (30°) ← attach a − sign

**Use the cofunction:**The argument*x*has now been reduced to be between 0° and 90°. If it is smaller than 45° then go on to step 4. Otherwise it can be made even smaller by using the following trick: instead of calculating sin(*x*) we calculate cos(90° −*x*). This picture shows why we can replace the sin of a big angle,*B*, by the cos of a small angle,*S*:

*x*to the small angle*S*. Angle*x*is now small enough to apply the polynomial approximation. Click here to use the cos polynomial, or proceed to step 4 to use the sin polynomial.

**Use the sin polynomial:**If angle*x*is in degrees then convert it to radians by multiplying it by π/180. Then substitute*x*into the formula: For*x*≤ π/4 radians (i.e. 45°) this polynomial is accurate to within ±0.00004.

- = sin (205°) ← use the periodicity of the sin function
- = − sin (25°) ← use the symmetry of the sin function
- nothing to do; the argument is already less than 45°
- ← 25° = 0.4363 radians

- nothing to do; the argument is already between 0 and 2π radians
- = sin (1.312) ← use the symmetry of the sin function
- = cos(0.2592) ← use the cofunction because the argument was greater than 45°
- ← use the cos polynomial

**Use periodicity:**If*x*is in the range 0≤*x*≤360° then go on to step 2. Otherwise, reduce*x*so that it lies in the range 0≤*x*≤360° by adding or subtracting a suitable multiple of 360° from it (we are assuming that angle*x*is measured in degrees). This new*x*has the same value of the cos function that the original*x*has.-
**Use symmetry:**If*x*is in quadrant 1 then go on to step 3. Otherwise if it is in quadrant 2 call it*x*_{2}, if it is in quadrant 3 call it*x*_{3}, and if it is in quadrant 4 call it*x*_{4}.

The graph shows that four angles:*x*,*x*_{2},*x*_{3}, and*x*_{4}, all have the same value of the cos function (except for a − sign.) Thus instead of calculating the cos of*x*_{2},*x*_{3}, or*x*_{4}we can calculate the cos of*x*(the red one in quadrant 1) and just attach a − sign to the answer if the angle was in quadrant 2 or 3. Here are some examples. In each case the quadrant 1 angle is found by using the symmetry of the cos function:

- cos (110°) = − cos (70°) ← attach a − sign
- cos (200°) = − cos (20°) ← attach a − sign
- cos (330°) = cos (30°)

**Use the cofunction:**The argument*x*has now been reduced to be between 0° and 90°. If it is smaller than 45° then go on to step 4. Otherwise it can be made even smaller by using the following trick: instead of calculating cos(*x*) we calculate sin(90° −*x*). This picture shows why we can replace the cos of a big angle,*B*, by the sin of a small angle,*S*:

*x*to the small angle*S*. Angle*x*is now small enough to apply the polynomial approximation. Click here to use the sin polynomial, or proceed to step 4 to use the cos polynomial.

**Use the cos polynomial:**If angle*x*is in degrees then convert it to radians by multiplying it by π/180. Then substitute*x*into the formula: For*x*≤ π/4 radians (i.e. 45°) this polynomial is accurate to within ±0.000004.

- = cos (205°) ← use the periodicity of the cos function
- = − cos (25°) ← use the symmetry of the cos function
- nothing to do; the argument is already less than 45°
- ← 25° = 0.4363 radians

- nothing to do; the argument is already between 0 and 2π radians
- = −cos (1.312) ← use the symmetry of the cos function
- = −sin(0.2592) ← use the cofunction because the argument was greater than 45°
- ← use the sin polynomial

**Use periodicity:**If*x*is in the range 0≤*x*≤180° then go on to step 2. Otherwise, reduce*x*so that it lies in the range 0≤*x*≤180° by adding or subtracting a suitable multiple of 180° from it (we are assuming that angle*x*is measured in degrees). This new*x*has the same value of the tan function that the original*x*has.-
**Use symmetry:**If*x*is in quadrant 1 then go on to step 3. Otherwise it is in quadrant 2, in which case we will call it*x*_{2}. The graph shows that, except for a − sign,*x*and*x*_{2}have the same value of the tan function. Thus instead of calculating the tan of*x*_{2}we can calculate the tan of*x*(the red one in quadrant 1) and just attach a − sign to the answer.

The quadrant 1 angle is found by using the symmetry of the tan function. For example tan (110°) = − tan (70°). **Use the cofunction:**The argument*x*has now been reduced to be between 0° and 90°. If it is smaller than 45° then go on to step 4. Otherwise it can be made even smaller by using the following trick: instead of calculating tan(*x*) we calculate tan(90° −*x*) and take the reciprocal. This picture shows why we can replace the tan of a big angle,*B*, by the reciprocal of the tangent of a small angle,*S*:

*x*to the small angle*S*.*x*is now less than 45°.

**Use a trigonometric identity:**If*x*is less than 22.5° then go on to step 5. Otherwise use this trig identity: 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 tan function is now less than 22.5°.

**Use the polynomial:**If angle*x*is in degrees then convert it to radians by multiplying it by π/180. Then substitute*x*into the formula: For*x*≤ π/8 radians (i.e. 22.5°) this polynomial is accurate to within ±0.000006.

- = tan (14°) ← use the periodicity of the tan function
- nothing to do; the argument is already between 0 and 90°
- nothing to do; the argument is already between 0 and 45°
- nothing to do; the argument is already between 0 and 22.5°
- ← 14° = 0.2443 radians

- nothing to do; the argument is already between 0 and 180°
- = − tan (70°) ← use the symmetry of the tan function
- = − 1 / tan(20°) ← use the “cofunction” because the argument was greater than 45°
- nothing to do; the argument is already less than 22.5°
- ← 20° = 0.3491 radians

- nothing to do; the argument is already between 0 and 180°
- nothing to do; the argument is already between 0 and 90°
- nothing to do; the argument is already between 0 and 45°
- use the trig identity
- Calculate the polynomial for tan (20°) using 20° = 0.3491 radians: and substitute the result into the trig identity of step 4:

We can calculate angle θ using the arcsin: Alternatively we can calculate angle θ using the arccos: In either case we have reduced the problem to calculating arctan. Using the algorithm for calculating the arctan (given below), this becomes:

**Use symmetry:**If the argument*x*is positive then go on to step 2. Otherwise use the fact that arctan(−*x*) = −arctan(*x*) to make the argument positive.**Use the complementary angle:**If the argument*x*is less than 1 then go on to step 3. Otherwise use the fact that: to replace the arctan of a value bigger than 1 by the arctan of a value smaller than 1. This equation follows from the fact that angles*B*and*S*in the triangle shown are given by:

and that .

**Use an identity:**If*x*≤ (about 0.268) then go on to step 3. Otherwise use the identity: to replace the arctan of a value*x*bigger than by the arctan of a value smaller than .

**Use the polynomial:**Substitute the argument*x*into the formula: For*x*≤ (about 0.268) this polynomial gives an angle in radians that is accurate to within ±0.00002. To convert this angle to degrees multiply it by 180/π.

- nothing to do; the argument is already positive
- nothing to do; the argument is already less than 1
- use the identity:
- use the polynomial to evaluate the new arctan: Substitute this back into the original arctan and then convert the answer to degrees:

**Express the number**If*x*in scientific notation:*x*=*m*· 10^{ p}thenlog (

where*x*) = log (*m*) +*p*,*p*is an integer and*m*(the new argument of the log function) is a number between 1 and 10.**Use the square root:**Use the fact that: to reduce the argument of the log function even further, to a value between 1 and .

**Replace log by ln:**Use the change of base formula:log (

(This follows from the fact that 1 / ln (10) = 0.43429448). Putting steps 1, 2 and 3 together gives:*x*) = 0.43429448 ln (*x*)**Use the polynomial:**For any argument*x*between 1 and , the following polynomial: where , accurately gives ln (*x*) to within ±0.0008.

- 900 = 9 · 10
^{ 2}so log (900) = log (9) + 2 - log (900) = 2 log (3) + 2
- log (900) = 0.86858896 ln (3) + 2
- use the polynomial to evaluate ln (3).

x = 3 gives y = 2/4 = 0.5 so the polynomial becomes: Substitute this back into the result from step 3:log (900) = 0.86858896 · 1.098 + 2 = 2.954

**Express the number**If*x*in scientific notation:*x*=*m*· 10^{ p}thenln (

where*x*) = ln (*m*) + 2.3025851*p*,*p*is an integer and*m*(the new argument of the log function) is a number between 1 and 10.

(Note that ln (10) = 2.3025851)**Use the square root:**Use the fact that: to reduce the argument of the ln function even further, to a value between 1 and .

Putting steps 1 and 2 together gives:**Use the polynomial:**For any argument*x*between 1 and , the following polynomial: where , accurately gives ln (*x*) to within ±0.0008.

- 9000 = 9 · 10
^{ 3}so ln (9000) = ln (9) + 3 · 2.3025851 - ln (9000) = 2 · ln (3) + 3 · 2.3025851
- use the polynomial to evaluate ln (3).

x = 3 gives y = 2/4 = 0.5 so the polynomial becomes: Substitute this back into the result from step 2:ln (9000) = 2 · 1.098 + 3 · 2.3025851 = 9.104

**Split up**Write*x*:*x = n + r*, where*n*is the nearest integer to*x*and*r*is a real number between −½ and +½. Then*e*^{ x}=*e*^{ n}·*e*^{ r}.**Evaluate**Multiply the number*e*^{ n}:*e*by itself*n*times. To 14 digits,*e*= 2.7182818284590. The multiplication can be done quite efficiently. For example*e*^{ 8}can be evaluated with just 3 multiplications if it is written as (((*e*)^{ 2 })^{ 2 })^{ 2}. To further increase efficiency various integer powers of*e*can be calculated once and stored in a lookup table.

**Evaluate**For*e*^{ r}using the polynomial:*r*between −½ and +½ this polynomial is accurate to within ±0.00003.

- Split it into two factors:
- Evaluate the first factor using multiplication:
- Evaluate the second factor using the polynomial: Multiply the two factors to get the answer:

The basic idea is this: if we want to calculate the square root of some number

Newton's method for finding this point starts with

Given any estimate

Starting with an initial guess of 50 here are the results of the first 6 iterations:

We have shown the calculation for

x_{1}50 x_{2}x_{3}30.2352941176471 x_{4}30.0009155413138 x_{5}30.0000000139698 x_{6}30.0000000000000

If you found this page in a web search you won’t see the

Click here to display it.