0

Taylor series of sin (x)

6th Nov 2016, 11:21 AM
peniel galilee
peniel galilee - avatar
6 Respuestas
+ 2
which code the inbuilt one or our own can you please post your code I will write there are you getting problem building power factorial functions etc. there are inbuilt pow function and perhaps factorial function. you can make make a function that takes two arguments and return the term according to pattern now run a loop at first line it would add one term to the sin with positive sign and then increases to the x to 2 in third step it would subtract to the sin again a term using function and then again increases the value of x. run the loop with x 7 9 13 anything use double with returning Taylor term
6th Nov 2016, 4:19 PM
Sandeep Chatterjee
+ 1
it is sin(x)=x-x^3/3! +x ^5/5! -x^7/7! +x^9/9! + ... if you are making for this then good idea but there is a function in c++ to calculate sin cos tan directly however to dont forget to add math.h library in the begin
6th Nov 2016, 4:14 PM
Sandeep Chatterjee
+ 1
my problem is how to write the code.i have been trying but it's not coming out
6th Nov 2016, 4:17 PM
peniel galilee
peniel galilee - avatar
+ 1
here is my initial code #include <iostream> using namespace std; int main () { const double Pi=3.141592; double x; cin>>x; const double c=((x/180)*Pi); const double deg2rad ((x/180)*Pi); double sine ((x/180)*Pi); double cosine ((x/180)*Pi); cout <<''Enter the variable x in degree [0...360]: '' << x <<endl; cout <<''sine of x= '' <<x << ''degrees is ''<<sin (c)<<endl; cout <<''cosine of x =''<< x << ''degrees is '' <<cos (c)<<endl; return 0; } here is my code.normally from here I should write some codes in order to have at the end the taylor series of sine and cosine.when having maybe sin(1) or order.my big deal is what to remove from my code and what to insert.i first tried to write the the taylor series of sin (x) in and expanded way in the brackets but everytime it says value x not initiated
7th Nov 2016, 6:57 AM
peniel galilee
peniel galilee - avatar
0
ok
6th Nov 2016, 4:21 PM
peniel galilee
peniel galilee - avatar
0
and I read my books and it is said I should not use <cmath> library
7th Nov 2016, 6:58 AM
peniel galilee
peniel galilee - avatar