Thompson - Computing for Scientists and Engineers (523188), страница 16
Текст из файла (страница 16)
By writing(3.41)and taking logs of this product, we can repeat the above analysis to obtain(3.42)Exercise 3.22To verify the improved convergence of this expansion, which is about x = arather than about x = 1, choose a = 0.5 and write a small program to calculatethe series to, say, 4 terms. For x in the range 0 to 1, compare the series valueswith the function values, as shown by the dotted curve in Figure 3.4.
Whydoes the series expansion rapidly become a poor approximation as x increasesfrom x = a? n76POWER SERIES3.3 THE BINOMIAL APPROXIMATIONIn analysis and numerics there are many problems that can be greatly simplified ifthey can be approximated by a linear dependence on the variable of interest. Oneway to produce such a linear dependence is to use the binomial approximation,which we now discuss.
Skillful application of this approximation will often producean orderly solution from an otherwise chaotic problem.We first derive the binomial approximation, then we give several applications ofit and show its connection to exponentials and to problems of compounding interest.Deriving the binomial approximationSuppose that we need to estimate ( a + b)D, where | b/a | << 1 and aD is known.If D is an integer, this is no problem because for positive D we can use the binomialexpansion in terms of combinatorials and powers of a and b.
When D is a negativeinteger it may be sufficient to use the binomial expansion with ID I, then to take thereciprocal of the result. But what if D is an arbitrary quantity: how can one reasonably proceed?The binomial approximation is designed to answer such a question. First, wecast the problem in a simplified form by noting that(3.43)If a and b represent quantities with units, these units must be the same, otherwiseone is adding apples to bananas. Given this condition, x is dimensionless, so its addition to a pure number (unity) is allowed.
Knowing aD in (3.43), it is sufficient toconsider approximating the function (1 + x) D . We do this by devolving the Maclaurin series for this function.Exercise 3.23Calculate the successive derivatives of the function, then evaluate them at x = 0in order to show that(3.44)in which the series terminates after D terms if D is a positive integer. nThe binomial approximation is that(3.45)Thus we have approximated a result that usually depends nonlinearly on x by onethat has a linear dependence, which often leads to much simpler solutions.3.3 THE BINOMIAL APPROXIMATION77FIGURE 3.5 Geometric representation of the binomial approximation, shown for D = 2.A geometrical viewpoint is appropriate to clarify the interpretation of the binomial approximation.
Suppose that in the function to be expanded we have D = 2 and| x | << 1, thus satisfying the condition in (3.45). We can represent the function in aplane (such as a page of this book) by drawing two squares, one with sides oflength unity and the other with side length 1 + x, as shown in Figure 3.5.The two lightly shaded rectangles in Figure 3.5 are additional contributions proportional to x, and are therefore included in the binomial approximation that( 1 + x )2 1 + 2x for D = 2.
The heavily-shaded square is the ignored part, justequal to x2. Clearly this geometric correspondence can readily be generalized.Exercise 3.24(a) For practice, sketch the diagrams for the geometric interpretation of the binomial approximation when D = 0, 1, and 3. Indicate which parts are includedand ignored in the approximation,(b) (Challenge part) Since the interpretation is clear for the above D values,make a sketch for intermediate values of D, such as D = 1.5 and D = 2.5, aswell as for the larger value D = 4.
■Because this is a geometric representation, we may think of D as the dimension ofthe binomial approximation exponent. The example of D = 4, the fourth dimension, may be explored by the interested reader in the introductory-level book byRucker.78POWER SERIESApplications of the binomial approximationTo illustrate the power of the binomial approximation for numerical work, so muchpower that you can amaze your friends with your arithmetic skills, try the followingnumerical examples.Exercise 3.25(a) Show that the error in estimating 1.0110 by the binomial approximation isonly of order 5 parts in 1,000.(b) Approximate 2.01-3 by first removing the known factor of 2-3 = 0.125,then using (3.45) for the remaining factor.
Show that the fractional error fromusing the binomial approximation is only about 10-4.(c) Estimate by the binomial approximation, then compare with the exact valuesthe ratio of 2001D to 2000D for D = 1, 5, 137, l/137, 622, and 1066. (Forthe choice of the last three values, consult books on quantum mechanics, on Islamic history, and on English history, respectively.) nWith this introduction to the binomial approximation, you should be convincedof its numerical power.
It is also used analytically in Chapters 4, 7, and 8 when wedevelop numerical approximation methods for derivatives, integrals, and the solutionof differential equations.Linearized square-root approximationsMany scientific calculations involve computation of square roots, for example in distance calculations in two and three dimensions. Such calculations are often part of aquite approximate calculation, for example, the distance between two molecules in aMonte Carlo simulation of random motions in a gas or a distance in a computergraphics display. So one can save computer time by making a linearized approximation to the square root. We first discuss the binomial approximation for thesquare root, then we explore other linear estimates.Suppose that we have a base distance of unit length and that we want distances,D (x), given by(3.46)where xm is the maximum displacement from unity.
A linearized approximation toD that is exact at x = 0 is of the form(3.47)in which the value of a depends on the linear approximation devised. The binomialapproximation uses, according to (3.45),(3.48)3.3 THE BINOMIAL APPROXIMATION79FIGURE 3.6 The errors in various linear approximations to the square root.Other linear approximations can be devised. One might choose to force the approximation to be exact at the midpoint of the interval [0, xm ] or at the upper end ofthis interval.Exercise 3.26(a) Prove that if the square-root approximation is to be exact at the midpointx m /2, then the coefficient in (3.47) must be chosen as(3.49)(b) Show that if the square-root approximation is to be exact at the endpoint xm,then the coefficient in (3.47) must be chosen as(3.50)(c) Choose xm = 0.1 (about a 5% variation of distances) and calculate the exactdistance, then its binomial, midpoint, and endpoint linear approximations.
Dothis for x values between 0 and 0.1. Calculate the errors as exact distance minusapproximate distance. Compare your results with Figure 3.6. nFigure 3.6 shows the errors in the various approximations for xm = 0.1. Notice that, among these three approximations, the endpoint approximation probablydoes the best job of minimizing the error, except that the error is always such that theapproximation systematically underestimates the distance, which may not be desirable.
The midpoint approximation does not have this latter defect, but it deviatesstrongly (rather like the much poorer binomial approximation) toward the endpoint.80POWER SERIESCan one make a optimum linear approximation in the least-squares sense of minimizing the averaged squared deviation between the exact and approximated values?Although we justify the least-squares criterion more completely in Chapter 6, thefollowing analysis shows its effectiveness in constraining parameters.Exercise 3.27Consider the mean-square error, MSE, in fitting a linear approximation to asquare root, defined as(3.51)Differentiate MSE with respect to the parameter a and set this derivative to zerofor the optimum value a = amS.
Next, approximate the square root under the integrand by its first three terms in powers of X. Evaluate the indicated integrals inorder to show that the value of a is then given by(3.52)which is shown for xm = 0.1 in Figure 3.6. nNotice how the least-squares optimization of the linear approximation provides tighter bounds on the errors than do the other methods. For example, with xm = 0.1(as in Figure 3.6) the error in this approximation for the distance is never more than4about 2 parts in 10 . In Monte Carlo simulations one frequently needs the distancebetween two points in a calculation involving square roots. Linearized approximations such as those derived here may be sufficiently accurate for such a simulation,while greatly speeding up program execution.
If larger inaccuracies are acceptable,then faster approximations can be devised, as explained in Paeth’s article and implementation in C code.From this example of optimizing a linear approximation to calculation of squareroots and distances we have seen that a variety of realistic approximations is possible. We have also gained valuable practice in analyzing numerical methods.Financial interest schemesThe crass economics of various schemes for calculating interest due in financingmight seem to be of little relevance to binomial approximations, and probably notworth the attention of scientists. When that scientist par excellence, Isaac Newton,was Keeper of the Mint of England, he was the first to pose and solve the problemof exponential interest, and he used his newly-invented method of the differentialcalculus to do so. Therefore, let us look at financial interest schemes and their connection to series and the binomial approximation.Consider an interest rate r, usually quoted as an annual percentage rate (APR)paid on the principal.
Thus, if the time for interest repayment, t, is in years, thenafter this time the fraction of the principal that is due is 1 + rt, and the interest frac-3.3 THE BINOMIAL APPROXIMATION81tion is this minus unity. Such a form of interest payment is denoted simple interest.Thus, the simple-interest payment after time t, I1 (t), is given by(3.53)Such an interest payment is applied at the end of each year, rather than continuously.Suppose that the interest is paid n times a year on the amount held during theprevious n th of one year. For n > 1 this is called compound interest. For example, quarterly compound interest has n = 4. The interest payment after t years isIn (t), given by(3.54)Figure 3.7 shows simple interest and quarterly-compounded interest for a 20%interest rate, r = 0.2. The difference is insignificant after one year, but at the end oftwo years about 15% more has been paid in compound interest.FIGURE 3.7 Simple interest (long dashes), quarterly interest (short dashes), and exponential interest (solid curve) for an interest rate of 20%.Exercise 3.28(a) Expand (3.54) in a Maclaurin series in the variable rt/n.
Show thatThus show that the extra fraction by which interest paid n times annually has accumulated to after t years compared with simple interest is(3.56)(b) Use the binomial approximation to show that to this order of approximationthere is no difference between compound interest and simple interest. n82POWER SERIESWhat happens as one increases the frequency of payments until at any instantone has interest payment proportional to the amount currently held? That is, in(3.54) we allow n to become very large.Exercise 3.29(a) Continue the Maclaurin expansion begun in Exercise 3.28 (a).
Consider itslimit for very large n, so large that n (n - 1)/n2 1, and similarly for higherpowers of rt. Thus show that(3.57)in which the second equality comes from the Maclaurin expansion of the exponential, which is given by (3.18). Thus the interest scheme becomes exponentialinterest.(b) As a more abstract way of getting to the same result, consider the function(3.58)Show that this function has the derivative property(3.59)for any positive integer n. This is a property of the exponential function. Also,the solution of a first-order linear differential equation is unique once the value ata single point (here at x = 0) is specified. Argue that we must therefore have(3.60)which again produces the result (3.57).(c) From the results of either of the last two parts of this exercise show that exponential interest, Ie ( t ), is given by(3.61)(d) By using the first three terms of the expansion of the exponential functionwith variable rt, show that exponential interest payments exceed those of simpleinterest by a fraction of about rt/2.