5 Chapter 3

advertisement
CHAPTER III : THE SOLUTION OF NONLINEAR EQUATIONS
One of the frequently occurring problems in scientific work is to find the roots
of equations of the form f(x) = 0, i.e. zeros of the function f(x).
The function f(x) may be given explicitly, for example, a polynomial in x or as
a transcendental function.
Polynomials are a simple class of algebraic functions that are represented
generally by
fn ( x )  a0  a1x  a2 x 2  ...  an x n
Example : f2 ( x )  1  2.5 x  3.6 x 2
A transcendental function is one that is nonalgebraic. These include
trigonometric, exponential, logarithmic, and other less familiar functions.
Example:
f(x) = In x2 + 3
We learned to use quadratic formula
x
 b  b 2  4ac
2a
(*)
to solve f(x) = ax2 +bx +c = 0.
Although the quadratic formula is handly for solving Eq (*), there are many
other functions for which the root cannot be determined so easily. For these
cases, the numerical methods are used to obtain the answers.
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
3.1
21
Bisection method ...............................................................................
In general, if f(x) is real and continuous in the interval from xa to xb and f(xa)
and f(xb) have opposite signs, that is
f(xa)f(xb) < 0
then there is at least one real root between xa and xb.
The bisection method, which is alternatively called binary chopping, interval
halving, or Bolzano’s method, is one type of incremental search method in
which the interval is always divided into half. If a function changes sign
over an interval, the function value at the midpoint is evaluated. The location
of the root is then determined as lying at the midpoint of the subinterval
within which the sign change occurs. The process is repeated to obtain
refined estimates.
Step 1:
Choose lower xa and upper xb guesses for the root such that
the function f(x) changes sign over the interval. This can be
checked by ensuring that f(xa)f(xb) < 0.
Step 2:
An estimate of the root xm is determined by
x  xb
xm  a
2
Step 3:
Make the following evaluations to determine in which
subinterval the root lies:
(a)
If f(xa)f(xm) < 0, the root lies in the lower subinterval.
Therefore, set xb = xm and return to step 2.
(b)
If f(xa)f(xm) > 0, the root lies in the upper subinterval.
Therefore, set xa = xm and return to step 2.
(c)
If f(xa)f(xm) = 0, the root equals xm ; terminate the
computation.
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
22
To be more precise in our definition, suppose that we are given an interval
[xa, xb] satisfying f(x) = 0 and an error tolerance  >0. If | xb - xm |  , then
accept xm as the root and stop the calculation.
y
f(x)
root
xa
x
xm
xb
Figure 3.1: Root is between lower bound xa and upper bound xb
y
f(x)
root
xa
xm
x
xb
Figure 3.2: f(xa)f(xm) < 0, the root lies in the lower subinterval.
Therefore, set xb = xm
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
y
23
f(x)
root
x
xa
xm
xb
Figure 3.3: f(xa)f(xm) > 0 , the root lies in the upper subinterval.
Therefore, set xa = xm
Example:
Use the bisection method to find the root of
f (x)  x 6  x  1  0
accurate to within  = 0.001. Given that xa = 1 and xb = 2.
n
xa
xb
xm
f(xa)
f(xm)
xb  xm
1
1.0000
2.0000
1.5000
-1
8.8906
0.5000
2
1.0000
1.5000
1.2500
-1
1.5647
0.2500
3
1.0000
1.2500
1.1250
-1
-0.0977
0.1250
4
1.1250
1.2500
1.1875
-0.0977
0.6167
0.0625
5
1.1250
1.1875
1.1562
-0.0977
0.2333
0.0312
6
1.1250
1.1562
1.1406
-0.0977
0.0616
0.0156
7
1.1250
1.1406
1.1328
-0.0977
-0.0196
0.0078
8
1.1328
1.1406
1.1367
-0.0197
0.0206
0.0039
9
1.1328
1.1367
1.1348
-0.0197
0.0004
0.0020
10
1.1328
1.1348
1.1338
-0.0197
-0.0096
0.0010
 x = 1.1338.
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
24
Example:
Use 3 iterations of the bisection method to determine the root of f(x) =
x3  7.5x2 + 17.75x  13.125. Employ initial guesses of xa = 1.2 and xb =2.
n
1
xa
1.2
xb
2
xm
1.6
f(xa)
0.897
2
1.2
1.6
1.4
0.897
3
1.4
1.6
1.5
0.231
f(xm)
0.171
0.231
0
 x = 1.5
