Taylor

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mia023
    New Member
    • May 2007
    • 89

    #1

    Taylor

    Hi i just want to ask if i want to write a java program that compute sin x and cos x using Taylor series. I don't know the logic about how to write this program and how to get Taylor series through programming
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by mia023
    Hi i just want to ask if i want to write a java program that compute sin x and cos x using Taylor series. I don't know the logic about how to write this program and how to get Taylor series through programming
    Can you write down the i-th term of a Taylor expansion of a certain function in
    terms of 'i'? If so you can you can use 'i' as a loop invariant counter:

    [code=java]
    double taylor= 0;
    for (int i= 0; i < max_term_index; i++)
    taylor+= current_term_in _terms_of(i);
    [/code]

    kind regards,

    Jos

    Comment

    Working...