/* compute cos(x) using the terms of the series with absolute value > 0.0001. */ #include #include using namespace std; double approx(double); double fact(int); int main( ) { double x; cout << "Enter the value of x: "<> x; cout << "The value of cos(x) using C++ library function is: " << cos(x) << endl; cout << "The value of cos(x) using the series approximation is: " << approx(x) << endl; return 0; } double approx(double x) //compute cos(x) using terms of the series { double y = 1.0; double term; // int a; int k = 1; term = pow(-1.0,k) * pow(x,2*k)/fact(2*k); while(fabs(term) > 0.0001) { y = y + term; k = k + 1; term = pow(-1.0,k) * pow(x,2*k)/fact(2*k); // cout << "term = " << term <