Extra activity:
Use the bisection method to find the root of f ( x )  x 2  x  2  0 accurate to
within  = 0.002. Given that xa = 1,xb = 4.
Answer: x  2.00485  2.005
3.2
Simple fixed-point iteration ..............................................................
In general, a formula is developed for simple fixed-point iteration by
rearrangging the function f(x) = 0 so that x is on the left-hand side of the
equation:
x = g(x)
(**)
This transformation can be accomplished either by algebraic manipulation or
by simply adding x to both sides of the original example.
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
25
Example:
(i)
x 2  2x  3  0
can be simply manipulated to yield
x
(ii)
x2  3
3
or x 
2
x 2
sin x = 0
by adding x to both sides, we get
x = sin x + x
The utility of Eq(**) is that it provides a formula to predict a new value of x as
a function of an old value of x. Thus, given an initial guess at the root xi,
Eq(**) can be used to compute a new estimate xi+1 as expressed by the
iterative formula
xi+1 = g(xi)
Iterations were repeated until ith iteration when xi -xi1<  and so the root of
equation is x*  xi.
If we know that the root x* is in the interval [a,b], then we can set the initial
value, x0, as x0 = a or x0 = b. Otherwise, x0 can be any values.
The selected function g(x) must be always satisfy the condition
 g’(x)<1
so that the fixed-point iteration converges for any x0 in the interval [a,b].
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
26
y
y = g(x0)
y=x
root
x
x2
x1
x0
Figure 3.4:g(x) was used to predict a new value of x as a function
of an old value of x
Example:
Use simple fixed-point iteration to locate the root of f(x) = ex  3x2 = 0
accurate to within  = 0.0001.
We can rewrite the equation as:
x
ex
 g( x )
3x
Assume x0 = 1
i
xi
xi -xi 1
0
1
2
3
4
1.00000
0.90609
0.91037
0.90998
0.91001
0.09391
0.00428
0.00039
0.00003
Thus, each iteration brings the estimate closer to the true value of the root:
0.9100.
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
27
Example:
Employ initial guess of x0 = 1, doing 3 iterations of the simple fixed
point iteration for Inx2 = 0.7.
Then, show that the fixed-point iteration diverges for any x0 in the
interval [0,1].
Rewrite the equation as:
x  x  In x 2  0.7  g( x )
Given x0 = 1
Since g’(x)| = 1 
i
0
1
2
xi
1.0000
0.3000
2.8079
3
1.4430
2
 1 is only satisfied when x < 1, hence the fixed-point
x
iteration diverges for any x0 in the interval [0,1].
Extra activity :
Using the simple fixed-point iteration to find the root of f(x) = e-x  x = 0
accurate to within  = 0.003. Given that the root x* is in the interval [0,1].
Answer: x*  0.5664
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
3.3
28
Newton-Raphson method ................................................................
The Newton-Raphson method uses a straight-line approximation to the
function whose zero we wish to find, in this case the line is tangent to the
curve. The next approximation to the zero is the value of x where the tangent
crosses the x-axis. This requires additional information about the function
(i.e., its derivative).
Given an initial estimate of the zero, x0, the value of the function at x0, y0
=f(x0), and the value of the derivative at x0, y’0 =f’(x0), the x-intercept of the
tangent line, which is the new approximation to the zero, is
f (x0 )
f ' (x0 )
The process continues until the change in the approximations is sufficiently
small or some other condition is satisfied. At the ith stage, we have
x1  x 0 
x i 1  x i 
f (x i )
f ' (xi )
y
x
x0
x1
x2
root
Figure 3.5: The targent to the curve was used to approximate the root
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
29
Example:
Use the Newton-Raphson method to estimate the root of f(x) = 0.9x2 +
1.7x  5 employing an initial guess of x0 = 1 accurate to within  =
0.001.
We have f(x) = 0.9x2 + 1.7x  5 ,
So f’(x) = 1.8x + 1.7
Use the formula
x i 1  x i 
f (x i )
f ' (xi )
xi -xi1
f(xi)
f’(xi)
3.5
1.6857
1.5963
1.5947
0.6857
0.0894
0.0016
2.4
0.4232
0.0072
0.0002
1.5947
0.0000
i
xi
0
1
1
2
3
4
4.7343
4.5734
4.5705
 x  1.5947
Example:
Use the Newton-Raphson method to estimate the root of f(x) = e-x – x
employing an initial guess of x0 = 0 accurate to within  = 0.001.
We have f(x) = e-x –x,
so f’(x) =  e-x –1
i
xi
0
1
2
3
0
0.5
0.566311
0.567143
 x  0.567143
xi -xi1
0.5
0.066311
0.000832
f(xi)
f’(xi)
1
0.106531
0.001305
-2
-1.606531
-1.567616
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
30
Extra activity:
Use the Newton-Raphson method to estimate the root of f(x) = 3x3 + 2x  4
employing an initial guess of x0 = 1 accurate to within  = 0.001.
Answer: x  0.9014
3.4 Root location with MATLAB ………………………………………………...
MATLAB is capable of locating roots of single algebraic and transcendental
equations. We can either use the MATLAB function fzero or solve to find the
roots of the nonlinear equations.
 The fzero function is designed to locate one root of a single function.
