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 ore)^{ x}square root (sqrt) power ( y)^{ x}

**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 sine 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 sine function (except for a − sign.) Thus instead of calculating the sine of*x*_{2},*x*_{3}, or*x*_{4}we can calculate the sine 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 sine 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 sine of a big angle,*B*, by the cosine 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 cosine polynomial, or proceed to step 4 to use the sine polynomial.

**Use the sine 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 cosine 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 cosine 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 cosine function (except for a − sign.) Thus instead of calculating the cosine of*x*_{2},*x*_{3}, or*x*_{4}we can calculate the cosine 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 cosine 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 cosine of a big angle,*B*, by the sine 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 sine polynomial, or proceed to step 4 to use the cosine polynomial.

**Use the cosine 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 cosine function
- = − cos (25°) ← use the symmetry of the cosine 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 cosine function
- = −sin(0.2592) ← use the cofunction because the argument was greater than 45°
- ← use the sine 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 tangent 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 tangent function. Thus instead of calculating the tangent of*x*_{2}we can calculate the tangent 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 tangent 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 tangent 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 tangent 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 tangent 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 tangent 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 arcsine: 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:

**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 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:

and that .

**Use an identity:**If*x*≤ (about 0.268) then go on to step 3. Otherwise use the identity: to replace the arctangent of a value*x*bigger than by the arctangent 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 arctangent: Substitute this back into the original arctangent and then convert the answer to degrees:

**Express the number***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 base 10 logarithm function) is a number between 1 and 10.**Use the square root:**Use the fact that: to reduce the argument of the base 10 logarithm 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***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 natural logarithm 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 natural logarithm 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.