// Newton Raphson Method #include #include #include // Define your function here float f(float x) { return (x+log(x)-2); } // 1st derivative of the above float df(float x) { return (1+(1/x)); } // Main program main() { int itr, maxitr; float h, x0, x1, aerr; printf("Enter the value of x0, tolerance, maximum iteration \n"); scanf("%f%f%d", &x0, &aerr, &maxitr); for(itr=1; itr<=maxitr; itr++) { h = f(x0)/df(x0); x1 = x0 - h; printf("Iteration %2d, x = %9.6f\n", itr, x1); if(fabs(h)