Zeros
Zeros
nonlinear
equations
Walter
Mudzimbabwe
Chapter 3
Walter Mudzimbabwe
Zeros
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
Chapter 3
We sometimes have to find points where a non-linear function
is 0, i.e.
f (x) = 0.
Such points are called zeros or roots of f (x) = 0.
All numerical methods for finding roots are usually iterative.
Examples
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
Chapter 3
Methods
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
Chapter 3
Zeros of
nonlinear
equations
Walter Suppose f (a)f (b) < 0 on [a, b] then we know that a root of
Mudzimbabwe
the equation lies in the interval [a, b].
Chapter 3 The mid point of [a, b] is
(a + b)
c=
2
If f (a)f (c) < 0 then f (a) and f (c) have opposite signs
and so the root must lie in [a, c].
If f (a)f (c) > 0 then f (a) and f (c) have same signs and,
so the root must lie in the interval [c, b].
Pictorial representation
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
Chapter 3
Bisection steps
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
Chapter 3
1. c = 21 (a + b).
2. If f (a)f (c) < 0 then [a, b] = [a, c].
3. If f (a)f (c) > 0 then [a, b] = [c, b].
4. Stop if root has been found otherwise go to 1.
Bisection method example
Zeros of
nonlinear Problem: Perform two iterations of the bisection method on
equations
the function f (x) = x 3 − x 2 − 4x − 6 using [1, 4].
Walter
Mudzimbabwe Solution:
Chapter 3
f (1) = −10 and f (4) = 26 also f (1) and f (4) have opposite
signs so there is a root/zero in [1, 4].
Iteration 1:
[a, b] = [1, 4], c = 12 (a + b) = 2.5
f (a)f (c) = f (1)f (2.5) > 0 so [a, b] = [c, b] = [2.5, 4].
Iteration 2:
[a, b] = [2.5, 4], c = 12 (a + b) = 3.25
f (a)f (c) = f (2.5)f (3.25) < 0 so [a, b] = [a, c] = [2.5, 3.25].
..
.
Iteration 11:
.....c = 3.0002
so [a, b] = [2.9995, 3.0010].
False position method or Regula Falsi
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
Chapter 3
The bisection method is simple however it is slow. False
position method gives a better way of finding c. The equation
of the line through (a, f (a)) and (b, f (b)) is
x −a
y = f (a) + (f (b) − f (a)).
b−a
False position method or Regula Falsi
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
We require the point c where y = 0, i.e.
Chapter 3
c −a
0 = f (a) + (f (b) − f (a)),
b−a
from which we solve for c to get:
af (b) − bf (a)
c= .
f (b) − f (a)
Pictorial representation
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
Chapter 3
False position steps
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
af (b)−bf (a)
Chapter 3 1. c = f (b)−f (a) .
2. If f (a)f (c) < 0 then [a, b] = [a, c].
3. If f (a)f (c) > 0 then [a, b] = [c, b].
4. Stop if root has been found otherwise go to 1.
We can use a stopping criteria such as |cn − cn−1 | < ϵ, where
cn is c at iteration n.
False position example
Zeros of
nonlinear Problem: Perform two iterations of the False position method
equations
on the function f (x) = x 3 − x 2 − 4x − 6, using [1, 4].
Walter
Mudzimbabwe Solution:
f (1) = −10 and f (4) = 26 also f (1) and f (4) have opposite
Chapter 3
signs so there is a root/zero in [1, 4].
Iteration 1:
[a, b] = [1, 4], c = aff (b)−bf (a)
(b)−f (a) = 1.8333, f (1.8333) = −10.53
f (a)f (c) = f (1)f (1.8333) > 0 so [a, b] = [c, b] = [1.8333, 4].
Iteration 2:
[a, b] = [1.8333, 4], c = aff (b)−bf (a)
(b)−f (a) = 2.4580,
f (2.4580) = −7.02, f (a)f (c) = f (1.8333)f (2.4580) > 0 so
[a, b] = [c, b] = [2.4580, 4].
..
.
Iteration 8:
..... c = 2.9996, .... [a, b] = [2.9988, 4].
Fixed point methods
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
xn+1 = g (xn ).
Zeros of
nonlinear
Problem: Find x such that g (x) = 0.
equations
Walter
Mudzimbabwe
Chapter 3
y − g (xn )
The derivative of g (x) at xn is g ′ (xn ) = .
x − xn
Let x = xn+1 when y = 0, i.e., x-intercept.
Newton formula
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
Therefore:
Chapter 3
g (xn )
xn+1 = xn − .
g ′ (xn )
Zeros of
nonlinear
equations
Walter
Mudzimbabwe Example: Solve e −x = ln(x) with x0 = 1.
Chapter 3
Solution:
g (x) = ln(x) − e −x , g ′ (x) = x1 + e −x
Iteration 1:
ln(x0 )−e −x0
n = 0, x1 = x0 − gg′(x 0)
(x0 ) = x0 − 1
+e −x0
= 1.26894
x0
Iteration 2:
g (x1 ) ln(x1 )−e −x1
n = 1, x2 = x1 − g ′ (x1 ) = x1 − 1
+e −x1
= 1.30911
x
1
Iteration 3:
g (x2 ) ln(x2 )−e −x2
n = 2, x3 = x2 − g ′ (x2 ) = x2 − 1
+e −x2
= 1.30980
x
2
Newton’s Method for Systems of Nonlinear
Zeros of
nonlinear
equations
Walter
Mudzimbabwe Consider a system of two equations:
Chapter 3
f (x, y ) = 0, g (x, y ) = 0
∂f ∂f
f (x + h, y + k) = f (x, y ) + h +k + ... (1)
∂x ∂y
∂g ∂g
g (x + h, y + k) = g (x, y ) + h +k + ... (2)
∂x ∂y
Newton’s Method for Systems of Nonlinear
Zeros of
nonlinear
If we keep only the first order terms, we are looking for a
equations couple (h, k) such that:
Walter
Mudzimbabwe ∂f ∂f
f (x + h, y + k) = 0 ≈ f (x, y ) + h +k (3)
Chapter 3 ∂x ∂y
∂g ∂g
g (x + h, y + k) = 0 ≈ g (x, y ) + h +k (4)
∂x ∂y
hence it is equivalent to the linear system:
" #
∂f ∂f
∂x ∂y h f (x, y )
∂g ∂g = − (5)
∂x ∂y
k g (x, y )
or
" #−1
∂f ∂f
h ∂x ∂y f (x, y )
=− ∂g ∂g (6)
k ∂x ∂y
g (x, y )
Newton’s Method for Systems of Nonlinear
Equations
Zeros of
nonlinear Finally
equations
Walter
Mudzimbabwe x +h x h
= +
y +k y k
Chapter 3
" #−1
∂f ∂f
x ∂x ∂y f (x, y )
= − ∂g ∂g (7)
y ∂x ∂y
g (x, y )
in general,
" #−1
∂f ∂f
xn+1 xn ∂x ∂y f (xn , yn )
= − ∂g ∂g (8)
yn+1 yn ∂x ∂y
g (xn , yn )
x=xn ,y =yn
i.e.,
xn+1 = xn − J(xn )−1 f (xn )
Example Newton’s method for Systems
Zeros of
nonlinear
Use Newton’s method to find the root of
equations
Walter
f (x, y ) = x 3 − 3xy 2 − 1 = 0
Mudzimbabwe
g (x, y ) = 3x 2 y − y 3 = 0
Chapter 3
with (x0 , y0 ) = (−0.6, 0.6)
Solution:
2
3x − 3y 2
−6xy 0 2.16
J(x, y ) = , J(x0 , y0 ) =
6xy 3x 2 − 3y 2 −2.16 0
so
−1 0 −0.463
J (x0 , y0 ) =
0.463 0
Therefore x1 = x0 − J(x0 )−1 f (x0 )
−0.6 0 −0.463 −0.568 −0.4
= − =
0.6 0.463 0 0.432 0.863
Example Newton’s method for Systems
Zeros of
nonlinear
equations
Walter
Mudzimbabwe
−1.754 2.071
J(x1 , y1 ) =
Chapter 3 −2.071 −1.754
so
−1 −0.238 −0.281
J (x1 , y1 ) =
0.281 −0.238
Therefore x2 = x1 − J(x1 )−1 f (x1 )
−0.4 −0.238 −0.281 −0.170 −0.505
= − =
0.863 0.281 −0.238 −0.228 0.856