10 - MatLab
10 - MatLab
2. Newton-Raphson
Newton-Raphson is the most widely used method for locating the root. If the initial guess
at the root is xi, a tangent can be extended from the point [xi, f(xi)]. The point where the
tangent crosses the x axis usually represents the improved estimate of the root.
𝑓(𝑥𝑖 ) − 0
𝑓 ′ (𝑥𝑖 ) =
𝑥𝑖 − 𝑥𝑖+1
which can be rearranged to the yield and we reach the Newton-Raphson formula.
𝑓(𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 −
𝑓 ′ (𝑥𝑖 )
Ex.1. Use the Newton-Raphson method to estimate the root of f(x) = e-x – x employing an
initial guess of x0 = 0.
𝑓 ′ (𝑥) = −𝑒 −𝑥 − 1
which can be substituted along with the original function into the Newton-Raphson
formula to get:
𝑒 −𝑥𝑖 − 𝑥𝑖
𝑥𝑖+1 = 𝑥𝑖 −
𝑒 −𝑥𝑖 − 1
Starting with the initial guess of x0 = 0, this iterative equation can be applied to compute
i xi εt (%)
0 0 100
1 0.500000000 11.8
2 0.566311003 0.147
3 0.567143165 0.0000220
4 0.567143290 <10-8
The approach rapidly converges on the true root. Notice that in each iteration true percent
relative error decreases much faster than it does on fixed-point iteration. Like as the other
root location methods, you can terminate the iteration with a stopping criterion.
2. Secant Methods
In the Ex.1 the possible problem in implementing the Newton-Raphson method is the
evaluation of the derivative. Although this is suitable for polynomials and many other
functions, there are certain functions whose derivatives may be difficult or inconvenient
to evaluate. For these cases, derivatives can be approximated by a backward finite
divided difference:
𝑓(𝑥𝑖−1 ) − 𝑓(𝑥𝑖 )
𝑓 ′ (𝑥𝑖 ) =
𝑥𝑖−1 − 𝑥𝑖
The equation can be substituted to the Newton-Raphson formula to gather the below
iterative equation, which is called Secant method formula:
𝑓(𝑥𝑖 )(𝑥𝑖−1 − 𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 −
𝑓(𝑥𝑖−1 ) − 𝑓(𝑥𝑖 )
Note that Secant Method requires two initial guesses of x. However, because f(x) is not
changing sign between the guesses, it is not classified as bracketing method. This is an
open method.
Rather than using two arbitrary values to estimate the derivative, an alternative approach
involves a fractional perturbation of the independent variable to estimate f’(x),
where δ is a small perturbation fraction. This approximation can be again substituted into
Newton-Raphson formula to yield the following iterative equation, which is called
Modified Secant Method:
𝛿𝑥𝑖 𝑓(𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 −
𝑓(𝑥𝑖 + 𝛿𝑥𝑖 ) − 𝑓(𝑥𝑖 )
Example. Use the Modified Secant Method to determine the mass of the bungee-jumper
with a drag coefficient of 0.25 kg/m to have a velocity of 36 m/s after 4 s of free-fall.
Acceleration gravity 9.81 m/s2, initial guess is 50kg and a value of 10-6 for perturbation
fraction.