• No se han encontrado resultados

Cómo conseguir que no te paguen

In document Rompe la barrera del no (página 177-183)

for given y. We have to expect numerical difficulties solving for x(y) when g = e-l because the curve has a horizontal tangent then.

If we were solving this equation for a given γ as an isolated problem, a good way to proceed would be to use Zero. Because the code converges very quickly from poor guesses, we might try a “large” interval so as to increase the chance of locating the root that is larger than 1. We might, for example, choose [B,C] = [1, l000]. This presents no difficulty for the code, but makes a point raised in Chapter 1. The function exp(-x ) underflows for x as large as 1000, causing problems with some operating systems. Davis solves for x when y = 1. It is a matter of a few minute’s work to alter the example code provided with Zero to solve this problem using a system that deals with underflows by setting them to 0. With a relative error tolerance of 10-6 and an absolute error tolerance of 10-8, only 15 evaluations of the function were needed to compute the root x 4.24960. With this value of y, the constant 0.060641. The code reports the residual of the approximate root to be r 8 × 10-9. This is a situation illuminated by backward error analysis: the computed root is the exact root of f(x) = γ + r, a problem very close to the one posed. Here we see that the x coordinate computed by Zero is the exact value for a slightly different y coordinate.

When computing a trajectory, we are solving a sequence of problems, indeed, more than a hundred in generating the figure. The first derivative is readily available, the roots are simple, and a good initial guess is available. The circumstances suggest that writing a code based on Newton’s method would be worth the trouble. Before discussing the computation of the trajectory, let’s do a couple of experiments with Newton’s method. First we compute the smaller root when y = 1. Recall that when solving F(x) = f(x) - γ = 0, the method is

Because the method is quadratically convergent for these simple roots, the difference between successive iterates provides a convenient and reliable way to test for conver- gence. Of course, for this test to work it is necessary that the iterate be close enough to the root that the method really is converging quadratically fast and not so close that finite precision corrupts the estimate. Because γ is relatively small in this case, we can compute an accurate value for x using the series to see how well the procedure works. With x0 = γ, the table shows that convergence appears to be quadratic right from the start and the estimated error is quite close to the true error, except at limiting precision. (It is quite possible that the root computed in this manner is more accurate than the ref- erence value computed with the series.) Because there is a natural measure of scale provided by the constant γ, the small residual tells us that after only a few iterations, we have a very accurate solution in the sense of backward error analysis.

This is what we expect of Newton’s method, but things do not always go so well. Suppose now that we try to compute the larger root starting with a guess of 8. In order to measure the error, we computed the root accurately in a preliminary computation. The first difficulty we encountered is that the method does not converge to this root. Remember that we can expect convergence to the root nearest the guess only when the guess is “sufficiently close.” The error reported in the table is the difference between the iterate and an accurate value for the smaller root.

As the residual makes clear, we went from a reasonable initial guess to approximations that are terrible in the sense of backward error analysis. This kind of thing did not happen with Zero, even though it was given much worse guesses, because of the way it combines the secant rule and bisection. All goes well near the root, but convergence is very slow when an iterate is large and negative. Indeed, the estimated error is the change in the iterate and the table shows it to be nearly constant then. This is easy to see analytically from

Examination of the sizes of the terms when xi << - 1 shows that the change is approx- imately xi/(1 - xi). This can be further approximated as 1, agreeing as well as might

be expected with the values 0.94 seen in the table. These approximations make it clear that if we should turn up an approximation xi << - 1, the iterates are going to increase slowly to the positive roots.

Davis used this algebraic approach only for computing a couple of points on the trajectory. If we want to compute the closed trajectory of the figure, we need to do con- tinuation efficiently and deal with the fact that the differential equation for the phase is singular when x = 1. First let’s look for a moment at the solution of x exp( -x) = γ for a sequence of values γ. Suppose we have found a root x corresponding to a given γ and want to compute a root corresponding to γ + δ for some “small” δ. One possibility for an initial guess is simply x. Often this works well enough, but for this equation a short calculation shows that

REFERENCES 167

problem that shows up here when x = 1. This is the kind of difficulty that we overcome when tracing a trajectory by exploiting additional information at our disposal.

The program that computed the figure accepts the constants a, c and the initial point (x,y). Using these data, it computes the constant K. The conservation law allows us to solve for x when y is given, or to solve for y when x is given, and the code selects the more appropriate at each step. The differential equations for the populations tell us that for a small increment δ in t, the change in x is about δdx/dt and the change in y is about δdy/dt. If |dy/dt| < |dx/dt|, the code uses the value x + δdx/dt and solves for y(x). Otherwise, it uses the value y + δdy/dt and solves for x(y). This amounts to changing the coordinate system in which the curve is viewed so as to avoid difficulties with vertical tangents. After choosing which equation to solve, Newton’s method is easily applied and converges very rapidly. Superlinear convergence is used to test for convergence to a specified relative error tolerance.