x = fzero(inline('f’),x0)
where f is the function you are analyzing, x0 is the initial guess.
Note that one or two guesses can be employed. If two guesses are
employed, they are assumed a bracket a root.
Example:
Locate the root of f(x) = 3xex –1 = 0.
>> x0=1;
>> x=fzero(inline('3*x*exp(x)-1'),x0)
x=
0.2576
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
31
Example:
Find the root of f(x) = x2 –x –2 = 0. Given xa = 1, xb = 4.
>>x0=[1 4];
>> x=fzero(inline('x^2-x-2'),x0)
x=
2
 Activity:
Find the root of f(x) = x6 –x –1 = 0. Given xa=1, xb=2.
Answer : x = 1.1347 .
 If S is a symbolic expression,
solve(S)
attempts to find values of the symbolic variable in S for which S is zero. This
function is most useful for the solving polynomials since it provides
expressions for all roots. In order to use this command, you must have
symbolic math toolbox in your Matlab.
Example:
Locate the root of f(x) = 7xex +2x = 0.
>> syms x
>>f=7*x*exp(x)+2*x;
>>solve (f)
ans =
[
0]
[ log(-2/7)]
 Activity:
Find the root of f(x) = x2 –x –2 = 0.
Answer : x = 2 & x = 1 .
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
32
 Exersice 3:
1. Using the bisection method, find the root of
a.
f (x) = x  cos x in the interval [0 ,

] accurate to within  = 0.005,
2
where x is in radian.
b. f (x) = 3x  ex in the interval [0.25 , 0.27] to a level of  = 0.1%
1. Use the Bisection Method to find solutions accurate to within 10 2 for
a. f ( x)  x 3  7 x 2  14 x  6 in the interval [1,3.2]
b. f ( x) 
x  cos x in the interval [0,1]
3. Use the Bisection Method to find an approximation to
within 10 4 .
3
correct to
[Hint : consider f ( x)  x 2  3 ].
4. Use simple fixed-point iteration to find the root of
a. 5xex = 1 accurate to within  = 0.0001.44)
b. x2 + 5x  3 = 0 accurate to within  = 0.0005.
c.
f ( x)  x  0.8  0.2 sin x accurate to within   0.0001 . Given that
x0  0 . (
48
5. Use the Newton-Raphson method to estimate the root of x2  2x  3 + ex
= 0 employing an initial value guess of x0 = 1 with a value of ,
corresponding to 3 significant figures. 2)
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
33
6. Use the Newton-Raphson method to estimate the root of sin x = x2
employing an
initial value guess of x0 = 1 accurate to within  = 0.001,
where x is in radian.
7. By using Newton-Raphson method accurate to within 10 4 .Use x0  0 to
find the root of
a.
f ( x)  e x  3 x 2
b.
f ( x)  sin x  e  x
8. The flow rate in a pipe system connecting two reservoirs (at different
surface elevations) depends on the characteristics of the pump, the
roughness of the pipe, the length and the diameter of the pipe, and the
specific gravity of the fluid. For an 800 ft section of 6’’ pipe connecting
two reservoirs (with a 5 ft differential in elevation) containing oil of
specific gravity 0.8, with a 6-hp pump. The equation for the flow rate Q is
12Q 3  5Q  40  0
Approximate the real root of the equation in the interval 0  Q  2 .
CHAPTER III: THE SOLUTION MOF NONLINEAR EQUATION
34
9. In studies of solar-energy collection by focusing a field of plane mirrors
on a central collector, one researcher obtained this equation for the
geometrical concentration factor C:
C
 (h / cos A) 2 F
0.5D 2 (1  sin A  0.5 cos A)
where A is the rim angle of the field, F is the fractional coverage of the
field with mirrors, D is the diameter of the collector, and h is the height of
the collector. Find A if h  300 , C  1200 , F  0.8 , and D  14.
10. The upward velocity, v of a rocket can be computed by the following
formula:
 m0 
  gt
v  u ln
 m0  qt 
where u = velocity at which fuel is expelled relative to the rocket, m0 =
initial mass of the rocket at time t = 0, q = fuel consumption rate and
g = downward acceleration of gravity (assumed constant = 9.8 m/s2). If
u  2200 m/s, m0  160000 kg and q  2680 kg/s, use the NewtonRaphson method to determine the time t at which v = 1000 m/s accurate
to within   0.0001 . Employ an initial value guess of x0  20 .
Download