Nonlinear Spring21
Nonlinear Spring21
Feng-Nan Hwang
Department of Mathematics
National Central University,
Jhongli District, Taoyuan City, Taiwan
Email: [email protected]
Homepage: http:/www.math.ncu.edu.tw/~hwangf
References:
Chapter 3 of the textbook
1 / 45
Introduction
2 / 45
I This is not an easy task, in general. Let us look at three
equations
I f (x) = x 4 − 12x 3 + 47x 2 − 60x
I f (x) = x 4 − 12x 3 + 47x 2 − 60x + 24
I f (x) = x 4 − 12x 3 + 47x 2 − 60x + 24.1
I The first function has roots 0, 3, 4, and 5
I The real roots of the second function are 1 and 0.888...
I The third function has no real roots at all
3 / 45
I The basic questions:
1. Does the solution exist?
2. Is the solution unique?
3. How to find it?
I In this class, we don’t try to answer (1) and (2) — Too Hard!
I We assume that the problem has a unique solution and focus
only on question (3)
I We will study iterative methods for finding the solution: First
find an initial guess x0 , then a better guess x1 , . . . , in the end
we hope lim xn = x ∗
n→∞
4 / 45
Convergence rate
kxn+1 − x ∗ k ≤ C kxn − x ∗ kp
5 / 45
Section 3.1 Bisection method
6 / 45
Bisection method
7 / 45
An example: Use the bisection method to find the root of
e x = sin(x)
A rough plot of f (x) = e x − sin(x) shows there is no positive root,
and the first root to the left of 0 is somewhere in the interval
[−4, −3].
f(x)=exp(x)−sin(x)
2
1.5
0.5
−0.5
−1
−5 −4 −3 −2 −1 0 1
x
8 / 45
The output obtained by bisection algorithm running a machine
similar to Marc-32
k c f (c)
1 -3.5000 -0.321
2 -3.2500 −0.694 × 10−1
3 -3.1250 −0.605 × 10−1
4 -3.1875 −0.625 × 10−1
.. .. ..
. . .
13 -3.1829 0.122 × 10−3
14 -3.1830 0.193 × 10−4
15 -3.1831 −0.124 × 10−4
16 -3.1831 0.345 × 10−5
9 / 45
I How do we implement the algorithm? What do we need?
I We need an initial interval. This is often the hardest thing to
find.
I We need some stopping conditions.
I If |f (c)| ≤ , we stop
I If k ≥ M, we stop, to avoid infinite loop
I If |b − a| ≤ δ, we stop
10 / 45
A pseudocode for the bisection algorithm
input a, b, M, δ,
u ← f (a), v ← f (b), and e ← b − a
if sign(u) = sign(v ), then stop
for k = 1 to M do
e ← e/2, c ← a + e, w ← f (c)
if |e| < δ or |w | < , then stop
if sign(u) 6= sign(w ), then
b ← c, v ← w
else
a ← c, u ← w
end if
end do
Note 1: sign(u) 6= sign(v ) is better than if( uv < 0 ). Why?
Note 2: Compute midpoint as c ← a + (b − a)/2 rather than
c ← (a + b)/2. Why?
11 / 45
Convergence analysis
I We have three sequences of numbers: left point an , mid point
cn , and right point bn , with n = 0, 1, . . . , and they satisfy
or
bn − an = 2−n (b0 − a0 ),
I Taking the limit, we have
lim an = lim bn
n→∞ n→∞
12 / 45
I Take the limit of
f (an )f (bn ) ≤ 0
and use the assumption that f (x) is continuous
(limn→∞ f (an ) = f (limn→∞ an )), we obtain
f (r )f (r ) ≤ 0
13 / 45
How fast is the convergence?
14 / 45
I For example, if we start with the initial interval [50, 63], how
many steps do we need in order to have a relative accuracy to
be smaller than 10−12 ?
I This is what we want
|r − cn |/|r | ≤ 10−12
|r − cn |/50 ≤ 10−12 .
That means n ≥ 37
15 / 45
Some major problems with the bisection method
16 / 45
Section 3.2 Newton’s method
17 / 45
Newton’s method
0 = f (x) + hf 0 (x)
which means
h = −f (x)/f 0 (x)
18 / 45
I If x is an approximation of x ∗ , then x + h should be a better
approximation of x ∗ . Hence,
x + h = x − f (x)/f 0 (x)
I Newton’s method can be defined as:
x ← x − f (x)/f 0 (x)
or
xn+1 = xn − f (xn )/f 0 (xn )
19 / 45
I Example: Find the root of f (x) = e x − 1.5 − tan−1 x.
Suppose we start with x0 = −7, then the iteration goes like
x0 = −7, f (x0 ) = −0.7 × 10−1
x1 = −10.7, f (x1 ) = −0.2 × 10−1
···
x3 = −14.0, f (x3 ) = −0.2 × 10−3
x4 = −14.1, f (x4 ) = −0.8 × 10−6
I In-class exercise. Find an efficient method for computing
square roots of a given positive number using Newton’s
method.
20 / 45
Geometrical interpretation
See http://www.math.umn.edu/˜garrett/qy/Newton.html
21 / 45
A little informal convergence theory
Define the error as en = xn − x ∗
0 = f (x ∗ ) ≈ f (xn − en )
22 / 45
So, we obtain
en+1 ≈ Cen2
or more precisely
|en+1 | ≤ C |en2 |
23 / 45
Theorem on Newton’s method
|xn+1 − x ∗ | ≤ C |xn − x ∗ |2
24 / 45
Example: Find the root of f (x) = α − 1/x, for any given α > 0.
(We know the exact solution is x ∗ = 1/α)
I Using Newton’s method:
which is same as
25 / 45
Questions:
I Does the sequence x0 , x1 , x2 , . . . converge?
I How fast?
I Does the convergence depend on the initial guess x0 ?
26 / 45
Let us define the error
en = x ∗ − xn = 1/α − xn
Then
That is
en+1 = αen2
If it converges, then the rate is q-quadratic.
27 / 45
We now have
1 2
en+1 = αen2 = α(αen−1
2
)2 = (αen−1 )2
α
1 n+1
··· = (αe0 )2
α
∗
Therefore, xn converges to x only if |αe0 | < 1
|e0 | ≤ 1/α
or
|1/α − x0 | < 1/α
or
−1/α < 1/α − x0 < 1/α
or
0 < x0 < 2/α
28 / 45
Some remarks
29 / 45
Implementation of Newton’s method
Input x and M
y ← f (x)
for k = 1 to M do
0
x ← x − y /f (x)
y ← f (x)
end do
30 / 45
Stopping conditions
31 / 45
A better implementation of Newton’s method
Input x0 , M, ε, δ
v ← f (x0 )
if |v | ≤ ε stop
for k = 1 to M do
0
x1 = x0 − v /f (x0 )
v ← f (x1 )
if |x1 − x0 | ≤ δ or |v | ≤ ε stop
x0 ← x1
end do
32 / 45
I Another condition: If |f 0 (x)| is too small, 1/|f 0 (x)| may
overflow the calculation
I A question: What happens if f 0 (x) is not available? Will
study in the next section.
33 / 45
Systems of nonlinear equation
I We wish to solve
f1 (x1 , x2 ) = 0
f2 (x1 , x2 ) = 0,
34 / 45
I To simplify the notation we introduce the Jacobian matrix
" #
∂f1 ∂f1
J= ∂x1 ∂x2
∂f2 ∂f2
∂x1 ∂x2
I Then we have
0 f1 (x1 , x2 ) h1
= +J
0 f2 (x1 , x2 ) h2
35 / 45
I Newton’s method in 2D
" # " # " #
(k+1) (k) (k)
x1 x1 h1
(k+1) = (k) + (k)
x2 x2 h2
4x12 − x22
=0
4x1 x22 − x1 = 1
36 / 45
I In general, we can use Newton’s method for
F (X ) = 0
37 / 45
I Newton’s method in n dimensional space: Given
(0) (0)
X (0) = [x1 , · · · , xn ]T
38 / 45
Section 3.3 Secant method
39 / 45
Methods without using derivatives
I Basic idea:
x ← x − f (x)/f 0 (x)
If f 0 (x) is too hard or too expensive to compute, we can use
an approximation
I Questions:
I How to obtain an approximation?
I Do we lose the fast convergence?
I Two classes of methods
I Finite difference Newton’s method
I Secant method
40 / 45
Finite difference Newton’s method
a = (f (x + h) − f (x))/h
41 / 45
Secant method
I Since h can be any small number in the FD-Newton’s
method, why don’t we simply use
h = xn − xn−1 ,
42 / 45
Which of the three methods is better?
43 / 45
Convergence rates
44 / 45
More remarks
45 / 45