REFERENCES

1. R. Borrelli and C. Coleman, Differential Equations: A Modeling Approach, Prentice Hall, En- glewood Cliffs, N.J., 1987.

2. W. Boyce and R. DiPrima, Elementary Differential Equations and Boundary Value Problems, Wiley, New York, 1992.

3. R. Brent, Algorithms for Minimization without Derivatives, Prentice Hall, Englewood Cliffs, N.J., 1973.

4. P. David and J. Voge, Propagation of Waves, Pergamon Press, New York, 1969.

5. H. Davis, Introduction to Nonlinear Differential and Integral Equations, Dover, New York, 1962.

6. T. Dekker, “Finding a zero by means of successive linear interpolation,” in Constructive Aspects

of the Fundamental Theorem of Algebra, B. Dejon and P. Henrici, eds., Wiley, London, 1969.

7. J. Dennis, Jr., and R. Schnabel, Numerical Methods for Unconstrained Optimization and Non-

linear Equations, Prentice Hall, Englewood Cliffs, N.J., 1983.

8. J. Eberhardt and T. Sweet, ‘The numerical solution of equations in chemistry,” J. Chem. Ed., 37 (1960), pp. 422-430.

9. S. Timoshenko, Theory of Elastic Stability, McGraw Hill, New York, 1961.

10. L. Vant-Hull and A. Hildebrandt, “Solar thermal power systems based on optical transmission,”

Solar Energy, 18 (1976), pp. 3l-40.

11. J. Wilkinson, Rounding Errors in Algebraic Processes, Dover, Mineola, N.Y., 1994. 12. G.M. Wing, An Introduction to Transport Theory, Wiley, New York, 1962.

MISCELLANEOUS EXERCISES FOR CHAPTER 4

4.27 A semi-infinite medium is at a uniform initial tem- perature T0 = 70°F. For time t > 0, a constant heat

flux density q = 300 Btu/hr sq ft is maintained on the surface x = 0. Knowing the thermal conductivity k = 1.0 Btu/hr/ft/°F and the thermal diffusivity α = 0.04

sq ft/hr, the resulting temperature T(x, t) is given by

where

is the error function. Find the times t required for the temperature at distances x = 0.1, 0.2, . . . ,0.5 to reach a preassigned value T = 100°F. Use ABSERR = 10-8 and RELERR = 10-6. The function erf(y) is available in many FORTRAN and some C and C++ libraries. 4.28 Write a code like Zero based upon bisection and New-

ton’s method. Are there advantages to using Newton’s method instead of the secant rule?

4.29 Modify Zero so as to input f´(x) along with f(x). The code is to compute roots via the function u(x) =

f(x)/f´(x) as described in the text. This makes the

modified code faster for multiple roots and permits the computation of roots of even multiplicity.

4.30 Given

devise an algorithm using the codes Zero and Fac- tor/Solve to solve for x1, x2, x3 and θ. Sketch a pro-

gram in FORTRAN or C or C++ to implement your scheme. Do not worry about input/output nor an ini- tial bracket, but do define F(x) carefully.

4.31 In parts (a) and (b) below, error bounds are derived for an approximate root σ (real or complex) of the poly- nomial equation

In each case we require an accurate value of P(σ). Since root solvers may make this residual about as small as possible in the working precision, it is nec-

Show that

a0 = (-1) n

r1r2···rn

and then that

This implies that

which says that there is some zero that is approxi- mated with a relative error of no more than

This bound is very pessimistic when σ approximates well a zero that is much larger than some other zero. To understand this assertion, work out a numerical ex- ample for a quadratic with σ r1 and |r1| >> |r2|.

Then argue that the assertion is true in general. (b) Show that

by differentiating ln P(x). This then implies that

and

This is an absolute error bound, but we get the follow- ing relative error bound easily:

How is this error bound related to the error estimate derived for Newton’s method?

essary to compute P(σ) in higher precision. Let 4.32 The book [4, p. 65] contains a cubic equation for a pa-

r1,r2. . . , rn be the roots of P(x) = 0. rameter s in the context of corrections for the earth’s

(a) The theory of equations tells us that P(x) can be curvature in the interference zone. The equation factored in the form

MISCELLANEOUS EXERCISES 169 depends on two parameters, u and v, which are ob-

tamed from the heights of the towers, the distance be- tween stations, and the radius of the earth. Represen- tative values are v = 1/291, u = 30. The smallest pos- itive root is the one of interest, but calculate them all.

The residuals of the larger roots are quite large. Are they inaccurate? Compare with Exercise 4.1. Use the computable error bounds of Exercise 4.31 to bound the errors of the roots.

In document Rompe la barrera del no (página 177-183)