# Sin And Cos Algorithms

Quick synopsis of formulas:

In [0,pi/2], you can estimate:

sin(x) ~= 0.01 * x * ( 100 - 15(x^2) )

cos(x) ~= 0.01 * [100 + {y-25}{y}] .........where y = 2*(x^2)

In [-pi/4,pi/4], you can estimate:

tan(x) ~= x + 0.43 * (x^3)

also remember, tan(x)=sin(x)/cos(x)

Error range: sin(x) within 0.011, cos(x) within 0.010, tan(x) within 0.009

In the range [0, pi/2], there are two simple Curta formulas that will give you a good estimate of sin(x) and cos(x) where x is in radians, usually within 0.01.

****

Recall how to do serial multiplication (A*B*C*D...)

****

First, let's recall how to do serial multiplication without clearing:

5*7*12*36

First, enter 5 in SR, and crank 7 times to get 35 in RR

Now enter 12 in SR. Since we want to get 35 *twelve* times, and we already have 35 *one* time in the RR, we need (12-1) *more* 35s. So decrease 12 by one in the SR to 11.

Now so you don't forget how many times to turn, move the registers so the leftmost digit of current result (35) lines up with rightmost digit of SR (11). See a 3, crank three times. Move one to the right, see a 5, crank 5 times. Now you have 420.

Enter (36-1)=35 in SR. Line up the 5 with the 4 in 420. Crank 4 times, twice in the next position, 0 times in the last position. Now you have 15120.

*****

Sin(x)

*****

Recall that the Taylor series expansion of sin(x) is

x - (x^3)/3! + (x^5)/5! - (x^7)/7! ...

A very good estimate for this in the range [0, pi/2] is

x - (x^3)/6.66666667

which can be rewritten as

(1/100) * x * (100-15(x^2))

So all you need to do is

A. square x

B. multiply by -15 and add 100

C. multiply the result by x again

D. move the decimal 2 spaces to the left.

Accuracy is within + or - 0.011

Example with x=1.2 radians

A. x^2 = 1.44

B. Use (-15-1)=-16 to do a serial multiplication: 1.44*-15. Then add 100 to get 78.4.

C. Do another serial multiplication with 12 - 1 = 11 (for the 1.2.) Result is 94.08.

D. Result is 0.9408. Actual sin(1.2)=0.9320. Error is 0.0088.

*****

Cos(x)

*****

Recall that the Taylor series expansion of cos(x) is

1 - (x^2)/2! + (x^4)/4! - (x^6)/6! ...

A very good estimate for this in the range [0, pi/2] is

1 - (x^2)/4 + (x^4)/25

which can be rewritten as

(1/100) * [100 + {2(x^2)-25}{2(x^2)}]

and if you define y=2(x^2), you have

(1/100) * [100 + {y-25}{y}]

So all you need to do is

A. square x and multiply by 2. This is y, put this in SR.

B. multiply by (y-25)

C. add 100

D. move the decimal 2 spaces to the left.

Accuracy is within + or - 0.010

Example with x=1.2 radians

A. 2(x^2) = 2.88 = y

B. Multiply by y-25.

C. Add 100. You should get 36.2944

D. Result is 0.362944. Actual cos(1.2)=0.362358. Error is 0.000586.

*****

Tan(x)

*****

Recall that the Taylor series expansion of cos(x) is

x + (x^3)*2/3! + (x^5)*16/5! ...

A very good estimate for this in the range [0, pi/4] is

x + 0.43 * (x^3)

Edit Text of this page (last edited July 18, 2006 by adsl-69-219-41-94.dsl.chcgil.ameritech.net)
Find Page by browsing or searching
Brought to you by Curta.org