Cos func.

This is a discussion on Cos func. within the C Programming forums, part of the General Programming Boards category; OmGeek, with your permission, I just wanted to: Welcome tty0 to the forum!...

  1. #16
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    OmGeek, with your permission, I just wanted to:

    Welcome tty0 to the forum!

  2. #17
    Registered User
    Join Date
    Oct 2010
    Posts
    4
    Thnx Adak.

  3. #18
    Registered User
    Join Date
    Sep 2010
    Location
    Boston, MA
    Posts
    97
    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...

  4. #19
    Registered User
    Join Date
    Oct 2010
    Posts
    107
    Quote Originally Posted by omGeeK View Post
    this is what i was given and i am having a hard time understanding it.
    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.

  5. #20
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    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.

  6. #21
    Registered User
    Join Date
    Sep 2010
    Location
    Boston, MA
    Posts
    97
    Quote Originally Posted by carrotcake1029 View Post
    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.
    This helped tremendously, and if you wouldn't mind, the more understanding the better i think.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with cos, sin and tan^-1 (arctan);
    By xIcyx in forum C Programming
    Replies: 15
    Last Post: 04-23-2007, 09:14 AM
  2. sin() and cos() that use degrees
    By dwks in forum C Programming
    Replies: 3
    Last Post: 05-14-2005, 04:29 PM
  3. cos() returning wrong result?
    By rmullen3 in forum C++ Programming
    Replies: 6
    Last Post: 08-20-2002, 11:46 PM
  4. typedef a func
    By trekker in forum C Programming
    Replies: 4
    Last Post: 07-02-2002, 05:15 AM
  5. Delete & print func()
    By spentdome in forum C Programming
    Replies: 5
    Last Post: 05-29-2002, 09:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21