Computer Science, asked by barnali12, 11 months ago

Write a program to find cos(x) for any given x (degrees) using 10 terms of the Taylor series. Express your result by rounding up to 3 digit after the decimal point.

Answers

Answered by studyprincess
0

Answer:

I will send you after I write it

Answered by lovingheart
0

A program to find cos(x) for any given x :

using namespace std;  

 

const double PI = 3.142;  

 

double FindcosXSertiesSum(double x,  int n)  

{  

   x = x * (PI / 180.0);  

 

   double dres = 1;  

   double dsign = 1, dfact = 1,  dpow = 1;  

   for (int i = 1; i < 5; i++)  

   {  

       dsign = dsign * -1;  

       dfact = dfact * (2 * i - 1) * (2 * i);  

       dpow = dpow * x * x;  

       dres = dres + dsign * dpow / dfact;  

   }  

 

   return dres;  

}  

 

int main()  

{  

   float x = 50;  

   int n = 5;  

   cout <<Find cosXSertiesSum(x, 5);  

   return 0;  

}  

Similar questions