/*--------------------------------------------------------------------*/ /* Problem chapter3_102 */ /* */ /* Newton's formula for a root of x^2=cos(x) */ #include #include using namespace std; int main() { double a; cout << "Enter an initial approximation between 0 and 1: "; cin >> a ; while ( fabs(a*a-cos(a))>1e-5 ) a -= (a*a-cos(a))/(2.0*a+sin(a)); cout << " the root is " << a << endl; // Exit program. return 0; }