## [TECH] APPROXIMATING THE SINUS VALUE [UPDATE]

*2009 April 02 | 0 comments*

Today I've been trying to do some strange stuff for which I needed to manually compute the sinus value of a given angle.

A few hours later I succeded in understanding how to do it:

The value is incomputible, but you can approximate it (much like Pi).

The formula is

(-1)

^{n}*((angle^(2*n+1))/(2*n+1)!)n: Iteration of the approximation, starting with 0

!: Product of all whole integers from 1 to x (for example: (2*3+1)! == (6+1)! == 7! == 1*2*3*4*5*6*7)

angle: The angle for which you want the sinus value, multiplied by Pi, divided by 180 (for example: 30*3.1415926/180)

Here's an example for angle 30° and 3 iterations:

angle = 30 * 3.1415926 / 180 = .52359876666666666666

Iteration n=0:

(-1)

^{0}*((angle^(2*0+1))/(2*0+1)!) == angle/1 == .52359876666666666666Iteration n=1:

(-1)

^{1}*((angle^(2*1+1))/(2*1+1)!) == -(.14354756987763735945/(1*2*3)) == -.02392459497960622657Iteration n=2:

(-1)

^{2}*((angle^(2*2+1))/(2*2+1)!) == .03935437997487359868/(1*2*3*4*5) == .00032795316645727998Now we add the results:

.52359876666666666666 + (-.02392459497960622657) + .00032795316645727998 == .50000212485351772007

Which is approximately 0.5 which is sin(30).

q.e.d.

Here's a small approximator in javascript. Try changing the value of Pi :-)

degrees

iterations

Pi:

sin(30):

Calculate Sinus

EOF

Category: blog

Tags: Tech

## Post a comment

All comments are held for moderation; basic HTML formatting is accepted.