OmGeek, with your permission, I just wanted to:
Welcome tty0 to the forum!
OmGeek, with your permission, I just wanted to:
Welcome tty0 to the forum!
Thnx Adak.
No problem, welcome by the way. I am very new to programming myself and this website. Nonetheless
i have figured out the TERMn= ((x^2)/(2n)(2n-1))*TERMn-1
so for example TERM0=1
then TERM1= ((x^2)/2(1)*(2*1-1))*TERM0
so now i need to do that for 7 terms i just dont know how to store each term somewhere after i find them and add them to the function that cos = 1-TERM1+TERM2-TERM3+TERM4...
That's a Taylor series expansion of cos(x-c) with c = 0. The idea is to approximate a transcendental function like the cosine by approximating it with a truncated polynomial when we have analytical solutions for the derivatives. Since cos(0) and sin(0) are straight forward (1 and 0 respectively), we can easily derive the Taylor series expansion for any number of digits.
I just found something on Wikipedia that I think relates. Basically, it's a recurrence relation that you can use for both sine and cosine, and you decide N where N the number of approximations in advance. Just read under "A better, but still imperfect, recurrence formula." The recurrence relation is given right after "A significant improvement is to use the following modification to the above, a trick (due to Singleton, 1967) often used to generate trigonometric values for FFT implementations:"
EDIT: Oh hai tty0!
Last edited by QuadraticFighte; 10-16-2010 at 08:06 PM.
You should take a look at what I did when I originally transformed that series into a program. I used the exact same series you did and broke it down piece by piece to make it better.
Scroll down toward the bottom for the final code:
Cosine - Maclaurin Series
If you are truly interested, I would be willing to scan a paper showing how the math cancels a lot of the operations like factorials and exponents out.
Last edited by carrotcake1029; 10-16-2010 at 10:42 PM.