#include #include using namespace std; double f( double x ) { return( x - cos(x) ); } double fp( double x ) { return( 1.0 + sin(x) ); } int main() { double x = 0.125; int n = 10; cout.precision(12); cout << "x0 = " << x << endl; for ( int i = 1; i <= n; i++ ) { if ( fp(x) == 0 ) { cout << "Zero derivative encountered at x = " << x << endl; break; } x = x - f(x) / fp(x); cout << "x" << i << " = " << x << endl; } cout << "\n\n"; system( "PAUSE" ); return( 0 ); }