The Newton-Raphson Method
The Newton-Raphson Method
To converge to the solution, the new solution is x1, therefore assume that
𝑏 𝑓 𝑥
𝑦 𝑓 𝑥
𝑓 𝑥
𝑥 𝑥
The slope crosses the x-axis at x = x1 and y=0. Since this point (x1, f(x1)) = (x1,0)
lies on the slope line, it satisfies the above equation. By substitution,
0 𝑓 𝑥 𝑓 𝑥 . 𝑥 𝑥
17
University of Baghdad Numerical Methods and Reservoir Simulation
Department of Petroleum Engineering 2020
𝑓 𝑥
𝑥 𝑥
𝑓 𝑥
and in general,
𝑓 𝑥
𝑥 𝑥
𝑓 𝑥
Newton-Raphson Algorithm
1- Assume the initial guess of the root (xn)
2- Apply the following equation to calculate the new guess of the root (xn+1):
𝑓 𝑥
𝑥 𝑥
𝑓 𝑥
3- Calculate the absolute difference between the old and the new guesses of root
|𝒙𝒏 𝟏 𝒙𝒏 |, and then if
|𝒙𝒏 𝟏 𝒙𝒏 | 𝜀
Then, xn+1 is the final solution and the solution procedure should STOP.
Otherwise, if
|𝒙𝒏 𝟏 𝒙𝒏 | 𝜀
Then,
𝒙𝒏 𝟏 𝒙𝒏 , and go back to STEP 2.
where, ε is allowable error difference
Example (1)
Use Newton’s method to approximate the positive root of
𝑥 𝑥 1 0
Accurate to within ε=0.001.
Assume the initial guess = 1
Solution
𝑓 𝑥 𝑥 𝑥 1 0
𝑓 𝑥 6𝑥 1
18
University of Baghdad Numerical Methods and Reservoir Simulation
Department of Petroleum Engineering 2020
1 1 -1 5 1.2 0.2
2 1.2 0.785984 13.92992 1.143576 0.056424
3 1.143576 0.093032 10.73481 1.134909 0.008666
4 1.134909 0.001907 10.29685 1.134724 0.000185
Note that after 4 steps we have |𝒙𝒏 𝟏 𝒙𝒏 | = 0.000185 < 0.001 hence the required
root approximation is xn+1 = 1.1349.
19
University of Baghdad Numerical Methods and Reservoir Simulation
Department of Petroleum Engineering 2020
Example (2)
Resolve Example (1) using initial guess = 5
n xn f(xn) f'(xn) xn+1 |𝒙𝒏 𝟏 𝒙𝒏 |
1 5 15619 18749 4.166942 0.833058
2 4.166942 5229.691 7536.697 3.473045 0.693897
3 3.473045 1750.469 3030.82 2.895489 0.577556
4 2.895489 585.3982 1220.128 2.415705 0.479784
5 2.415705 195.3142 492.5949 2.019204 0.396501
6 2.019204 64.75765 200.3967 1.696057 0.323147
7 1.696057 21.10754 83.20801 1.442385 0.253672
8 1.442385 6.562686 36.45909 1.262384 0.180001
9 1.262384 1.784755 18.2357 1.164512 0.097871
10 1.164512 0.329302 11.84906 1.136721 0.027791
11 1.136721 0.020639 10.38728 1.134734 0.001987
12 1.134734 9.86E-05 10.28811 1.134724 9.59E-06
20