You are on page 1of 11

Numerical Analysis

and Computation
Lecture # 5
(Solution of Non-Linear Equations)
Newton-Raphson Method

Course Instructor: Imtiaz


Mr. Attiq
Ali Iqbal
Shah Class: BSCS-F19
Office: IAA-405 Section: C
Pros and Cons of Bisection Method
Pros:
➢The convergence is guaranteed in [𝑎 𝑏] if 𝑓 (𝑎). 𝑓 (𝑏) < 0
➢Simple to implement and easy to understand
➢Error can be controlled. As iterations are conducted, the interval gets halved,
so one can guaranteed the error in the solution of the equation.

Cons:
➢The convergence of Bisection method is always slow.
➢If one of the initial guesses is closer to the root it will take larger number of
iterations to reach the root.
➢If 𝑓(𝑥) is such that it just touches the 𝑥 − axis, it will be unable to find the
lower guess and upper guess. For example
(𝑥 + 1.55)2 + sin(𝑥 ) + 1 = 0
Derivation of Newton-Raphson Method
Given a non-linear equation 𝑓 (𝑥 ) = 0 where 𝑓 is continuous and differentiable
function. If 𝑥𝑛 is the approximation of the root, then we draw a tangent line to
the graph of 𝑓 at 𝑥𝑛 . This line touches the point (𝑥𝑛 , 𝑓(𝑥𝑛 )) and has slope 𝑓′(𝑥𝑛 )
To find equation of this tangent line we use
𝑦 − 𝑦0 = 𝑚(𝑥 − 𝑥0 )
Where (𝑥0 , 𝑦0 ) = (𝑥𝑛 , 𝑓(𝑥𝑛 )) and 𝑚 = 𝑓′(𝑥𝑛 )
⇒ 𝑦 − 𝑓(𝑥𝑛 ) = 𝑓′(𝑥𝑛 )(𝑥 − 𝑥𝑛 )
⇒ 𝑦 = 𝑓′(𝑥𝑛 )(𝑥 − 𝑥𝑛 ) + 𝑓(𝑥𝑛 )
The point at which this line touches the x-axis i.e. 𝑦 = 0 will be the better
approximation of the root. Consider that point as 𝑥𝑛+1
⇒ 0 = 𝑓′(𝑥𝑛 )(𝑥𝑛+1 − 𝑥𝑛 ) + 𝑓(𝑥𝑛 )
Upon Rearranging we will get
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 −
𝑓′(𝑥𝑛 )

This formula is known as Newton-Raphson iterative method to find root of nonlinear


equation
Solution of Non-Linear Equations
Newton-Raphson Method
Given a non-linear equation 𝑓 (𝑥 ) = 0, if 𝑥𝑛 is an approximation to the root of
given equation then a better approximation is given by

𝑓 (𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 − ′ ; 𝑛 = 0,1,2, …
𝑓 (𝑥𝑛 )

OR
𝑓 (𝑥𝑛−1 )
𝑥𝑛 = 𝑥𝑛−1 − ′ ; 𝑛 = 1,2,3, …
𝑓 (𝑥𝑛−1 )
Repeat this process again and again until you find the root.
Stopping Criterias
• |𝑓(𝑥𝑛 )| < 𝜖

• |𝑥𝑛+1 − 𝑥𝑛 | < 𝜖

|𝑥𝑛+1 −𝑥𝑛 |
• <𝜖
|𝑥𝑛+1 |
Question: Given a non-linear equation 2𝑥 − 5𝑥 + 2 = 0. Use Newton-Raphson Method
to find the root of this equation correct upto 4 decimal places (𝜀 = 10−4 ). Use 𝑥0 = 0 as
initial guess.
Solution: First let’s Compute derivative of given function
𝑓 ′ (𝑥 ) = 2𝑥 (ln (2)) − 5
Now start newton’s method
𝑓 (𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 − ′ ; 𝑛 = 0,1,2, …
𝑓 (𝑥𝑛 )
We take initial guess 𝑥0 = 0
1st Iteration: n=0
𝑓 (𝑥0 )
𝑥1 = 𝑥0 − ′
𝑓 (𝑥0 )
𝑓 (𝑥0 ) = 3
𝑓 ′ (𝑥0 ) = −4.3069
3
𝑥1 = 0 − = 0.6966
−4.3069
2nd Iteration: n=1
𝑓 (𝑥1 )
𝑥2 = 𝑥1 − ′
𝑓 (𝑥1 )
𝑓 (𝑥1 ) = 0.1378
𝑓 ′ (𝑥1 ) = −3.8767
0.1378
𝑥2 = 0.6966 − = 0.7321
−3.8767

3rd Iteration: n=2


𝑓 (𝑥2 )
𝑥3 = 𝑥2 − ′
𝑓 (𝑥2 )
𝑓 (𝑥2 ) = 0.0005
𝑓 ′ (𝑥2 ) = −3.8486
0.0005
𝑥3 = 0.7321 − = 0.7322
−3.8486
4th Iteration: n=3
𝑓 (𝑥3 )
𝑥4 = 𝑥3 − ′
𝑓 (𝑥3 )
𝑓 (𝑥3 ) = 0.0000
𝑓 ′ (𝑥3 ) = −3.8485
0.0000
𝑥4 = 0.7322 − = 0.7322
−3.8485
Practice Question:
1. Given a non-linear equation
𝒄𝒐𝒔(𝒙) − 𝟑𝒙 = 𝟎
a). Use Newton-Raphson method to find the root of this equation correct
up to 6 decimal places (𝜀 = 10−6 ). Use 𝑥0 = 1 as initial guess.
Note: Do not forget to set the angle measurement of your calculator in
radians.

2. Generate a Newton Raphson formula to find square root of any positive


number 𝑁.
Hint: Let 𝑥 be a square root of any positive number 𝑁 then
𝑥 = √𝑁
⇒ 𝑥 2 − √𝑁 = 0 ⇒ 𝑓 (𝑥) = 𝑥 2 − √𝑁

You might also like