Chapter 1 Solving Equations
Chapter 1 Solving Equations
Chapter 1 Solving Equations
Solving Equations
• Stewart platform
– As a six-degree-of-freedom, robot, the Stewart
platform can be placed at any point and
inclination in three dimensional space that is
within its reach
– A two-dimensional is discussed in the Reality
Check
• Given (x, y, θ), determine (p1, p2, p3)
• No closed-form solution is known
(tolerance)
• Example 1.1
Use Bisection Method to find the root of the function
f ( x ) = x + x − 1 on the interval [0,1]
3
>> x0=(a+b)/2 x1 =
x0 = 0.7500
0.5000
• How accurate and how fast?
– [a0,b0] is the staring interval
– After n bisection steps, bn-an=(b0-a0)/2n , and the
solution is xc=(bn+an)/2
– Error< (bn-an)/2= (b0-a0)/2n+1
– Total function evaluations=n+2
– Definition1.3
• A solution is correct within p decimal places if the error
is less than 0.5x10-p
π = 3.141592653589793
πˆ 2 ≈ 3.141 π − πˆ 2 ≈ 0.00059
0.59 × 10−3 > 0.5 × 10−3
0.059 ×10−2 < 0.5 × 10−2 2 decimal places
b − a 1− 0
En < n+1 = n+1 < 0.5 × 10−6 >> log2(1/0.5e-6)
2 2
1 ans =
2n+1 >
0.5 × 10−6 20.931568569324174
1
log 2 2n+1 > log 2 −6
0.5 × 10
n > 19.93
– See & run “ex1p2.m”
Computed Solutions(xc)
1 Error bound & errors
100
0.8
10-2
0.6
10-4
0.4
10-6
0.2
0 10-8
0 5 10 15 20 0 5 10 15 20
• Bisection summary
– A stable method that always converge
– We can know how many steps is required for a
desired precision
– By contrast, more high-power algorithms are
often less predictable
• Not necessarily converge
• Need to define stopping criteria
1.2 Fixed-Point Iteration
• Fixed points of a function
– Def. 1.4: The real number r is a fixed point of the
function g if g(r)=r
• g(x)=cos(x)=> r=0.7390851332
• g(x)=x3=> r=-1, 0, 1
– Once equation is written as g(x)=x, fixed-point
iteration proceeds as inital guess x0
xi +1 = g ( xi )
– Not necessarily converge
– Recalculate EXAMPLE 1.1: x3+x-1=0
• x0=0.5, r=0.682327803828020
1+2 x 3
(a) g ( x ) = 1 − x 3 (b) g ( x ) = 3 1 − x (c) g ( x ) =
1 + 3x 2
– Linear convergence of fixed-point iteration
• Geometric view
– |g’(r)| makes the crucial difference between divergence and
convergence
3 5 1 3
g1 ( x ) = − x + g2 ( x ) = − x +
2 2 2 2
r =1 r =1
3 1
g1 ( r ) = > 1
′ g1 ( r ) = < 1
′
2 2
• In terms of equations, it helps to write g1(x) and g2(x) in
terms of x-r
– The error is ei=|xi-r| for i-th iteration
3 5 1 3
g1 ( x ) = − x + g2 ( x ) = − x +
2 2 2 2
3 1
= − ( x − 1) + 1 = − ( x − 1) + 1
2 2
3 1
g1 ( x ) − 1 = − ( x − 1) g 2 ( x ) − 1 = − ( x − 1)
2 2
3 1
xi +1 − 1 = − ( xi − 1) xi +1 − 1 = − ( xi − 1)
2 2
3 1
ei +1 = ei ei +1 = ei
2 2
– Def. 1.5 :
ei +1
lim = S < 1 Linear convergence with rate S
i →∞ e
i
(c)
(a) (b)
3 3 x 3 + x = 1+2 x 3
x = 1− x x = 3 1− x
g ′ ( r ) = 1.3966 > 1 x ( 3 x 2 + 1) = 1+2 x 3
g ′ ( r ) = 0.716 < 1
1+2 x 3
x=
1 + 3x 2
g′( r ) = 0
• Example 1.3
Explain why the FPI g(x)=cos(x) converges
• Example 1.4
Use FPI to find a root of cos(x)=sin(x)
• Example 1.5
Find the fixed point of g(x)=2.8x-x2
g ′ ( 0 ) = 2.8
g ′ (1.8 ) = −0.8
• Example 1.6
Calculate by using FPI
x= 2
2
x =2
(b)
(a)
2
2 =x
=x x
x 2
2 + x = 2x
xi +1 = x
xi x+2 x
=x
=> won’t converge 2
=> rapidly converge
• YBC 7289 is a Babylonian clay tablet
– Some time in the range from 1800–1600 BC
» The Babylonians’ method is not known, but some
speculate it is based on the FPI algorithm in base 60
» In the first century A.D., Heron of Alexandria used the FPI
algorithm to calculate 720
– Stopping criteria
1.
2.
3.
1.3 Limits of Accuracy
• Forward and backward error
– Forward error: |r-xa|
– Backward error: |f(xa)|
– Well-conditioned problems
• Both errors approach zero, e.g.,
>> syms x
>> f1=(x-1)*(x-2)*(x-3)*(x-4)*(x-5);
>> expand(f1)
ans = x^5 - 15*x^4 + 85*x^3 - 225*x^2 + 274*x - 120
>> f1=@(x) x^5 - 15*x^4 + 85*x^3 - 225*x^2 + 274*x - 120;
>> fzero(f1,5)
ans = 5
>> f1(5)
ans =0
– Ill-conditioned problems
• Forward error can hardly approach zero
• Example 1.7
3
4 8 2
f ( x ) = x3 − 2 x 2 + x− =x−
3 27 3
>> f=@(x) x^3-2*x^2+4/3*x-8/27;
>> fzero(f,1)
ans =
0.666664247279230
>> f(0.666664247279230)
ans =
0
• Wilkinson polynomial
>> syms x
>> f2=(x-1)*(x-2)*(x-3)*(x-4)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*...
(x-11)*(x-12)*(x-13)*(x-14)*(x-15)*(x-16)*(x-17)*(x-18)*(x-19)*(x-20);
>> expand(f2)
ans =
>> fzero(f2,16)
ans =
16.014680305804578
>> f2(16.014680305804578)
ans =
-1.089172930560000e+11
1.4 Newton’s Method
• Given a function f(x), finding f(xr)=0
– Initial guess: x0
– Express f(x) with Taylor series @ x0
f ( x ) = f ( x0 ) + f ′ ( x0 )( x − x0 ) +
-1 x3 = 142.35
f ( x)
f(m)
-2
-3
x0 = 68
-4
-5
50 100 150 200
x
m [kg]
• Example 1.11
Find the Newton’s Method formula for the
3
equation x + x − 1 = 0
f ( x ) = x3 + x − 1
f ′ ( x ) = 3x 2 + 1
f ( xi ) xi3 + xi − 1
xi +1 = xi − = xi −
f ′ ( xi ) 3 xi2 + 1
2 xi3 + 1
= 2 >> roots([1 0 1 -1])
3 xi + 1
ans =
-0.341163901914009 + 1.161541399997252i
-0.341163901914009 - 1.161541399997252i
0.682327803828020 + 0.000000000000000i
– See & run ex1p11.m
0: xc=-7.000000e-01 error=1.382328e+00
1: xc=1.271255e-01 error=5.552023e-01
2: xc=9.576781e-01 error=2.753503e-01
3: xc=7.348278e-01 error=5.249999e-02 =>Quadratic convergence
4: xc=6.845918e-01 error=2.263967e-03
5: xc=6.823322e-01 error=4.370376e-06
6: xc=6.823278e-01 error=1.631228e-11
Computed Solutions(x )
c
10
2 x2
0
-2 x1
x0
-4
-1 -0.5 0 0.5 1 1.5 2
– Revisit Example 1.2
• Solve f ( x ) = cos ( x ) − x = 0
0.8
10-5
0.6
10-10
0.4
10-15
0.2
0 10-20
0 5 10 15 20 0 5 10 15 20
• Quadratic convergence of Newton’s method
– Def. 1.10
An iteration method is quadratic convergence if
ei +1
lim 2 = M < ∞
i →∞ e
i
– Theorem 1.11
Newton’s Method is locally and quadratically
convergent to r &
f ′′ ( r )
M=
2 f ′( r )
– Proof of Theorem 1.11
• To prove convergence
– Newton’s method is a particular form of Fixed-Point Iteration
FPI: xi +1 = g ( xi )
f ( xi )
Newton's: xi +1 = xi −
f ′ ( xi )
f ( x)
g ( x) = x −
f ′( x)
2
f ′ ( x ) − f ( x ) f ′′ ( x ) f ( x ) f ′′ ( x )
g′( x) = 1 − 2
= 2
f ′ ( x ) f ′ ( x )
f ( r ) f ′′ ( r )
g′( r ) = 2
= 0 <1
f ′ ( r )
f ( r ) = f ( xi ) + f ′ ( xi )( r − xi ) + f ′′ ( ci )
2
( r − xi )
2
0 = f ( xi ) + f ′ ( xi )( r − xi ) + f ′′ ( ci )
2
− f ( xi ) ( r − xi ) f ′′ ( ci )
2
= ( r − xi ) +
f ′ ( xi ) 2 f ′ ( xi )
f ( xi ) ( r − xi ) f ′′ ( ci )
2
xi − −r =
f ′ ( xi ) 2 f ′ ( xi )
f ′′ ( ci )
( xi − r )
2
xi +1 − r =
2 f ′ ( xi )
f ′′ ( ci ) 2 f ′′ ( r ) 2
ei +1 = ei ≈ ei
2 f ′ ( xi ) 2 f ′(r )
– Algorithm for finding
f ( x) = x − a = 0
2
f ′( x ) = 2x
a
xi +
f ( xi ) 2
xi − a xi
xi +1 = xi − = xi − =
f ′ ( xi ) 2 xi 2
For a = 2 (1.14 )
• Linear convergence of Newton’s method
– Newton's Method does not always converge
quadratically
– FPI does not always converge linearly
• Example 1.12
Use Newton’s Method to find a root of
• Example 1.13
Use Newton’s Method to find a root of
– Theorem 1.13
If f contains a root r of multiplicity m>1, then Modified
Newton’s Method
mf ( x )
xi +1 = xi −
f ′( x )
converges locally and quadratically to r
f ( x ) = x3
• Example 1.15
Apply Newton’s Method to
f ( x ) = x3 − 3sin ( x )
-2 f ( x1 ) − f ( x0 )
g ( x2 ) = f ( x0 ) + ( x2 − x0 )
g ( x) x1 − x0
-3
x1 − x0
x2 = x1 − f ( x0 )
-4 f ( x1 ) − f ( x0 )
⊕ x0
-5
50 100 m 150 200
– Iteration formula & convergence rate
α −1
f ′′ ( r )
ei +1 ≈ eiα
2 f ′( r )
1+ 5
where α = ≈ 1.62 Superlinear convergence
2
• Example 1.16
Apply the Secant Method with starting guesses
x0=0, x1=1 to find the root of
x2 =
0.5000
>> x3=x2-(x2-x1)*fx(x2)/(fx(x2)-fx(x1))
x3 =
0.6364
– Muller’s method and IQI
• Use three points to draw the parabola
Muller: IQI:
y = P2 ( x ) x = P2 ( y )
y = f ( x)
• Brent’s method
– Bisection + Secant + IQI
>> f=@(x) x^3+x-1;
fzero(f,[0 1],optimset('Display','iter'))
ans =
0.682327803828019
>> f=@(x) x^3+x-1;
fzero(f,1,optimset('Display','iter'))
ans =
0.6823
• Revisit Example 1.2
– Solve
• Use IQI to solve Example 1.2
– Solve
X 0 = [ 0 0.5 1]
X 1 = [ 0.5 0.75 1]
x0 = 0.5 → x1 = 0.75 → x2 = 0.739 →
6
x = −0.0777 y 2 − 0.6036 y + 0.7390
4
0 f ( x)
-2
-4
x = −0.1412 y 2 − 0.6088 y + 0.75
-6
-6 -5 -4 -3 -2 -1 0 1 2
Computed Solutions(xc)
Bisection
Newton
FPI
Secant
IQI
Errors
Bisection
Newton
FPI
Secant
IQI
• A circuit example
( )
I D = I S eVD VT − 1 ≈ I S eVD VT , when VD >> VT
I S = 10−15 A
VT ≈ 27 mV
100 Ω
ID
+
4V
VD
−