Chapter 1 Solution of nonlinear equations

advertisement
Chapter 1
Solution of nonlinear equations
This chapter is devoted the problem of locating roots of equations (or zeros functions). The
problem occurs frequently in scientific work. In this chapter, we are interested in solving
nonlinear equation, finding x such that f (x) = 0 .
The general problem, posed in the simplest case of a real-value function of a real variable, is
this: Given a function f : R ® R , find the values of x for which f (x) = 0 . We shall
consider several standard procedures for solving this problem.
Examples of nonlinear equations can be found in many applications. In the theory of
diffraction of light, we need the roots of the equation x - tan x = 0 . In the calculation of
planetary orbits, we need the roots of Kepler’s equation x - asin x = b for various values
of a and b .
Since locating the zeroes of functions has been an active area of study for several hundred
years, numerous methods have been developed. In this chapter, we begin with three simple
methods that are quite useful: the bisection method, Fixed-point method, Newton’s method
and the Secant method.
1.1 Bisection Method
If
f (x) is a continuous function on the interval [a, b] and if f (a) f (b) < 0 , then f (x) must
have a zero in
(a,b) . Since f (a) f (b) < 0, the function f changes sign on the interval [a, b]
and therefore, it has at least one zero in the interval. This is a consequence of the
Intermediate-Value Theorem.
Theorem (Intermediate-Value Theorem) Let
f (x) be a continuous function on the interval
[a,b], Then f (x) realizes every value between f (a) and f (b). More precisely, if y is a
number between
f (a) and f (b), then there exists a number c with a £ c £ b such that
f (c) = y
1
Theorem 1.2 Let f (x) be a continuous function on [a,b] , satisfying f (a) f (b) . Then
f (x) has a root between a and b , there exists a number r satisfying a < r < b and
f (r) = 0 .
The bisection method exploits this idea in the following way. If
f (a) f (b) < 0,
then we compute
1
c = (a + b) ,
2
and test whether f (a) f (c) < 0 . If this is true, the f (x) has zero in [a,c] . So we start again
with the new interval
[a,c] , which is half as large as the original interval. If
f (a) f (c) > 0 .
Then
f (c) f (b) < 0 .
In this case we restart with the new interval [c,b] . In either case, a new interval containing a
zero of f has been produced, and the process can be repeated. Bisection method finds one zero but
not all the zeros in the interval [a,b]. Of course, if
f (a) f (b) = 0 ,
then
f (c) = 0 ,
and a zero has been found. However it is quite unlikely that
f (c) is exactly 0 in the computer
because of round off errors. Thus, the stop criterion should not be whether
A reasonable tolerance must be allowed, such as
f (c) = 0
| f (c) |< 10-5 . Bisection method is also known
as the method of interval having .
Example Use the bisection method to find the root of the equation
Solution. If the graphs of e
x
ex = sin x
closest to 0 .
and sinx are roughly plotted, it becomes clear that there are no
positive roots of
f (x) = ex - sin x
2
and that the first root to the left of 0 is in the interval [-4,-3]. When the bisection algorithm was
run on a machine similar to the marc-32, the following output was produced, starting with the
interval (-4,-3).
R
c
f(c)
1
-3.500
-0.321
2
-3.2500
-0.694 ´ 10-1
3
-3.12500
-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
Bisection Method
Given initial interval
While
[a,b] such that f (a) f (b) < 0
b-a
< TOL
2
c = (a + b) / 2
if
f (c) = 0 ,
stop
end if
if
f (a) f (c) < 0
b = c;
else
a=c
end if
end while
3
Error Analysis (How accurate and how fast)
To analyze the bisection method, let us write the successive intervals that arise in the process
[ a0 ,b0 ],
[a1 ,b1 ] and so on. Here are some observations about these numbers.
a0 £ a1 £ a2 £
£ b0
b0 ³ b1 ³ b2 ³
³ a0
1
bn+1 - an+1 = (bn - an ) ( n ³ 0 )
2
Since the sequence
[an ] is non-decreasing and bounded above, it converse. Likewise, [bn ]
converges. If we apply equation (1) repeatedly, we find that
bn - an = 2- n (b0 - a0 ) ,
lim bn - lim an = lim 2- n (b0 - a0 ) = 0
Thus ,
n®¥
n®¥
n®¥
If we put r = lim an = lim bn , then, by taking a limit in the inequality
n®¥
obtain
n®¥
0 ³ f (an ) × f (bn ) , we
0 ³ [ f (r)]2 where f (r) = 0 .
Suppose that, at a certain stage in the process, the interval [a, b] has just been defined. If the
process in now stopped, the root is certain to lie in this interval. The best estimate of the root at
this stage is not an or bn but the midpoint of the interval
The error is then bounded as follows | r - cn |£
bn - an
2
cn = (bn + an ) / 2.
= 2-( n+1) (b0 - a0 ) .
Summarizing this discussion, we have the following theorem on the bisection method
Theorem
[a0 ,b0 ],[a1 ,b1 ], [an ,bn ],
(Theorem on Bisection Method) If
denote the
intervals in the bisection method, then the limits lim an and lim bn exist, equal and represent
n®¥
a zero of f. If r = lim cn and cn =
n®¥
bn - an
2
, then
n®¥
| r - cn |£ 2-(n+1) (b0 - a0 ) .
4
Example Suppose that the bisection method is started with the interval [50,63], how many steps
should be taken to compute a root with relative error accuracy of on root in
10-12 .
Practical considerations
First, the midpoint c is computed as
¬ a + (b - a) / 2
rather than as
c ¬ (a + b) / 2
To adhere to the general stratagem that in numerical calculation, it is best to compute a quantity by
adding a small correction to a previous approximation. Forsythe, Malcolm, and Moler [1977]
present an example in which the midpoint
(a + b) / 2 moves outside of the interval [a,b] on
a machine with limited precision.
Second, it is better to determine whether the function changes sign over the interval using
sign( f (a)) ¹ sign( f (b))
Rather than
f (a) f (b) < 0
Since the lather requires an unnecessary multiplication and could cause an underflow or overflow.
Finally, notice that three stopping criteria are presented in the following algorithm. First, M
gives the maximum number of steps that the user permits. Such a safeguard should always be
present to reduce the possibility of the computation going into an infinite loop. Next, the
calculation can be stopped when either the error is small or the value of
f (c) is small enough.
5
The Parameter d and w control this. Example can be easily given in which one of the latter
two stopping criteria is satisfied but the other is not. We choose to stop the algorithm when any
one of the three stop criteria is established in the interest of having a robust code.
Function [a,b,u,v]=bisection (fun , a, b, M,
u=feval(fun ,a);
v=feval(fun ,b);
e=b-a;
d, e)
if (sign (u)>0 & sign(v)>0) || (sign (u)<0 & sign(v)<0)
return ;
end
for k=1:M
e=e/2;
c=a+e ;
w =feval (fun ,c);
if (|e|< d || w< e )
return
enf
if (sign( w ) = = sign(u))
a=c ;
u= w
else
b=c;
v= w
end
end
6
Download