The Newton-Raphson method, or Newton method, is used to find the zeros or roots of equations numerically. One of the most popular usages is to calculate the square root of a number, without using the square root function. The basic principle used is that if x is a guess to the function f(x) = 0, then a better guess is given by
x - f(x) / f'(x),
where f'(x1) is the gradient of the function f(x) at the point x.
The method has some limitations. For example, if the first guess to the root of the equation is not close, then the method takes longer to find a solution. Also, if no solution exists, then each successive guess tends to a local minimum, rather than a root. It is also possible for some first guesses to lead to a local minimum and get "stuck" there, even when a real root does exist.
Newton-Raphson Formula Derivation
Figure 1 shows a function which has at least one real root or zero, λ. The function may be logarithmic, exponential, polynomial, trignometric or any other, provided the function is able to be differentiated. It is preferable, though not necessary, that the function is continuous.
The Newton-Raphson method is based on the premise that it is desired to find the value of λ, and the tentative assumption that the slope of the function at x1 (the first guess at λ) "points" to a better guess, x2.
- y1 = f(x1)
- The slope of the straight line through x2 is the first derivative of f(x) at x = x1. This is denoted by f'(x1)
- The equation for every straight line in two dimensions is y = m.x + c, where m is the gradient
- A formula is needed from which to calculate x2.
(y - y1) / (y2 - y1) = (x - x1) / (x2 - x1) and re-arranging:
y - y1 = (y2 - y1) × (x - x1) / (x2 - x1)
But (y2 - y1) / (x2 - x1) is just the gradient of the line, which equals f'(x1), and y1 = f(x1), so
y - f(x1) = f'(x1) × (x - x1)
Re-arranging to make x the subject gives
x = x1 + (y - f(x1)) ÷ f'(x1)
At x = x2, y = 0, since x2 lies on the x-axis, so the equation for x2 becomes
x2 = x1 - f(x1) / f'(x1)
Newton-Raphson Method To Find The Square Root of 2
As an example, the square root of 2 will be estimated. Noting that:
- f(x) is the equation x² - 2 = 0
- f'(x) is 2x
- The first guess, x1, is 1.000
x2 = 1.000 - (1.000² - 2) / (2 × 1.000)
Using 1.500 to make a better guess, x3,
x3 = 1.500 - (1.500² - 2) / (2 × 1.500)
= 1.500 - 0.25 / 3.000
The actual square root of 2 is 1.414 to three decimal places.
Newton-Raphson Method Summary
The Newton method to find the root of equations is widely used. The derivation of the formula has been described, and an example shown step by step. It has some limitations, as it cannot by itself detect when no real roots exist, and the result to which the iteration process leads is highly dependent on the choice of the very first guess, x1.
Newton-Raphson Method References
Since the Newton-Raphson formula has been derived from first principles, no other reference is necessary for this, but " Solving Nonlinear Equations with Newton's Method (Fundamentals of Algorithms) " by C. T. Kelley gives useful information about the practicalities and limitations of the process.