2-Roots of Nonlinear Single Equations
2-Roots of Nonlinear Single Equations
Chemical Engineering
DCHET, COET, MSU-IIT
Numerical Solution of
Nonlinear Equations
in One Variable
AN ALGEBRAIC EQUATION CAN INCLUDE
Polynomial: 𝑥 2 , 𝑥 3 , 𝑥 4 , . . . 𝑥 𝑛
log 𝑥 or ln 𝑥
Exponential (𝑒 𝑥 )
Trigonometric functions:
▪ sin 𝑥, cos 𝑥, . . .
▪ sinh 𝑥, cosh 𝑥, . . .
THE VERY FAMOUS ALGEBRAIC EQUATION
Second order polynomial algebraic equation
𝑎𝑥 2 + 𝑏𝑥 + 𝑐 = 0
example
2𝑥 2 + 7𝑥 + 6 = 0
2𝑥 + 3 𝑥 + 2 = 0
𝑥 = −1.5, 𝑥 = −2
−𝑏 ± 𝑏2 − 4𝑎𝑐
𝑥=
2𝑎
MORE DIFFICULT EQUATIONS
5𝑥 4 + 6𝑥 3 − 𝑥 2 + 𝑥 − 10 = 0
or
2𝑥 4 − 7𝑥 2 + 6𝑒 2𝑥 = 0
or
2𝑥 3 + 2 sin 2𝑥 − cos 3𝑥 = 0
INTRODUCTION
𝑓 𝑥 =0 (1)
No
Assumed
Assume Substitute in Satisfies Yes
value is
“𝑥” the equation equation?
correct
ITERATIVE METHODS
▪ Fixed-point iteration or M.O.S.S. (Method of
Successive Substitution)
▪ Newton’s Method
▪ Secant Method
▪ Inclusion Methods
▪ Bisection Method
▪ Regula-Falsi
ITERATIVE METHODS
▪ No numerical procedure works for all equations
▪ The root depends on the guess
▪ Measurement of accuracy of estimate depends
on:
▪ Absolute Error:
▪ Relative Error:
▪ Error Ratio:
▪ Mitigation of non-convergence
ITERATIVE METHODS
(Method of Successive Substitution)
▪ Condition: 𝑥 = 𝑔 𝑥
𝑑𝑔 𝑥
▪ Test for Convergence: <1
𝑑𝑥
Solution:
Test for vicinity of possible root:
𝑎 = 0, 𝑏 = 1
𝑓 𝑎 = 0 3 − 3 0 + 1 = 1,
3
𝑓 𝑏 = 1 − 3 1 + 1 = −1
𝑓 0 𝑓 1 = 1 −1 = −1, 𝑓 𝑎 𝑓 𝑏 < 0
Then we choose an 𝑥0
𝑥0 = 0
𝑑𝑔 𝑥
Test for Convergence: <1
𝑑𝑥
𝑑𝑔 𝑥
= 𝑥2 0 =0<1
𝑑𝑥 0
FIXED-POINT ITERATION
(Graphical interpretation)
𝑥1
FIXED-POINT ITERATION
Compute 𝑥1 = 𝑔 𝑥0 , 𝑥2 = 𝑔 𝑥1 , . . ., until
x=g(x) = (x^3 + 1) / 3
n x (n) x (n+1) = g (x(n)) Relative Error
0 0.0000
5
FIXED-POINT ITERATION
FIXED-POINT ITERATION
Solution:
x=g(x) = (x^3 + 1) / 3
y = x^3 - 3x+ 1
3.000
2.500
2.000
1.500
1.000
0.500
0.000
-2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5
-0.500
-1.000
-1.500
NEWTON’S METHOD
If a differentiable function 𝑦 = 𝑓 𝑥 has a simple root 𝑠 in 𝑎, 𝑏
and 𝑓 ′ 𝑠 ≠ 0, then the iteration rule is given as
𝑓 𝑥𝑛
𝑥𝑛+1 = 𝑥𝑛 − ′
𝑓 𝑥𝑛
for 𝑛 = 1, 2, 3, . . .
Steps:
▪ Pick an 𝑥 close to the root of a continuous function 𝑓 𝑥
▪ Take the derivative of 𝑓 𝑥 to get 𝑓 ′ 𝑥
𝑓 𝑥𝑛
▪ Plug into 𝑥𝑛+1 = 𝑥𝑛 − ′ , 𝑓′ 𝑥 ≠ 0
𝑓 𝑥𝑛
Solution:
Pick an 𝑥 close to the root of a continuous function 𝑓 𝑥
𝑥 = −0.5
𝑓 ′ 𝑥 = 3𝑥 2 − 3
NEWTON’S METHOD
𝑥 3 −3𝑥+1
Plug into 𝑥𝑛+1 = 𝑥𝑛 −
3𝑥 2 −3
f(x)=x^3-3x+1
n x (n) f(x) f '(x) x (n+1) Tolerance
1
2
3
5
6
7
8
9
10
11
NEWTON’S METHOD
Repeat until converges where 𝑥𝑛+1 ≈ 𝑥𝑛
f(x)=x^3-3x+1
n x (n) f(x) f (x) x (n+1) Tolerance
0 -0.50000 2.37500 -2.25000 0.55556 1.9000000000
1 0.55556 -0.49520 -2.07407 0.31680 -0.7536534447
2 0.31680 0.08140 -2.69892 0.34696 0.0869250821
3 0.34696 0.00089 -2.63886 0.34730 0.0009731972
4 0.34730 0.00000 -2.63816 0.34730 0.0000001298
5 0.34730 0.00000 -2.63816 0.34730 0.0000000000
6 0.34730 0.00000 -2.63816 0.34730 0.0000000000
7 0.34730 0.00000 -2.63816 0.34730 0.0000000000
8 0.34730 0.00000 -2.63816 0.34730 0.0000000000
9 0.34730 0.00000 -2.63816 0.34730 0.0000000000
10 0.34730 0.00000 -2.63816 0.34730 0.0000000000
11 0.34730 0.00000 -2.63816 0.34730 0.0000000000
12 0.34730 0.00000 -2.63816 0.34730 0.0000000000
13 0.34730 0.00000 -2.63816 0.34730 0.0000000000
14 0.34730 0.00000 -2.63816 0.34730 0.0000000000
DRAWBACK OF NEWTON’S METHOD
▪ Requires 𝑓 ′ 𝑥𝑛
▪ If 𝑓 𝑥 = sin cos 𝑒 𝑥
▪ 𝑓 ′ 𝑥 = −𝑒 𝑥 sin 𝑒 𝑥 cos cos 𝑒 𝑥
3.500
y = x^3 - 3x+ 1
3.000
2.500
2.000
1.500
1.000
0.500
0.000
-2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5
-0.500
-1.000
-1.500
SECANT METHOD
3.500
y = x^3 - 3x+ 1
3.000
2.500
2.000
1.500
1.000
0.500
0.000
-2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5
-0.500
-1.000
-1.500
SECANT METHOD
ALGORITHM:
1. Assume 𝑥0 and 𝑥1
3. Solve for 𝑥2
𝑥1 − 𝑥0
𝑥2 = 𝑥1 − 𝑓 𝑥1
𝑓 𝑥1 − 𝑓 𝑥0
4. Set 𝑥0 = 𝑥1 and 𝑥1 = 𝑥2
𝑥𝑛 − 𝑥𝑛−1
𝑥𝑛+1 = 𝑥𝑛 − 𝑓 𝑥𝑛
𝑓 𝑥𝑛 − 𝑓 𝑥𝑛−1
6. Continue until 𝑓 𝑥2 ≤𝜀
SECANT METHOD
Example 3
Solve for the root of
𝑓 𝑥 = 𝑥 3 + 𝑥 2 − 3𝑥 − 3 𝜀 = 0.00001
Solution:
Assume values for 𝑥𝑛−1 and 𝑥𝑛 :
𝑥𝑛−1 = 1
𝑥𝑛 = 2
Condition: 𝑖𝑠 𝑓 1 <𝑓 2 ?
𝑓 1 = 1 3 + 1 2 − 3 1 − 3 = −4
𝑓 2 = 2 3+ 2 2−3 2 −3=3
Swap.
SECANT METHOD
f(x)=x^3+x^2-3x-3
n x (n-1) x (n) f(x(n-1)) f(x(n)) x (n+1) Tolerance
1 2.00000 1.00000
6
SECANT METHOD
f(x)=x^3+x^2-3x-3
n x (n-1) x (n) f(x(n-1)) f(x(n)) x (n+1) Tolerance
3. Solve for 𝑓 𝑐
If 𝑓 𝑐 = 0, then c is a root
If 𝑓 𝑐 ≠ 0
AND 𝑓 𝑐 < 0, the root is between 𝑐, 𝑏
AND 𝑓 𝑐 > 0, the root is between 𝑎, 𝑐
𝑓 𝑥 = 𝑥 3 + 𝑥 2 − 3𝑥 − 3 𝜀 = 0.0001
f(x)=x^3+x^2-3x-3
n a b f(a) f(b) c f(c)
7
REGULA-FALSI METHOD
An iterative method that works well with functions that are not
differentiable. It requires two initial values 𝑥0 , 𝑥1 , and iteration rule
is as follows:
𝑥𝑛 − 𝑥𝑛−1
𝑥𝑛+1 = 𝑥𝑛 − 𝑓 𝑥𝑛
𝑓 𝑥𝑛 − 𝑓 𝑥𝑛−1
for 𝑛 = 1, 2, 3, . . .
REGULA-FALSI METHOD
Example 5
Solve for the root of
𝑓 𝑥 = 𝑥 3 + 𝑥 2 − 3𝑥 − 3 𝜀 = 0.0001
f(x)=x^3+x^2-3x-3
n x(n-1) x(n) f(x(n-1)) f(x(n)) x(n+1) tolerance
7
EXERCISES
𝑥
▪ Find a root of 𝑥 cos =0
𝑥−2
𝑒 −2𝑥 −1
▪ Find a root of 𝑥2 =
𝑥
2 −1
▪ Find a root of 𝑒 𝑥 + 10 sin 2𝑥 − 5 = 0
EXERCISES
▪ Find a root of 𝑒 𝑥 − 3𝑥 2 = 0