Root Findings
Root Findings
Root Findings
Root finding
Dr. Gokul K. C.
Department of Mathematics,
School of Science,
Kathmandu University, Nepal
Email: gokul.kc@ku.edu.np
1 / 47
Objective
To find the roots of equation
f (x) = 0 (1)
2 / 47
Rate of Convergence
If a sequence x1 , x2 , x3 , · · · , xn converges to a value α and if there exist real
numbers C > 0 and p > 0 such that
|xn+1 − α|
lim =C (2)
n→∞ |xn − α|p
|n+1 |
lim =C (3)
n→∞ |n |p
Computatioal Steps
1 Input: Function(f (x)), tolerance() and initial approximations (a) and
(b), such that f (a) × f (b) < 0.
2 Compute x = (a + b)/2.
3 If f (x) × f (a) < 0, the root lies on [x, a], set b = x and go to step 2.
4 If f (x) × f (b) < 0, the root lies on [x, b], set a = x and go to step 2.
5 Repeat steps 2-4 until |b − a| < or |f (x)| <
6 / 47
Example
Solve using bisection method the equation x 3 − x − 1 = 0, correct to 4
decimal places.
Given: f (x) = x 3 − x − 1,
Tolerance=4 decimal places
= 1/2 × 10−4 = 0.00005
Let a = 1 such that f (a) = f (1) = −1 < 0
and b = 2 such that f (b) = f (2) = 5 > 0.
Total steps required: (n) ≥ ln(|2 − 1|/0.00005)/ln(2) = 14.28
ThereforeTotal steps required: (n) ≈ 15
Our first approximation is
x = (b + a)/2 = (2 + 1)/2 = 1.5.
Further calculations are tabulated below:
7 / 47
f (a) < 0(−) f (b) > 0(+)
n a b x f(x) Remarks
1 1 2 1.5 0.87 f (x) > 0, replace b by x
2 1 1.5 1.25 -0.29 f (x) < 0, replace a by x
3 1.25 1.5 1.375 0.22 f (x) > 0, replace b by x
4 1.25 1.375 1.3125 -0.05 f (x) < 0, replace a by x
5 1.3125 1.3750 1.3438 0.08 f (x) > 0, replace b by x
6 1.3125 1.3438 1.3281 0.01 f (x) > 0, replace b by x
7 1.3125 1.3281 1.3203 -0.01 f (x) < 0, replace a by x
8 1.3203 1.3281 1.3242 -0.00 f (x) < 0, replace a by x
9 1.3242 1.3281 1.3262 0.00 f (x) > 0, replace b by x
10 1.3242 1.3262 1.3252 0.00 f (x) > 0, replace b by x
11 1.3242 1.3252 1.3247 -0.00 f (x) < 0, replace a by x
12 1.3247 1.3252 1.3250 0.00 f (x) > 0, replace b by x
13 1.3247 1.3250 1.3248 0.00 f (x) > 0, replace b by x
14 1.3247 1.3248 1.3248 0.00 f (x) > 0, replace b by x
Exercise: Find a root, correct to three decimal places of the function
xe x − 1 = 0 Ans : 0.5671
8 / 47
False position method
Let a and b be chosen such that f (a) × f (b) < 0. i.e. either
f (a) > 0, f (b) < 0 or f (a) < 0, f (b) > 0. The root lies on [a, b].
Now, the equation of chord joining (a, f (a)) and (b, f (b)) is given by
y − f (a) = f (b)−f
b−a
(a)
(x − a)
If this chord intersects X-axis at (x1 , 0), we have
0 − f (a) = f (b)−f
b−a
(a)
(x1 − a)
Simplifying, We get first approximation,
f (a) af (b)−bf (a)
x1 = a − f (b)−f (a) (b − a) = f (b)−f (a)
If f (x1 ) = 0, x1 is the desired root. If not then f (x1 ) < 0 or f (x1 ) > 0.
If f (x1 ) × f (a) < 0, then the root lies on [x1 , a] otherwise on [x1 , b].
Let the root lies on [x1 , b], the next approximation(x2 ) is
x2 = x1ff(b)−f
(b)−bf (x1 )
(x1 )
and so on.
9 / 47
10 / 47
False position method
Computatioal Steps
1 Input: Function(f (x)), tolerance() and initial approximations (a) and
(b), such that f (a) × f (b) < 0.
af (b)−bf (a)
2 Compute x = f (b)−f (a)
3 If f (x) × f (a) < 0, the root lies on [x, a], set b = x and go to step 2.
4 If f (x) × f (b) < 0, the root lies on [x, b], set a = x and go to step 2.
5 Repeat steps 2-4 until |xn − xn−1 | < or |f (x)| <
11 / 47
Example
Solve using false position method the equation x 3 − x − 1 = 0, correct to 4
decimal places.
13 / 47
14 / 47
Secant method
Computatioal Steps
1 Input: Function(f (x)), tolerance() and initial approximations (a) and
(b).
af (b)−bf (a)
2 Compute x = f (b)−f (a)
3 Set a = b and b = x.
4 Repeat steps 2-3 until |xn − xn−1 | < or |f (x)| <
15 / 47
Example
Solve using secant method the equation x 3 − x − 1 = 0, correct to 4
decimal places.
16 / 47
Rate of convergence (Secant method)
If xk+1 , xk , xk−1 are three consecutive approximations for the root α of
equation f (x) = 0, then the formula for secant method is
(k − k−1 )f (α + k )
k+1 = k −
f (α + k ) − f (α + k−1 )
1
Again expanding 1+x = 1 − x + x 2 − x 3 + · · · assuming
00
x = 12 (k + k−1 ) ff 0 (α)
(α)
+ · · · , we get
1 2 f 00 (α) f 00 (α)
1
k+1 = k − k + k 0 + ··· 1 − (k + k−1 ) 0 + ··· + ···
2 f (α) 2 f (α)
1 f 00 (α)
k+1 = k k−1 + · · · ⇒ k+1 = Ak k−1
2 f 0 (α)
1/p
Since k+1 = C pk ⇒ k = C pk−1 so that k−1 = C −1/p k , we get
1+1/p
pk = AC −(1+1/p) k
The formula for both Secant method and False position method are same.
The difference is on algorithm while updating the values. In secant
method both ends [a, b] varies, but in false position method one end of [a,
b] is always fixed. Let us suppose ’a’ is fixed, so that the error due to this
end is constant (k−1 = C1 ).
Now, the error equation according to secant method
becomes
k+1 = A k C1 ⇒ k+1 = C2 k C2 = AC1
Substituting k+1 = C pk and equating the powers of k ,
C pk = C2 k
19 / 47
Newton-Raphson method
Let x0 be an approximate root of f (x) = 0 and let x1 = x0 + h be the exact
root such that f (x1 ) = f (x0 + h) = 0.
Expanding f (x0 + h) = 0 by Taylor’s series, we obtain
h2 00
f (x0 + h) = f (x0 ) + hf 0 (x0 ) +
f (x0 ) + · · · = 0 (5)
2!
Neglecting the second and higher order derivatives, we have
f (x0 )
f (x0 ) + hf 0 (x0 ) = 0, h = − (6)
f 0 (x0 )
Substituting the value of h in x1 , we get first approximation
f (x0 )
x1 = x0 − (7)
f 0 (x0 )
After nth approximation, we have
f (xn )
xn+1 = xn − (8)
f 0 (xn )
Which is the Newton-Raphson formula
20 / 47
Method of tangent
21 / 47
Newton-Raphson method
Computatioal Steps
1 Input: Function(f (x)), Derivative of function(f 0 (x)), tolerance() and
initial approximation(a)
f (a)
2 Compute x = a − f 0 (a)
3 Set a = x.
4 Repeat steps 2-3 until |xn − xn−1 | < or |f (x)| <
22 / 47
Example
Solve using Newton-Raphson method the equation x 3 − x − 1 = 0, correct
to 4 decimal places.
n a x
1 1 1.5
2 1.5 1.3478
3 1.3478 1.3252
4 1.3252 1.3247
1 f 00 (α) f 00 (α)
k+1 = k − k + 2k 0 + · · · 1 + k 0 + ···
2 f (α) f (α)
1 f 00 (α) 2
k+1 = + · · · ⇒ k+1 = A2k
2 f 0 (α) k
⇒ C pk = A2k
Equating the powers of k , we get p = 2. Hence Newton’s method
converges quadratically. 24 / 47
Iteration method
Given equation,
f (x) = 0 (10)
Rewriting equation (10) in the form
x = g (x) (11)
x1 = g (x0 ) (12)
25 / 47
Fixed point iteration method
26 / 47
Fixed point iteration method
Computatioal Steps
1 Input: Function(f (x)), Function(g (x)), tolerance() and initial
approximation(a)
2 Compute x = g (a)
3 Set a = x.
4 Repeat steps 2-3 until |xn − xn−1 | < or |f (x)| <
27 / 47
Example
Solve using Iteration method the equation x 3 − x − 1 = 0, correct to 4
decimal places.
α = g (α) (15)
Taking modulus
|n+1 | = |xn − α||g 0 (η)| = |n ||g 0 (η)|
|n+1 | = k|n | ∵ |g 0 (η)| = k < 1
|C pn | = k|n |
Equating the powers of k , we get p = 1. Hence iteration method
converges linearly.
29 / 47
Solution to systems of non-linear equations
Iteration Method
Consider the system of two non-linear equations:
f (x, y ) = 0
g (x, y ) = 0
Convergent Criteria
Rewriting the equation in the form:
∂F ∂F
x = F (x, y ) y = G (x, y ) + < 1
∂x ∂y
OR
∂G ∂G
x = G (x, y ) y = F (x, y ) + < 1
∂x ∂y
If (x0 , y0 ) be an initial approximation to the root (α, β), then we get,
x1 = F (x0 , y0 ) y1 = G (x0 , y0 )
x2 = F (x1 , y1 ) y2 = G (x1 , y1 )
.. ..
. .
xn+1 = F (xn , yn ) yn+1 = G (xn , yn )
30 / 47
Exampale
Exmaple: Find a real root of the equations y 2 − 5y + 4 = 0 and
3yx 2 − 10x + 7 = 0 correct to 4 decimal places using initial approximation
(0, 0)
n x y n x y
1 0.70000 0.80000 8 0.99001 0.99972
2 0.81760 0.92800 9 0.99395 0.99989
3 0.88610 0.97224 10 0.99635 0.99996
4 0.92901 0.98905 11 0.99780 0.99998
5 0.95608 0.99564 12 0.99868 0.99999
6 0.97303 0.99826 13 0.99920 1.00000
7 0.98354 0.99931 14 0.99952 1.00000
f (x, y ) = 0
g (x, y ) = 0
Now,
D1 D2
,
h= k=
D D
The new approximations are, therefore,
x1 = x0 + h, y1 = y0 + k
xn+1 = xn + h, yn+1 = yn + k
33 / 47
Exampale
Exmaple: Find a real root of the equations 3yx 2 − 10x + 7 = 0 and
y 2 − 5y + 4 = 0 correct to 4 decimal places using initial approximation (0, 0)
34 / 47
System of linear equations
Consider a system of linear equations:
AX = B (17)
a11 a12 a13 x1 b1
Where, A = a21 a22 a23 , X = x2 , B = b2
a31 a32 a33 x3 b3
In this chapter, we will study the following 3 methods to solve linear
system.
LU decomposition method
Tri-diagonal system
Iterative methods
35 / 47
LU decomposition method
a11 a12 a13
Let A = a21 a22 a23 be a nonsingular square matrix. Then A can be
a31 a32 a33
factorized in the form LU such that A = LU, where L is lower triangular
matrix
and U is upper
triangular
matrix represented
by:
1 0 0 u11 u12 u13
L = l21 1 0 and U = 0 u22 u23 .
l31 l32 1 0 0 u33
Substituting A = LU in (17), we get
LUX = B (18)
If we set
UX = Y (19)
then,
LY = B (20)
Solving (20) by forward substitution, we obtain vector Y . Substituting this
Y in (19) and solving by backward substitution, we get the required
solution vector X .
36 / 47
Solve the system by LU
decomposition 2 3 1
∴ U = 0 1/2 5/2 .
2x + 3y + z = 9
0 0 18
x + 2y + 3z = 6
3x + y + 2z = 8 Now for L, we collect all pivot
columns from pivot element in
2 3 1 downward direction.
Given A = 1 2 3 .
2 0 0
3 1 2 1 1/2 0
Since 2 is a pivot element, using
3 −7/2 18
Gaussian elimination, perform
R2 = R2 − 1/2R1 , R3 = R3 − 3/2R1 Dividing every column by corre-
sponding pivot element, we get
2 3 1
0 1/2 5/2 1 0 0
0 −7/2 1/2 ∴ L = 1/2 1 0
Again, 1/2 is second pivot element, 3/2 −7 1
perform R3 = R3 + 7R2
Never transform pivot ele-
2 3 1 ment to identity 1
0 1/2 5/2 = U
0 0 18
37 / 47
9
Given, B = 6 . Now, UX = Y is:
8
2 3 1
x
9
A = −3 5
9 1 ,B = 5
∴ Y = 3/2 6 −4 0 2
5
38 / 47
Tridiagonal system
Consider the system of equations defined by:
b1 x1 + c1 x2 = d1 Thomas algorithm
a2 x1 + b2 x2 + c2 x3 = d2 Set α1 = b1 and
a3 x2 + b3 x3 + c3 x4 = d3 compute
.. αi = bi − aαi ci−1
i−1
,
. i = 2, 3, · · · , n.
an−1 xn−2 + bn−1 xn−1 + cn−1 xn = dn−1 Set β1 = d1 /b1 and
an xn−1 + bn xn = dn compute
βi = di −aαi iβi−1 ,
The matrix of coefficient is i = 2, 3, · · · , n.
b1 c1 0 0 ··· ··· ··· 0 Set xn = βn and
a2 b2 c2 0 ··· ··· ··· 0
compute
0 a3 b3 c3 ··· ··· ··· 0
xi = βi − ci αxi+1
,
··· ··· ··· ··· ··· ··· ··· ··· i
0 0 0 ··· 0 an−1 bn−1 cn−1
i = n − 1, n − 2, · · · , 1.
0 0 0 ··· 0 0 an bn
39 / 47
2. Setting β1 = d1 /b1
Solve using Thomas algorithm:
=⇒ β1 = 0/2 = 0 and compute
2x − y = 0 d2 −a2 β1 0−(−1)(0)
−x + 2y − z = 0 β2 = α2 = 3/2 =0
d3 −a3 β2 0−(−1)(0)
−y + 2z − u = 0 β3 = α3 = 4/3 =0
−z + 2u = 1 d4 −a4 β3 1−(−1)(0)
β4 = α4 = 5/4 = 4/5
The augmented matrix is:
2 −1 0 0 : 0
3. Setting x4 = β4
−1 2 −1 0 : 0 =⇒ x4 = 4/5 and compute
0 −1 2 −1 : 0 x3 = β 3 − c3 x4
=0− (−1)(4/5)
= 3/5
α3 4/3
0 0 −1 2 : 1 c2 x3 (−1)(3/5)
x2 = β 2 − α2 =0− 3/2 = 2/5
Given i = 4, c1 x2 (−1)(2/5)
x1 = β 1 − α1 =0− 2 = 1/5
1. Setting α1 = b1
=⇒ α1 = 2 and compute
Exercise: Solve the system using
a2 c1 (−1)(−1)
α2 = b2 − α1 =2− 2 = 3/2 Thomas algorithm
a3 c2 (−1)(−1)
α3 = b3 − α2 =2− 3/2 = 4/3 3x1 − x2 = −1
α4 = b4 − a4 c3
=2− (−1)(−1)
= 5/4 −x1 + 3x2 − x3 = 7
α3 4/3
−x2 + 3x3 = 7
40 / 47
Vector Norms
A norm is a way to measure the size of a vector. In other words, norms are
a class of functions that enable us to quantify the magnitude of a vector.
Generally, the norm of a vector is a measure of its length from origin.
A function k.k : Rn → R is called a vector norm if it has the following
properties:
kxk ≥ 0 for any vector x ∈ Rn and kxk = 0 if and only if x = 0
kαxk = |α|kxk for any vector x ∈ Rn and any scalar α ∈ R
kx + y k ≤ kxk + ky k for any vectors x, y ∈ Rn
The most commonly used vector norms belong to the family of p − norms
1/p
or lp − norms defined by kxkp = (Σni=1 |xi |p ) The following p − norms are of
particular interest:
p = 1 : The l1 or Taxicab norm kxk1 = |x1 | + |x2 | + · · · + |xn |
p
p = 2 : The l2 or Euclidean norm kxk2 = x12 + x22 + · · · + xn2
p = ∞ : The l∞ or Maximum norm kxk∞ = max |xi |
i
41 / 47
Matrix Norms
The norm of a matrix is a measure of how large its elements are. It is a
way of determining the size” of a matrix that is not necessarily related to
how many rows or columns the matrix has.
The norm of a square matrix A is a non-negative real number denoted kAk
satisfying the following properties:
kAk ≥ 0 and kAk = 0 if and only if A = 0
kαAk = |α|kAk (any scalar α)
kA + Bk ≤ kAk + kBk
kABk ≤ kAkkBk
The most commonly used matrix norms are:
The l1 − norm or the column norm kAk1 = max Σi |aij |
j
1/2
The Euclidean norm kAke = Σi,j |aij |2
The l∞ − norm or the row norm kAk∞ = max Σj |aij |
i
The l2 − norm or spectral norm
kAk2 = (Maximum eigenvalue of AT A)1/2
42 / 47
Examples
43 / 47
Iteration methods
Consider a system:
a11 x1 + a12 x2 + a13 x3 + · · · + a1n xn = b1
a21 x1 + a22 x2 + a23 x3 + · · · + a2n = b2
a31 x1 + a32 x2 + a33 x3 + · · · + a3n = b3 · · · (∗)
..
.
an1 x1 + an2 x2 + an3 x3 + · · · + ann = bn
If the coefficient matrix of (∗) is diagonally dominant, i.e.
a11 > a12 + a13 + · · · + a1n , a22 > a21 + a23 + · · · + a2n ,
a33 > a31 + a32 + · · · + a3n , · · · , ann > an1 + an2 + · · · + an,n−1 then we can
solve using iterative methods. Rewriting (∗) in the form:
b1 a12 a13 a1n
x1 = a11 − a11 x2 − a11 x3 − ··· − a11 xn
b2 a21 a23 a2n
x2 = a22 − a22 x1 − a22 x3 − ··· − a22 xn
45 / 47
Jacobi method
Solve using iteration methods:
2x − y = 1
−x + 3y − z = 8
−y + 2z = −5
Rewriting,
1+y 8+x+z y −5
x= 2
, y= 3
, z= 2
Using initial approximation (0, 0, 0), the
results are tabulated below:
Gauss-Seidel method
46 / 47
Exercise
Solve using iterative methods:
10x − 2y − z − u = 3
−2x + 10y − z − u = 15
−x − y + 10z − 2u = 27
−x − y − 2z + 10u = −9
47 / 47