Chapter 02
Solution of Algebraic and
Transcendental Equations
Shirin Sultana
Assistant Professor
Department of CSE
Daffodil International University,
Ashulia, Dhaka, Bangladesh.
Newton-Raphson Method
2
Introduction
Newton–Raphson Method
(also known as Newton’s Method)
• Named after Isaac Newton and Joseph Raphson.
• An open method: requires only one initial guess (unlike the bisection method which
needs two).
• Uses the first derivative of the function to iteratively improve the root
approximation.
• Often used to improve the accuracy of roots obtained through other methods.
• Most effective when the derivative near the root is non-zero and relatively large.
• May fail or diverge if the derivative is zero or if the function behaves poorly near the
root.
3
Geometry and Intuition
• The geometry behind Newton’s method is illustrated in
Figure 1, where the root to be found is denoted by 𝑟. 𝑌 𝑦 = 𝑓(𝑥)
• We start with an initial approximation 𝑥0 , obtained by 𝑥0 , 𝑓 𝑥0 Tangent Line
guessing, sketching 𝑓(𝑥), or using a computer graph.
𝑓(𝑥0 )
• Consider the tangent line 𝐿 to the curve 𝑦 = 𝑓(𝑥) at the 𝐿
𝑋′ 𝑟 𝑋
point 𝑥0 , 𝑓 𝑥0 . 𝑥1 𝑥0
• Denote the x-intercept of this tangent line by 𝑥1 .
𝑌′
Figure 1
• The idea behind Newton’s method is that the tangent
line is close to the curve and so its x-intercept, 𝑥1 , is
close to the x-intercept of the curve (namely, the root r
that we are seeking).
4
Deriving the formula for 𝒙𝟏
′
• The slope of the tangent line L at 𝑥0 is 𝑓 𝑥0 .
𝑌 𝑦 = 𝑓(𝑥)
• The equation of L is: 𝑥0 , 𝑓 𝑥0 Tangent Line
𝑦 − 𝑓 𝑥0 = 𝑓 ′ 𝑥0 𝑥 − 𝑥0
𝑓(𝑥0 )
• To find the x-intercept, set 𝑦 = 0: 𝐿
𝑋′ 𝑟 𝑋
′
0 − 𝑓 𝑥0 = 𝑓 𝑥0 𝑥1 − 𝑥0 𝑥1 𝑥0
′
• Solving for 𝑥1 (assuming 𝑓 (𝑥0 ) ≠ 0): 𝑌′
Figure 1
𝑓(𝑥0 )
𝑥1 = 𝑥0 − ′
𝑓 𝑥0
5
Iteration and General Formula
• Use 𝑥1 as the next approximation to the root.
• Repeat this process, replacing 𝑥0 with 𝑥1 , and so
forth: 𝑌 𝑦 = 𝑓(𝑥)
𝑓(𝑥1 ) 𝑥0 , 𝑓 𝑥0 Tangent Line
𝑥2 = 𝑥1 − ′
𝑓 𝑥1 𝑥1 , 𝑓 𝑥1
𝑓(𝑥0 )
• Continuing this iteration generates a sequence of 𝐿
𝑋′ 𝑟
approximations as shown in Figure 2: 𝑥2 𝑥1 𝑥0
𝑋
𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 , … 𝑥3
𝑌′
• In general, the iteration formula for the (𝑛 + 1)th Figure 2
approximation is:
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 − ′
𝑓 𝑥𝑛 6
Algorithm
Step 1: Calculate 𝑓 ′ 𝑥 symbolically.
Step 2: Choose two approximations a and b 𝑏 > 𝑎 such that
𝑓 𝑎 × 𝑓 𝑏 < 0.
Step 3: Apply the Newton-Raphson formula:
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 − ′
𝑓 𝑥𝑛
Step 4: Choose an initial guess 𝑥0 ∈ 𝑎, 𝑏 and find the first approximate
value. Similarly find the other approximate value.
Step 5: Repeat this process until 𝑥𝑛+1 − 𝑥𝑛 ≈ 0 or near to zero.
7
𝟑
Find a root of the equation 𝒙 − 𝟑𝒙 − 𝟓 = 𝟎 using Newton-
Raphson method correct to four decimal places.
Solution: Given that, 𝑥 3 − 3𝑥 − 5 = 0
Let 𝑓 𝑥 = 𝑥 3 − 3𝑥 − 5
Step 1: 𝑑
′
𝑓 𝑥 = 3
𝑥 − 3𝑥 − 5
𝑑𝑥
𝑑 3 𝑑 𝑑
= 𝑥 − 3𝑥 − 5
𝑑𝑥 𝑑𝑥 𝑑𝑥
= 3𝑥 2 −3
8
Step 2:
For 𝑎 = 2,
𝑓 2 = 23 − 3 × 2 − 5 = −3 < 0
For 𝑏 = 3,
𝑓 3 = 33 − 3 × 3 − 5 = 13 > 0
∴ 𝑓 𝑎 × 𝑓 𝑏 = 𝑓 2 × 𝑓 3 = −3 × 13 = −39 < 0
Since , 𝑓(𝑎) = 𝑓(2) is negative and 𝑓(𝑏) = 𝑓 (3) is positive, so at least
one real root lies between 2 and 3.
9
Step 3:
∵𝑓 𝑥 = 𝑥 3− 3𝑥 − 5
We know from Newton-Raphson method ,
3
𝑓(𝑥𝑛 ) ∴ 𝑓 𝑥𝑛 = 𝑥𝑛 − 3𝑥𝑛 − 5
𝑥𝑛+1 = 𝑥𝑛 −
𝑓′ 𝑥𝑛 ′ 2
∵𝑓 𝑥 =3𝑥 −3
3
𝑥𝑛 − 3𝑥𝑛 − 5 ′ 2
∴ 𝑓 𝑥𝑛 = 3 𝑥𝑛 − 3
𝑥𝑛+1 = 𝑥𝑛 −
3 𝑥𝑛 2 − 3
3 𝑥𝑛 3 3
− 3𝑥𝑛 − 𝑥𝑛 + 3𝑥𝑛 + 5
= 2
3 𝑥𝑛 − 3
2 𝑥𝑛 3+5
= 2−3
3 𝑥𝑛
10
Step 4: Now putting 𝑛 = 0 and let the initial value 𝑥0 = 2.
We are capable to find the successive improved approximations are as following table:
3
2 𝑥𝑛 +5
𝑛 𝑥𝑛 𝑥𝑛+1 = 2−3
𝑥𝑛+1 − 𝑥𝑛
3 𝑥𝑛
0 𝑥0 = 2 𝑥1 = 2.33333 0.33333
1 𝑥1 = 2.33333 𝑥2 = 2.28056 0.05278
2 𝑥2 = 2.28056 𝑥3 = 2.27902 0.00154
3 𝑥3 = 2.27902 𝒙𝟒 = 𝟐. 𝟐𝟕𝟗𝟎𝟐 𝟎. 𝟎𝟎𝟎𝟎𝟎
Step 5.
Here, 𝑥𝑛+1 − 𝑥𝑛 ≈ 0.00000 or near to zero, which is the accuracy condition for the solution exact.
So, the required root of the given equation correct up to the four decimal places is 2.2790.
12
Find a root of the equation 𝒙 sin 𝒙 + cos 𝒙 = 𝟎 using
Newton-Raphson method correct to five decimal places.
Solution: Given that, 𝑥 sin 𝑥 + cos 𝑥 = 0
Let 𝑓 𝑥 = 𝑥 sin 𝑥 + cos 𝑥
Step 1:
′
𝑑
𝑓 𝑥 = 𝑥 sin 𝑥 + cos 𝑥
𝑑𝑥
𝑑 𝑑
= 𝑥 sin 𝑥 + cos 𝑥
𝑑𝑥 𝑑𝑥
= 𝑥 cos 𝑥 + sin 𝑥 − sin 𝑥
= 𝑥 cos 𝑥 13
Step 2:
For 𝑎 = 2,
𝑓 2 = 2 sin 2 + cos 2 = 1.40245 > 0
For 𝑏 = 3,
𝑓 3 = 3 sin 3 + cos 3 = −0.56663 < 0
∴ 𝑓 𝑎 × 𝑓 𝑏 = 𝑓 2 × 𝑓 3 = 1.40245 × (−0.56663) = −0.79467 < 0
Since , 𝑓(𝑎) = 𝑓(2) is positive and 𝑓(𝑏) = 𝑓 (3) is negative, so at least one
real root lies between 2 and 3.
Hints: Calculator must be in radian mode.
14
Step 3:
We know from Newton-Raphson method , ∵ 𝑓 𝑥 = 𝑥 sin 𝑥 + cos 𝑥
∴ 𝑓 𝑥𝑛 = 𝑥𝑛 sin 𝑥𝑛 + cos 𝑥𝑛
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 −
𝑓′ 𝑥𝑛 ′
∵𝑓 𝑥 = 𝑥 cos 𝑥
𝑥𝑛 sin 𝑥𝑛 + cos 𝑥𝑛 ′
∴ 𝑓 𝑥𝑛 = 𝑥𝑛 cos 𝑥𝑛
𝑥𝑛+1 = 𝑥𝑛 −
𝑥𝑛 cos 𝑥𝑛
𝑥𝑛 2 cos 𝑥𝑛 − 𝑥𝑛 sin 𝑥𝑛 − cos 𝑥𝑛
=
𝑥𝑛 cos 𝑥𝑛
𝑥𝑛 2 − 1 cos 𝑥𝑛 − 𝑥𝑛 sin 𝑥𝑛
=
𝑥𝑛 cos 𝑥𝑛
15
Step 4: Now putting 𝑛 = 0 and let the initial value 𝑥0 = 3.
we are capable to find the successive improved approximations are as following table:
2
𝑥𝑛 − 1 cos 𝑥𝑛 − 𝑥𝑛 sin 𝑥𝑛
𝑛 𝑥𝑛 𝑥𝑛+1 = 𝑥𝑛+1 − 𝑥𝑛
𝑥𝑛 cos 𝑥𝑛
0 𝑥0 = 3 𝑥1 = 2.80921 0.19079
1 𝑥1 = 2.80921 𝑥2 = 2.79843 0.01078
2 𝑥2 = 2.79843 𝑥3 = 2.79839 0.00004
3 𝑥3 = 2.79839 𝒙𝟒 = 𝟐. 𝟕𝟗𝟖𝟑𝟗 𝟎. 𝟎𝟎𝟎𝟎𝟎
Step 5.
Here, 𝑥𝑛+1 − 𝑥𝑛 ≈ 0.00000 or near to zero, which is the accuracy condition for the solution exact.
So, the required root of the given equation correct up to the four decimal places is 2.79839.
17
𝟐
Find a real root of the equation 𝒙 − 𝟒 sin 𝒙 = 𝟎 using the
Newton-Raphson method with initial value 𝒙𝟎 = 𝟏. 𝟓 .
Solution: Given that, 𝑥 2 − 4 𝑠𝑖𝑛 𝑥 = 0
Let 𝑓 𝑥 = 𝑥 2 − 4 𝑠𝑖𝑛 𝑥
Step 1: 𝑑
′
𝑓 𝑥 = 2
𝑥 − 4 sin 𝑥
𝑑𝑥
𝑑 2 𝑑
= 𝑥 − 4 sin 𝑥
𝑑𝑥 𝑑𝑥
= 2𝑥 − 4 cos 𝑥
18
Step 2:
For 𝑎 = 1,
𝑓 1 = 1 2 − 4 sin 1 = −2.36588 < 0
For 𝑏 = 1,
2
𝑓 2 = (2) −4 sin 2 = 0.36281 > 0
∴ 𝑓 𝑎 × 𝑓 𝑏 = 𝑓 1 × 𝑓 2 = −2.3659 × 0.3628 = −0.85836 < 0
Since , 𝑓(𝑎) = 𝑓(1) is negative and 𝑓(𝑏) = 𝑓 (2) is positive, so at least
one real root lies between 1 and 2.
Hints: Calculator must be in radian mode.
19
Step 3:
∵𝑓 𝑥 = 𝑥 2
− 4 𝑠𝑖𝑛 𝑥
We know from Newton-Raphson method ,
2
𝑓(𝑥𝑛 ) ∴ 𝑓 𝑥𝑛 = 𝑥𝑛 − 4 𝑠𝑖𝑛 𝑥𝑛
𝑥𝑛+1 = 𝑥𝑛 −
𝑓′ 𝑥𝑛 ′
∵ 𝑓 𝑥 = 2𝑥 − 4 cos 𝑥
2
𝑥𝑛 − 4 𝑠𝑖𝑛 𝑥𝑛 ′
∴ 𝑓 𝑥𝑛 = 2𝑥𝑛 − 4 cos 𝑥𝑛
𝑥𝑛+1 = 𝑥𝑛 −
2𝑥𝑛 − 4 cos 𝑥𝑛
2 𝑥𝑛 2 − 4𝑥𝑛 cos 𝑥𝑛 − 𝑥𝑛 2 + 4 𝑠𝑖𝑛 𝑥𝑛
=
2𝑥𝑛 − 4 cos 𝑥𝑛
𝑥𝑛 2 − 4𝑥𝑛 cos 𝑥𝑛 + 4 𝑠𝑖𝑛 𝑥𝑛
=
2𝑥𝑛 − 4 cos 𝑥𝑛
20
Step 4: Now putting 𝑛 = 0 and let the initial value 𝑥0 = 1.5.
we are capable to find the successive improved approximations are as following table:
2
𝑥𝑛 − 4𝑥𝑛 cos 𝑥𝑛 + 4 𝑠𝑖𝑛 𝑥𝑛
n 𝑥𝑛 𝑥𝑛+1 = 𝑥𝑛+1 − 𝑥𝑛
2𝑥𝑛 − 4 cos 𝑥𝑛
0 𝑥0 = 1.5 𝑥1 = 2.14039 0.64039
1 𝑥1 = 2.14039 𝑥2 = 1.95201 0.18838
2 𝑥2 = 1.95201 𝑥3 = 1.93393 0.01808
3 𝑥3 = 1.93393 𝑥4 = 1.93375 0.00018
4 𝑥4 = 1.93375 𝒙𝟓 = 𝟏. 𝟗𝟑𝟑𝟕𝟓 𝟎. 𝟎𝟎𝟎𝟎𝟎
Step 5.
Here, 𝑥𝑛+1 − 𝑥𝑛 ≈ 0.00000 or near to zero, which is the accuracy condition for the solution exact.
So, the required root of the given equation correct up to the four decimal places is 1.93375. 22
Algorithm of Newton-Raphson Method
23
Homework
Find the root of the following equations using Newton-Raphson Method
by taking your own guess.
𝑥
1. 2 − 5𝑥 + 2 = 0
2𝑥 𝑥
2. 𝑒 − 𝑒 − 2 = 0
3. 2𝑥 + cos 𝑥 − 3 = 0
4. cos 𝑥 − ln 𝑥 = 0
2
5. 𝑥 − 4𝑥 − 10 = 0
6. 2𝑥 = 1 + sin 𝑥
3 2
7. 𝑥 − 2𝑥 − 4 = 0
24
Homework
25