CS321 Numerical Analysis and Computing: Locating Roots of Equations
CS321 Numerical Analysis and Computing: Locating Roots of Equations
CS321 Numerical Analysis and Computing: Locating Roots of Equations
Numerical Analysis
and Computing
Lecture 2
September 8, 2015
What is the Root
2
Roots (Zeros)of a Function
3
Roots (Zeros)of a Function
4
Roots of a Functions
Let f(x) be a function that has values of opposite signs at the two ends of
a given interval [a,b] with a < b, i.e., f(a)•f(b) < 0. If f(x) is continuous on
[a,b], then there exists a number c in [a,b] such that f(c) = 0
has a root in the interval [0,2]. It has two roots in the interval [-5,2]
5
A Root of a Function
6
A Function with Four Roots
7
Bisection Method
8
Bisection Process
9
Bisection Process
10
Bisection Process
11
Convergence Analysis
a0 + b0
Let r be a root of f(x) in the interval [a0, b0]. Let c0 = be the
midpoint, then 2
b0 − a 0
r − c0 ≤
2
If we use the bisection algorithm, we compute and have a0, b0, c0, a1, b1,
c1, …, then
bn − a n
r − cn ≤ ( n ≥ 2)
2
Since the interval length is halved at each step, we have
bn −1 − a n −1 b −a
bn − a n = == 0 n 0
2 2
Hence b0 − a 0
r − cn ≤
2 n+1
which is the maximum error if we take cn as an approximate to the root r
12
Linear Convergence
13
Stopping Criterion
| r − c n |< ε
i.e., we find a point cn inside the interval [a,b] that is very close to the
root r. We then use cn as an approximate to r
14
How Many Iterations
If we want the approximate root cn is close to the true root r, i.e., we want
r − cn < ε ,
Then the number of bisection steps n satisfies
b−a
n +1
<ε
2
Or
log( b − a ) − log( 2ε )
n>
log 2
Example. Find a root in [16,17] up to machine single precision
15
Newton’s Method
Given a function f(x) and a point x0, if we know the derivative of f(x) at x0, we
can construct a linear function that passes through (x0, f(x0)) with a slope
f’(x0) ≠ 0 as
l ( x ) = f ' ( x 0 )( x − x 0 ) + f ( x 0 )
Since l(x) is close to f(x) at x0, if x0 is close to r, we can use the root of l(x) as
an approximate to r, the root of f(x)
f ( x0 )
x1 = x 0 −
f ' ( x0 )
x1 may not be close to r enough, we repeat the procedure to find
f ( x1 )
x 2 = x1 − ,
f ' ( x1 )
Under certain conditions, {xn} converges to r
16
Newton’s Method
17
From Taylor Series
If f(x0) ≠ 0, but x0 is close to r, we may assume that they differ by h, i.e.,
x0 + h = r, or f ( x + h) = f ( r ) = 0
0
18
First Few Approximations
19
Fast Convergence
Find a root for the following function f(x), starting at x0 = 4
f ( x) = x 3 − 2 x 2 + x − 3
f '( x) = 3 x 2 − 4 x + 1
21
Convergence Analysis
Let the function f have continuous first and second derivatives f’ and f”,
and r be a simple root of f with f’(r) ≠ 0. If x0 is sufficiently close to r, then
Newton’s method converges to r quadratically.
2
xn+1 − r ≤ c xn − r
If xn differs from r by at most one unit in the kth decimal place, i.e.,
x n − r ≤ 10 − k
Then, for c = 1, we have
xn +1 − r ≤ 10 −2 k
The number of correct decimal digits doubles after another iteration
22
Convergence Proof
23
Convergence Proof Cont.
We thus have
1 f " (ξ n ) 2
e n +1 = − e n
2 f ' ( xn )
e n = x n − r ≤ δ and ξn − r ≤ δ
This is to guarantee that xn is close to r within a distance of δ
24
Convergence Proof Cont.
x n+1 − r = e n+1 ≤ ρ e n ≤ e n ≤ δ
25
Weakness of Newton’s Method
26
Problems of Newton’s Method
27
Newton’s Method Cycling
28
Systems of Nonlinear Equations
f 1 ( x1 , x 2 , x 3 ) = 0
f 2 ( x1 , x 2 , x 3 ) = 0
f 3 ( x1 , x 2 , x 3 ) = 0
Using Taylor expansion
f i ( x1 + h1 , x 2 + h2 , x 3 + h3 )
= f i ( x1 , x 2 , x 3 ) +
∂f i ∂f i ∂f i
h1 + h2 + h3 +
∂ x1 ∂x 2 ∂x 3
0 ≈ f ( x ( 0 ) + h ) = f ( x ( 0 ) ) + f ' ( x ( 0 ) )h
30
Example Cont.
The Jacobian matrix is ∂f 1 ∂f 1 ∂f 1
∂x1 ∂x 2 ∂x 3
∂f ∂f 2 ∂f 2
J= 2
∂x1 ∂x 2 ∂x 3
∂f ∂f 3 ∂f 3
∂x3
It follows that 1 ∂x 2 ∂x 3
31
Secant Method
In Newton’s method
f ( xn )
x n+1 = xn −
f ' ( xn )
32
Secant Method
33
Comments
Secant method needs two iterates to start with, we can use bisection
method to generate the second iterate
If | f(xn) – f(xn-1)| is small, the computation may lose significant digits and
becomes unstable
20
Hybrid Approaches
In practice, hybrid methods are usually used
For example, we can use Bisection Method to generate initial iterates that
are close to the root, so that Newton’s method can be applied
35