Lecture 5
Lecture 5
Lecture 5
Roots of Equations
2
Simple Fixed-point Iteration
• Rearrange the function so that x is on the left-hand side of the equation:
f ( x )= 0 ⇒ g ( x)= x EXAMPLE:
x k = g ( x k − 1 ) x o is given , k= 1, 2, .. . f ( x)= x 2 − x− 2= 0
Rewrite it as: x= g ( x)
• Bracketing methods are “convergent” if you 2
have a bracket to start with x= x − 2
or
• Fixed-point methods may sometimes
“converge”, depending on the starting point x= √x+ 2
(initial guess) and how the function behaves. or
2
x= 1+
x
⋮
3
Newton-Raphson Method
• Most widely used formula
for locating roots.
f ( xi )
x i+ 1= x i −
f ' ( xi )
f ( xi )
x i+ 1= x i −
f ' ( xi )
• Newton-Raphson is a convenient
method if f’(x) (the derivative) can be
evaluated analytically
• Rate of convergence is quadratic, i.e.
the error is roughly proportional to the
square of the previous error
Ei+1=O(Ei2)
(proof is given in the Text)
But:
• it does not always converge èèè
0 0.5
1 51.65
10
f ( x )= x − 1 2 46.485
3 41.8365
N-R Formula: 4 37.65285
5 33.887565
x10
i − 1 .
x i+ 1= x i − use x o = 0. 5
10 x 9i .
38 1.083
W:\228\MATLAB\6\newtraph.m & func2 ∞ 1.0000000
6
The Secant Method
• If derivative f’(x) can not be computed analytically then we need to
compute it numerically (backward finite divided difference method)
f ( xi )
Newton-Raphson: x i+ 1 = x i −
f ' ( x i)
df f ( x i )− f ( x i− 1 )
'
f ( x i )= ≃
dx x i − x i− 1
x i − x i− 1
Secant: x i+ 1 = x i − f ( x i ) i= 1,2,3,…
f ( x i )− f ( x i− 1 )
The Secant Method
x i − x i− 1
x i+ 1= x i − f ( x i )
f ( x i )− f ( x i− 1 )
• Requires two initial estimates
xo, x1.
However, it is not a
“bracketing” method.
• The Secant Method has the
same properties as Newton’s
method.
Convergence is not guaranteed
for all xo, f(x).
8
Modified Secant Method
f ( xi )
Newton-Raphson: x i + 1= x i −
f ' ( xi )
x i − x i− 1
Original Secant: x i+ 1= x i − f ( x i )
f ( x i )− f ( x i− 1 )
δx i
Modified Secant: x i+ 1= x i − f ( x i )
f ( x i + δx i )− f ( x i )
9
Systems
Systemsof
of Nonlinear Equations
Nonlinear Equations
• Locate the roots of a set of simultaneous nonlinear equations:
f 1 ( x 1 , x 2 , x 3 ,… , x n )= 0
f 2 ( x 1 , x 2 , x 3 ,… , x n )= 0
⋮
f n ( x 1 , x 2 , x 3 ,… , x n )= 0
Example:
x 2 + xy= 10 ⇒ u( x , y)= x 2+ xy− 10= 0
y+ 3 xy = 57 ⇒
2 2
v( x , y )= y+ 3 xy − 57= 0
10
• First-order Taylor series expansion of a function with more than one variable:
∂ ui ∂ ui
u i+ 1 = u i+ ( x i+ 1 − x i )+ ( y i+ 1 − y i )= 0
∂x ∂y
∂ vi ∂v i
v i+ 1 = v i + ( x i+ 1− x i )+ ( y i+ 1 − y i )= 0
∂x ∂y
• The root of the equation occurs at the value of x and y where ui+1=0 and vi+1=0
Rearrange to solve for xi+1 and yi+1
[ ] [ ]
∂ ui ∂ ui ∂ ui ∂ ui ∂ ui ∂ ui ∂ ui ∂ ui
x i+ 1+ y i+ 1 = − ui + xi+ yi
∂x
∂ vi
x i+ 1 +
∂y
∂vi
y i+ 1 = − v i +
∂x
∂ vi
xi+
∂y
∂ vi
yi
∂x
∂v i
∂x
∂y
∂ vi
∂y
[ ] []
x i+ 1
y i+ 1
u
=− i +
vi
∂x
∂ vi
∂x
∂y
∂ vi
∂y
[]
xi
yi
∂x ∂y ∂x ∂y
• Since xi, yi, ui, and vi are all known at the ith iteration, this represents a set of
two linear equations with two unknowns, xi+1 and yi+1
• You may use several techniques to solve these equations