Newton-Raphson method
From Programming In C
Exercise 4.2
Note: this is an example of an actual assessment
The Newton-Raphson Method is a powerful method of finding the roots of the function f(x), that is the values of x for which f(x) = 0. Suppose that xold is an estimate of the root. Then a better estimate is xnew which is defined by:
xnew = xold-f(xold)/g(xold)
where g(x) = df(x)/dx.
This procedure is iterated until convergence is achieved, defined by |xnew – xold| < acc, where acc is a user-defined accuracy.
Use the Newton-Raphson method to find the root of the function f(x) = exp(-x) – x, starting the iteration at x = -10.0.
Use a do-while loop (or equivalent) algorithm.
How many iterations are required to obtain an accuracy (acc) of 10-6, and what is the solution at this accuracy ?
