taylor series for sin x
sin x = x - x^3/3! + x^5/5! - x^7/7! + ...
how do you make a c++ program for it?
this is my homework, but I can't figure it out because taylor series notation is so complicated. Please explain it to me
How to make a c++ program (turbo c++) that compute the sin value of X..using taylor series for sin x?
It sounds like your confusion revolves around the factorial. Simply make a function that calculates the factorial (your teacher probably wants you to use a recursive function to test if you understand your lessons). I have provided a recursive function in my reference to help you out, but beware because recursive programs can chew up memory if not implemented properly.
Example
Fact (x) // where x is a integer.
sin x = x - x^3/3! + x^5/5! - x^7/7! Becomes:
Sin (x); function and this is implemented as:
this is a snippet from the Sin() (with some degree of error) function you make:
%26lt;stuff left out here%26gt;
y=x -x^3/Fact(3) +x^5/Fact(5)- x^7/Fact(7); // you will need to decide how far to take this calculation
return(y) ;
%26lt;stuff left out here%26gt;
I know I have not done all the leg work for you but I think you are smart enought to fill in all the boring stuff.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment