Anda di halaman 1dari 52

Part 2

Roots of Equations

Why?
b b 2
4ac
ax bx c 0 x
2

2a

But
ax 5 bx 4 cx 3 dx 2 ex f 0 x ?
sin x x 0 x ?

1
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
2
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Nonlinear Equation
Solvers

Bracketing Graphical Open Methods

Bisection Newton Raphson


False Position
(Regula-Falsi) Secant

All Iterative
3
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 5
Bracketing Methods
(Or, two point methods for finding roots)
Two initial guesses for the
root are required. These
guesses must bracket or
be on either side of the root.

== > Fig. 5.1

If one root of a real and


continuous function, f(x)=0,
is bounded by values x=xl, x
=xu then
f(xl) . f(xu) <0. (The function
changes sign on opposite sides of the
root)

4
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Figure 5.2

5
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Figure 5.3

6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The Bisection Method
For the arbitrary equation of one variable, f(x)=0
1. Pick xl and xu such that they bound the root of
interest, check if f(xl).f(xu) <0.

2. Estimate the root by evaluating f[(xl+xu)/2].

3. Find the pair


If f(xl). f[(xl+xu)/2]<0, root lies in the lower interval,
then xu=(xl+xu)/2 and go to step 2.
7
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
If f(xl). f[(xl+xu)/2]>0, root
lies in the upper interval,
then xl= [(xl+xu)/2, go to
step 2.
If f(xl). f[(xl+xu)/2]=0, then
root is (xl+xu)/2 and
terminate.

xr
new old
xr
4. Compare es with ea ea new
100%
(5.2, p. 118) xr

5. If ea< es, stop. Otherwise


repeat the process.
8
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Step f (x ) = 2 - e -x x R = -ln(2) = -0.69314718 ea et
XL -1 XR -0.5 XU 0
1 f(XL) -0.71828 f(XR ) 0.351279 f(XU ) 1
f(XL)*f(XR) -0.25232 f(XL)*f(XR) 0.351279
XL -1 XR -0.75 XU -0.5
2 f(XL) -0.71828 f(XR ) -0.117 f(XU ) 0.351279 0.333333 0.056853
f(XL)*f(XR) 0.084039 f(XL)*f(XR) -0.0411
XL -0.75 XR -0.625 XU -0.5
3 f(XL) -0.117 f(XR ) 0.131754 f(XU ) 0.351279 0.2 0.068147
f(XL)*f(XR) -0.01542 f(XL)*f(XR) 0.046282
XL -0.75 XR -0.6875 XU -0.625
4 f(XL) -0.117 f(XR ) 0.011263 f(XU ) 0.131754 0.090909 0.005647
f(XL)*f(XR) -0.00132 f(XL)*f(XR) 0.001484
Evaluation of Method

Pros Cons
Easy Slow
Always find root Know a and b that
Number of iterations bound root
required to attain an Multiple roots
absolute error can be No account is taken of
computed a priori. f(xl) and f(xu), if f(xl) is
closer to zero, it is likely
that root is closer to xl .

10
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
How Many Iterations will It Take?
Length of the first Interval Lo=b-a
After 1 iteration L1=Lo/2
After 2 iterations L2=Lo/4

After k iterations Lk=Lo/2k

Lk
e a 100% ea es
xR

11
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
If the absolute magnitude of the error is

L0 L0
n n log 2
n
Ea
2 Ea , d
and Lo=2, how many iterations will you have to
do to get the required accuracy = 10-4 in the
solution?
2
log 4
n 10
14.3 n 15
log( 2)
12
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The False-Position Method
If a real root is
(Regula-Falsi)
bounded by xl and xu of
f(x)=0, then we can
approximate the
solution by doing a
linear interpolation
between the points [xl,
f(xl)] and [xu, f(xu)] to
find the xr value such
that l(xr)=0, l(x) is the
linear approximation
of f(x).

== > Fig. 5.12

13
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Procedure
1. Find a pair of values of x, xl and xu such that
fl=f(xl) <0 and fu=f(xu) >0.
2. Estimate the value of the root from the
following formula (Refer to Box 5.1)

xl f u xu f l
xr
fu fl
and evaluate f(xr).

14
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3. Use the new point to replace one of the
original points, keeping the two points on
opposite sides of the x axis.

Use the same selecting rules as the bisection


method.

If f(xr)=0 then you have found the root and


need go no further.

15
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4. See if the new xl and xu are close enough for
convergence to be declared. If they are not go back
to step 2.

Why this method?


Usually faster
Always converges for a single root.

See Sec.5.3.1, Pitfalls of the False-Position Method


Note: Always check by substituting estimated root in the
original equation to determine whether f(xr) 0.
One-sidedness: Watch out (p. 128)
16
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Step f (x ) = 2 - e -x x R = -ln(2) = -0.69314718 ea et
XL -1 XR -0.58198 XU 0
1 f(XL) -0.71828 f(XR ) 0.210428 f(XU ) 1
f(XL)*f(XR) -0.15115 f(XL)*f(XR) 0.210428
XL -1 XR -0.67669 XU -0.58198
2 f(XL) -0.71828 f(XR ) 0.03264 f(XU ) 0.210428 0.139969 0.016454
f(XL)*f(XR) -0.02344 f(XL)*f(XR) 0.006868
XL -1 XR -0.69075 XU -0.67669
3 f(XL) -0.71828 f(XR ) 0.004797 f(XU ) 0.03264 0.020345 0.002402
f(XL)*f(XR) -0.00345 f(XL)*f(XR) 0.000157
XL -1 XR -0.6928 XU -0.69075
4 f(XL) -0.71828 f(XR ) 0.000699 f(XU ) 0.004797 0.002962 0.00035
f(XL)*f(XR) -0.0005 f(XL)*f(XR) 3.36E-06
Chapter 6
Open Methods
Figure 6.1
Open methods
are based on
formulas that
require only a
single starting
value of x or two
starting values
that do not
necessarily
bracket the root.
18
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Simple Fixed-point Iteration
Rearrange the function so that x is on the
left side of the equation:
f ( x) 0 g ( x) x
xk g ( xk 1 ) xo given , k 1, 2, ...
Bracketing methods are convergent.
Fixed-point methods may sometime
diverge, depending on the stating point
(initial guess) and how the function behaves.
Good for calculators.
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
19
Example:
f ( x) x x 2
2
x0
g ( x) x 2
2

or
g ( x) x 2
or
2
g ( x) 1
x

20
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
2
g(x) = 1+2/x g(x) = x -2 g(x) = (x+2)^0.5
xold xnew xold xnew xold xnew
1 3 1 -1 1 1.732
3 1.667 -1 -1 1.732 2.155
1.667 2.2 -1 -1 2.155 1.928
2.2 1.909 -1 -1 1.928 2.037
1.909 2.048 -1 -1 2.037 1.982
2.048 1.977 -1 -1 1.982 2.009
1.977 2.012 -1 -1 2.009 1.995
2.012 1.994 -1 -1 1.995 2.002
1.994 2.003 -1 -1 2.002 1.999
2.003 1.999 -1 -1 1.999 2.001
1.999 2.001 -1 -1 2.001 2
g(x) = 1+2/x g(x) = x2-2 g(x) = (x+2)^0.5
xold xnew xold xnew xold xnew
0 ##### 0 -2 0 1.414
##### ##### -2 0 1.414 2.414
##### ##### 0 ##### 2.414 1.828
##### ##### ##### ##### 1.828 2.094
##### ##### ##### ##### 2.094 1.955
##### ##### ##### ##### 1.955 2.023
##### ##### ##### ##### 2.023 1.989
##### ##### ##### ##### 1.989 2.006
##### ##### ##### ##### 2.006 1.997
##### ##### ##### ##### 1.997 2.001
##### ##### ##### ##### 2.001 1.999

22
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Convergence Figure 6.2

x=g(x) can be expressed


as a pair of equations:
y1=x
y2=g(x) (component
equations)
Plot them separately.

23
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Conclusion
Fixed-point iteration converges if

g( x) 1 (slope of the line f(x) x)

When the method converges, the error is


roughly proportional to or less than the error of
the previous step, therefore it is called linearly
convergent.

24
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Newton-Raphson Method
Most widely used method.
Based on Taylor series expansion:
x 2
f ( xi 1 ) f ( xi ) f ( xi )x f ( xi ) Ox 3
2!
The root is the value of x i 1 when f(x i 1 ) 0
Rearrangin g,
Solve for
0 f(xi ) f (xi )( xi 1 xi )
f ( xi )
xi 1 xi Newton-Raphson formula
f ( xi )
25
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fig. 6.5

A convenient method for


functions whose
derivatives can be
evaluated analytically. It
may not be convenient
for functions whose
derivatives cannot be
evaluated analytically.

26
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fig. 6.6

27
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The Secant Method
A slight variation of Newtons method for
functions whose derivatives are difficult to
evaluate. For these cases the derivative can be
approximated by a backward finite divided
difference.

f ( xi ) f ( xi 1 )
f ( xi )
xi xi 1
xi xi 1
xi 1 xi f ( xi ) i 1,2,3,
f ( xi ) f ( xi 1 )
28
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fig. 6.7

Requires two initial


estimates of x , e.g, xo,
x1. However, because
f(x) is not required to
change signs between
estimates, it is not
classified as a
bracketing method.
The scant method has the
same properties as
Newtons method.
Convergence is not
guaranteed for all xo,
f(x).

29
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fig. 6.8

30
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Multiple Roots
None of the methods deal with multiple roots
efficiently, however, one way to deal with problems
is as follows:
f ( xi )
Set u ( xi ) This function has
f ( xi ) roots at all the same
locations as the
u ( xi )
Then find xi 1 original function
u ( xi )

31
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fig. 6.10

32
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Multiple root corresponds to a point where a
function is tangent to the x axis.
Difficulties
Function does not change sign at the multiple root,
therefore, cannot use bracketing methods.
Both f(x) and f(x)=0, division by zero with
Newtons and Secant methods.

33
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Systems of Linear Equations

f1 ( x1 , x2 , x3 ,, xn ) 0
f 2 ( x1 , x2 , x3 ,, xn ) 0

f n ( x1 , x2 , x3 ,, xn ) 0

34
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Taylor series expansion of a function of more than
one variable

ui ui
ui 1 ui ( x1i 1 x1i ) ( yi 1 yi )
x y
vi vi
vi 1 vi ( x1i 1 x1i ) ( yi 1 yi )
x y

The root of the equation occurs at the value of x


and y where ui+1 and vi+1 equal to zero.

35
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
ui ui ui ui
xi 1 yi 1 ui xi yi
x y x y
vi vi vi vi
xi 1 yi 1 vi xi yi
x y x y

A set of two linear equations with two


unknowns that can be solved for.

36
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
vi ui
ui vi
y y
xi 1 xi
ui vi ui vi

x y y x
vi ui
ui vi
yi 1 yi x x
ui vi ui vi
Determinant of
x y y x
the Jacobian of
the system.

37
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 7
Roots of Polynomials
The roots of polynomials such as

f n ( x) ao a1 x a2 x an x 2 n

Follow these rules:


1. For an nth order equation, there are n real or
complex roots.
2. If n is odd, there is at least one real root.
3. If complex root exist in conjugate pairs (that is,
l+mi and l-mi), where i=sqrt(-1).
38
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Conventional Methods
The efficacy of bracketing and open methods
depends on whether the problem being solved
involves complex roots. If only real roots exist,
these methods could be used. However,
Finding good initial guesses complicates both the
open and bracketing methods, also the open
methods could be susceptible to divergence.
Special methods have been developed to find
the real and complex roots of polynomials
Mller and Bairstow methods.
39
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Mller Method
Mllers method obtains a root estimate by
projecting a parabola to the x axis through three
function values. Figure 7.3

40
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Mller Method
The method consists of deriving the
coefficients of parabola that goes through the
three points:

1. Write the equation in a convenient form:

f 2 ( x) a( x x2 ) b( x x2 ) c 2

41
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
2. The parabola should intersect the three points [xo,
f(xo)], [x1, f(x1)], [x2, f(x2)]. The coefficients of the
polynomial can be estimated by substituting three
points to give
f ( xo ) a ( xo x2 ) 2 b( xo x2 ) c
f ( x1 ) a( x1 x2 ) 2 b( x1 x2 ) c
f ( x2 ) a ( x2 x2 ) 2 b ( x2 x2 ) c
3. Three equations can be solved for three unknowns,
a, b, c. Since two of the terms in the 3rd equation
are zero, it can be immediately solved for c=f(x2).
f ( xo ) f ( x2 ) a( xo x2 ) 2 b( xo x2 )
f ( x1 ) f ( x2 ) a( x1 x2 ) 2 b( x1 x2 )
42
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
If
h o x1 - x o h1 x 2 - x1
f ( x1 ) f ( xo ) f ( x2 ) f ( x1 )
o 1
x1 xo x2 x1
(ho h1 )b (ho h1 ) 2 a ho o h11
Solved for a
h1b h a h11
1
2
and b

1 o
a b ah1 1 c f ( x2 )
h1 ho

43
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Roots can be found by applying an alternative form of
quadratic formula:
2c
x3 x2
b b 4ac 2

The error can be calculated as

x3 x2
ea 100%
x3
term yields two roots, the sign is chosen to agree with b. This
will result in a largest denominator, and will give root estimate
that is closest to x2.
44
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Once x3 is determined, the process is
repeated using the following guidelines:
1. If only real roots are being located, choose the
two original points that are nearest the new root
estimate, x3.
2. If both real and complex roots are estimated,
employ a sequential approach just like in secant
method, x1, x2, and x3 to replace xo, x1, and x2.

45
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Bairstows Method
Bairstows method is an iterative approach loosely
related to both Mller and Newton Raphson methods.
It is based on dividing a polynomial by a factor x-t:
f n ( x) ao a1 x a2 x 2 an x n
f n 1 ( x) b1 b2 x b3 x 2 bn x n
with a reminder R b o , the coefficien ts are
calculated by recurrence relationsh ip
bn an
bi a i bi 1t i n 1 to 2
46
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
To permit the evaluation of complex roots, Bairstows
method divides the polynomial by a quadratic factor
x2-rx-s:
f n 2 ( x) b2 b3 x bn 1 x n 3 bn x n 2
R b1 ( x r ) bo
Using a simple recurrence relationsh ip
bn an
bn-1 an-1 rbn
bi ai rbi 1 sbi 2 i n-2 to 0

47
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
For the remainder to be zero, bo and b1 must be
zero. However, it is unlikely that our initial
guesses at the values of r and s will lead to this
result, a systematic approach can be used to
modify our guesses so that bo and b1 approach
to zero.

Using a similar approach to Newton Raphson


method, both bo and b1 can be expanded as
function of both r and s in Taylor series.

48
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
b1 b1
b1 (r r , s s ) b1 r s
r s
bo bo
bo (r r , s s ) bo r s
r s
assuming that the initial guesses are adequately
close to the values of r and s at roots. The changes
in s and r needed to improve our guesses will be
estimated as
b1 b1
r s b1
r s
bo bo
r s bo
r s
49
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
If partial derivatives of the bs can be determined,
then the two equations can be solved simultaneously
for the two unknowns r and b.
Partial derivatives can be obtained by a synthetic
division of the bs in a similar fashion the bs
themselves are derived:
cn bn
cn 1 bn 1 rcn
ci bi rci 1 sci 2 i n 2 to 2
where
bo bo b1 b1
c1 c2 c3
r s r s
50
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Then
c2 r c3s b1 Solved for r and s, in
turn are employed to
c1r c2 s bo improve the initial guesses.

At each step the error can be estimated as


r
e a ,r 100%
r
r
e a,s 100%
r
51
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The values of the roots are determined by

r r 2 4s
x
2
At this point three possibilities exist:
1. The quotient is a third-order polynomial or greater. The
previous values of r and s serve as initial guesses and
Bairstows method is applied to the quotient to evaluate
new r and s values.
2. The quotient is quadratic. The remaining two roots are
evaluated directly, using the above eqn.
3. The quotient is a 1st order polynomial. The remaining
single root can be evaluated simply as x=-s/r.
Refer to Tables pt2.3 and pt2.4 52
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Anda mungkin juga menyukai