ELEMENTS OF
NUMERICAL ANALYSIS
Academic Press Textbooks in Mathematics Consulting Editor: Ralph P. Boas, Jr., Northwe...
339 downloads
2561 Views
6MB Size
Report
This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
Report copyright / DMCA form
ELEMENTS OF
NUMERICAL ANALYSIS
Academic Press Textbooks in Mathematics Consulting Editor: Ralph P. Boas, Jr., Northwestern University
HOWARD G. TUCKER. An Introduction to Probability and Mathematical Statistics EDUARD l. STIEFEl. An Introduction to Numerical Mathematics WILLIAM PERVIN. Foundations of General Topology JAMES SINGER. Elements of Numerical Analysis PESI MASANI, R. C. PATEL and D. J. PATIl. Elementary Calculus
ELEMENTS OF
NUMERICAL ANALYSIS
James Singer Department of Mathematics Brooklyn College Brooklyn, New York
NEW YORK
ACADEMIC PRESS
LONDON
COPYRIGHT
©
1964,
BY ACADEMIC PRESS INC.
ALL RIGHTS RESERVED. NO PART OF THIS BOOK MAY BE REPRODUCED IN ANY FORM, BY PHOTOSTAT, MICROFILM, OR ANY OTHER MEANS, WITHOUT WRITTEN PERMISSION FROM THE PUBLISHERS.
ACADEMIC PRESS INC.
II Fifth Avenue, New York, New York 10003
United Kingdom Edition published by ACADEMIC PRESS INC. (LONDON) LTD.
Berkeley Square House, London W.I
LIBRARY OF CONGRESS CATALOG CARD NUMBER:
PRINTED IN THE UNITED STATES OF AMERICA
64-18216
To Hand Rand
J
Preface
This book is written with two sets of readers in mind, the practicing scientific worker and the "pure" mathematician. The practicing scientific worker-the chemist, the physicist, the engineer, the economist, anyone who is concerned with the quantitative aspects of the physical, biological, social and applied sciences-knows only too well that much of his effort is directly or indirectly devoted to the determination of numerical results and to the derivation of natural laws, which are nothing but relations between numbers endowed with "dimensions." This book aims to tell him how to obtain a numerical result and how to judge the reliability or trustworthiness of his answer. The scientific worker will find many of the necessary formulas and many special tables to help him in his computations, he will find detailed descriptions of the methods and procedures, he will be aided by many illustrative examples worked out in the text, he will be guided by many remarks, observations, and words of caution. The "pure" mathematician is usually interested, if at all concerned, with the art rather than the practice of computation. This book attempts to give him a .coherent, systematic and, I trust, lucid treatment of the classical or traditional theory of mathematical computation. He will find careful and honest proofs where proofs are given; and he will learn that there is frequently an amazing amount of real mathematics behind a prosaic numerical answer, correct to five decimal places. It is my earnest hope, however, that as far as possible the two sets of readers merge into one. It has always been my contention that the scientific worker interested in a numerical answer would do well to delve into the foundations of his methods, to learn "why" as well as "how"; an understanding of the underlying concepts is a powerful tool when he must cope with new problems or with old problems in new dress. On the other hand, it is my hope that those not now intrigued with computation will nevertheless plunge in to help discover new and better methods and more sound results if for no other reason than the fun of it. For these reasons, the text not only includes set algorithms and tables, but attempts to give the reader some feeling for and insight into the subject so that he will be more than ready to strike out on his own. This book is intended as a first course in numerical computation. It is not geared to electronic computers although it will serve as an introduction for those interested in high speed calculators. The methods and procedures that vii
Vlll
PREFACE
are described can readily be modified, if modifications are needed, for use on electronic computors; but fundamentally, the procedures were intended to be carried out on desk calculators or even longhand. For an understanding of most of the text, the reader will need a good introductory course in calculus; for some portions, some advanced calculus and differential equations will be necessary; for some of the material, not even the calculus is necessary. The references listed at the end of the book are few in number; they have been listed either because they can be used for supplementary reading or because they themselves contain extensive bibliographies. Various tables, not readily found elsewhere, are included in the text, but the serious reader should supply himself with a set of ordinary tables including the usual trigonometric, logarithmic and exponential tables. The reader will find two chapters not usually covered in present day texts, one on geometric methods and nomography and one on curve fitting; he will also find many illustrative examples throughout the text. It is suggested that these be more than read; the reader should also work them out and compare his results with those in the text. In some cases, the examples worked out are merely illustrations of theory or algorithms previously discussed in the text; in some cases, the examples worked out serve as the vehicle for the explanations of new theory or modes of operation. The text can be covered thoroughly in two semesters. Those who desire a faster pace can cover a good portion of it in one semester and finish it in a second semester with further topics such as matrix solutions or partial differential equations that are omitted from this book. A final word addressed to the teacher. The examples, by and large, were intended to be worked out with the aid of desk calculators but if these are not available, the number of required significant figures or decimal places should be cut to prevent prohibitively long calculations. JAMES SINGER
Brooklyn, New York
Contents vii
PREFACE
Chapter 1 1.1
1.2 1.3 1.4 1.5
Chapter 2
Numbers and Errors I
Significant Figures Errors Accuracy and Precision Computational Errors The Inverse Problem
11 18
The Approximating Polynomial; Approximation at a Point
22
6 9
2.1 Introduction 2.2 Representation of a Function by a Polynomial 2.3 Power Series 2.4 Computation with Power Series 2.5 Asymptotic Series; Euler's Summation Formula 2.6 Other Methods of Approximation
Chapter 3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 5.10 3.11 3.12 3.13
Chapter 4
The Approximating Polynomial; Approximation in an Interval
22 24 30 40 47 63 67
Introduction Polynomial through n + I Points; Determinant Form Polynomial through n + I Points; Lagrange Interpolation Formula Polynomial through n + I Points; Divided Difference Form Polynomial through n + I Points; Aitken-Neville Forms Magnitude of the Error in the Polynomial through n + I Points Equally Spaced Points; Finite Differences Polynomial through n + I Equally Spaced Points Extrapolation Subtabulation Nonpolynomial Approximation Additional Methods of Interpolation Inverse Interpolation
67 70 75 77 84 87 97 101 117 118 126 133 135
The Numerical Solution of Algebraic and Transcendental Equations in One Unknown; Geometric Methods
137
4.1 Introduction 4.2 Graphical Methods 4.3 Construction of Scales and Rules 4.4 Stationary Scales 4.5 Sliding Scales 4.6 Nomography 4.7 Nomography, General Theory
ix
137 138 141 148 lSI 154 160
x
CONTENTS
Chapter 5
The Numerical Solution of Algebraic and Transcendental Equations in One Unknown; Arithmetic Methods Horner's Method The Root-Squaring Method The Method of Iteration The Method of False Position (Regula Falsi); The Method of Chords Imaginary Roots
169 169 171 185 192 196
The Numerical Solution of Simultaneous Algebraic and Transcendental Equations
200
5.1 5.2 5.3 5.4
5.5 Chapter 6
6.1 6.2 6.3 6.4 Chapter 7
Introduction The Method of Iteration The Method of Chords Simultaneous Linear Equations
200
Numerical Differentiation and Integration
217
7.1 7.2 7.3 7.4
Introduction Numerical Differentiation in Terms of Finite Differences Numerical Differentiation in Terms of Ordinates Method of Undetermined Coefficients 7.5 Magnitude of the Error in Numerical Differentiation 7.6 Numerical Integration; Introduction 7.7 Numerical Integration in Terms of Finite Differences 7.8 Numerical Integration in Terms of Ordinates 7.9 Magnitude of the Error in Numerical Integration 7.10 Gauss' Formulas. Orthogonal Polynomials Chapter 8
217 223 235
242 246 257
258
269 279 281
The Numerical Solution of Ordinary Differential Equations
294
Statement of the Problem Picard's Method of Successive Approximations Power Series Approximations Pointwise Methods; Introduction Pointwise Methods; Power Series Pointwise Methods; The Runge-Kutta Formulas Pointwise Methods; Finite Differences Pointwise Methods; Iteration Using Ordinates First-Order Systems; Equations of Higher Order; Special Equations
294 299 303 310 311 315 320 330 339
Curve Fitting
351
Introduction The Straight Line Polynomial Graphs Other Graphs Inconsistent Equations
351
8.1 8.2 8.3 8.4 8.5
8.6 8.7 8.8 8.9 Chapter 9
203 209 210
9.1 9.2 9.3 9.4 9.5 BIBLIOGRAPHY ANSWERS
SUBJECT INDEX
352
366 370 375
382 383 393
ELEMENTS OF
NUMERICAL ANALYSIS
Chapter 1
Numbers and Errors
1.1. Significant Figures. In this chapter we develop some of the basic properties of numbers that are peculiar to the science (or art) of computation. The reader will please bear with us if we begin with some very elementary considerations. Numbers used by the scientific worker are usually written in the decimal notation. Let us recall that in this notation the successive places to the left of the decimal point are the unit's, ten's, hundred's, thousand's, ten-thousand's, etc., places and the successive places to the right of the decimal point are the tenth's, hundredth's, thousandth's, ten-thousandth's, etc., places. We use the convention of enumerating the digits of a number written in decimal form from left to right to simplify some of the later definitions; the first digit is then the one on the extreme left and the last digit is the one on the extreme right. The decimal representations of 22/5, 22/7, and 17 are different in character. The first decimal expression terminates or is finite, the second is nonterminating but periodic, the third is non terminating and nonperiodic. Since the scientific worker rarely if ever uses any but the first kind of decimal expression, we too, unless otherwise indicated, shall use only finite or terminating decimals. This implies that frequently a written number is only an approximation to some other number. (We remark that any number, be it 22/5, 22/7, y2, or 17, is exact; it becomes "inexact" or "approximate" only when it is considered as an evaluation or representation of some other number.) We now pave the way to a better understanding of these approximations. DEFINITION 1. The numerical unit of a number written in the decimal notation is the name of the place occupied by the last digit, except in the case of a whole number which terminates in one or more zeros (all to the left of the decimal point). The numerical unit in the exceptional case, if not implied by the context, must be specifically stated and may be either the name of the place occupied by the last nonzero digit or the name of the place occupied by anyone of the zeros to the right of the last nonzero digit.
1. NUMBERS AND ERRORS
2
For example, the numerical units of the numbers 3.04, 0.0700, 67, are hundredth, ten-thousandth, and unit, respectively. The numerical unit of 67,000 may be a thousand, hundred, ten, or unit and if not implied by the text must be explicitly stated. The last illustration indicates that two numbers may be numerically equal but can have different numerical units. We wish to emphasize this point. Consider the numbers 3.04 and 3.040. They are numerically equal but differ in form; the numerical unit of the first is a hundredth; that of the second is a thousandth. It is convenient to extend the concept of a numerical unit. We shall regard it not only as the name of a place in the decimal representation of a number but also as a number which is an appropriate power of 10. Thus, the numerical units a thousandth and a hundred will be represented by the powers 10-3 and 102 , respectively. If the numbers above are written in the forms 3.04 = 304 X 10- 2 ,
= 700
0.0700 67 67,000
=
67
X
103
=
670
=
X
67
102
=
X
X
10-4 , 10°,
6700
X
10
=
67,000
X
100,
the power of lOin each case indicates the numerical unit. In general, any number n can be written in the numerical unit form (1.1:1)
n
=
n'
X
10",
where n' is a whole number and lOu is the numerical unit of n. (We use the notation 1.2:3 to signify that the corresponding formula, equation, or statement is in Chapter I, Section 2, and is numbered third in that section.) It follows, of course, that u, too, is an integer, positive, negative, or zero. If all the digits of a number are zero, as in 0.00, we put n' equal to zero. DEFINITION 2. The significant digits or figures of a number n are the digits in n' when n is written in the numerical unit form. Thus, 3.04, 0.0700, 67, and 0.00 have 3, 3, 2, and I significant digits, respectively. The number 67,000 may have 2, 3, 4, or 5 significant digits depending on the numerical unit. Omitting this exceptional case of an integer that terminates in one or more zeros, the number of significant figures of a number written in the decimal notation is ~e number of its digits excluding all digits that precede the first nonzero digit.
3
1.1. SIGNIFICANT FIGURES
The significant figures of a number are so named because they are the ones that specify the number of numerical units. We call the attention of the reader to another notation often used similar to the numerical unit form. It is frequently used in the printing of tables and in the tabulation of data and is called the scientific or standard notation or form. A number is written in the standard notation as n = nil X 10", (1.1 :2) where nil has the same digits as n' in the numerical unit form but has just one nonzero digit left of the decimal point. Thus, 3.04, 0.0700, and 67 are 3.04 X 10°, 7.00 X 10- 2 , 6.7
X
10,
respectively, in standard notation. The number zero shall be written as 0.00 X lOu in the standard notation. The standard notation is particularly useful for numbers like 0.0000720 or 95,000,000 (where the numerical unit is a million, say) which are written as 7.20 X 10-5 and 9.5 X 107 , respectively. Generally speaking, a number used by a scientific worker arises in one of three ways. It may, first of all, be a "pure" number, that is, one which is the result of a count, or one which is the result of a mathematical or other definition. As examples of pure numbers we have the number (three) of sides of a triangle, the ratio of the circumference to the diameter of a circle, the value of sin 23°, or e- /2 dt, the number of feet in a mile, the number of days in a week, the number of pounds in the maximum load of an elevator. Secondly, there are numbers that arise as values of direct measurements. (By a direct measurement we mean one in which the result is read off some measuring instrument such as the measurement of a distance by a ruler or the measurement of a temperature with a thermometer.) Thirdly, there are numbers that arise as results of computations performed on numbers of the first two types. But, as we know, relatively very few numbers can be written exactly as finite decimals, measurements are at best approximate, and calculations are subject at the very least to all the inaccuracies of the numbers involved. Hence a number used by a scientific worker is usually an approximation to some "true" value. It is therefore important that he should indicate in some fashion the goodness of the approximation, the reliability, or the margin of error of a stated number. This can be done
n
4
1. NUMBERS AND ERRORS
in a variety of ways. He may write 6.040 ± 0.003 to indicate that the correct value is in the range from 6.037 to 6.043, inclusive. Note that if one wants to indicate a margin of error of 0.0003, say, one should not write 6.04 ± 0.0003 but 6.0400 ± 0.0003. The scientific worker will also use 6.04- to indicate that the true value of a number is less than 6.04 but closer to it than to 6.03. Likewise, 6.04+ indicates a true value greater than 6.04 but closer to it than to 6.05. These methods of writing approximate numbers clearly indicate that the numbers are approximate and give the margins of their errors but as matters of notation they are just a bit clumsy. The scientific worker will most frequently write 6.04 with the intent and understanding that this does not represent the number 6.04 exactly but a number which is closer to 6.04 than it is to 6.03 or 6.05. Likewise, 6.040 indicates a number which is closer to 6.040 than it is to 6.039 or 6.041. The last notation determines a number with a margin of error equal to one-half the numerical unit; the preceding notation also determines a number with the same margin of error but also indicates whether the error is one of excess or default. The first notation like the last does not indicate the direction of the error but usually indicates a more precise margin of error. Let us note in passing that the margin of error is closely linked with the numerical unit of the stated number and is, in the last notation, just one-half of that unit. Thus the margin of error in 6.040 is onetenth the margin of error of 6.04. Since the number of significant figuns in a number and the numerical unit of the number are themselves closely related, one must beware of using more significant figures than are warranted in writing a number. Just how many one should use will appear shortly. The following definition will be useful. DEFINITION 3. If a number a with k significant figures is an approximation to a number n and is the best approximation to n of all numbers with k significant figures, then a is said to be correct to k significant figures as an approximation to n. Thus, 3.1, 3.14, 3.142, and 3.1418 are correct to 2, 3, 4, and 5 significant figures, respectively, when considered as approximations to 28/9, {/31, fT, and loglo 1386, respectively. It is desirable for some purposes to "round off" a number which is written in the usual decimal notation with k + m significant figures to one that has only k significant figures. We do this by deleting those of the last m digits that are to the right of the decimal point and substituti'rig zeros for those that are to the left of the decimal point. No further change
1.1. SIGNIFICANT FIGURES
5
is necessary if the m deleted or replaced digits represent less than onehalf unit in the kth place; but if the deleted or replaced digits represent more than one-half unit in the kth place, the kth significant figure is increased by unity. (If the kth significant figure is 9, it changes to 0 and the preceding digit is increased by unity. Note the last illustration in the table below.) If the deleted or replaced digits represent exactly one-half unit in the kth place, usage varies. Some people treat this case like the preceding one and increase the kth digit by unity; others increase the kth digit by unity if it is odd and leave it alone if it is even. The reasoning behind this latter rule is specious; in actual practice, it matters little which system is used. ILLUSTRATIONS
Rounded off to: Number
32.0769 0.856025 123456 1234.56 1.34996 0.999777
5 significant figures
4 significant figures
3 significant figures
2 significant figures
32.077 0.85603 123460 1234.6 1.3500 0.99978
32.08 0.8560 123500 1235 1.350 0.9998
32.1 0.856 123000 1230 1.35 1.00
32 0.86 120000 1200 1.3 1.0
In particular, note that 1.34996 becomes 1.3 when rounded off to two significant figures and 1.35 when rounded off to three significant figures. If, however, we were given 1.35 and told to round it off to two significant figures, the correct answer is 1.4. Many authors write 1.33 to indicate 1.35-; rounded off to two significant figures, this number is 1.3. In brief, to round off a number with k + m significant figures to one with k significant figures is to rewrite it correct to k significant figures as an approximation to its original form. The numbers 3.14209 and 3.14285 are approximations to 1T = 3.14159 .... Neither one is correct to six significant figures. If they are rounded off to five significant digits to 3.1421 and 3.1428 (or 3.1429), respectively, they remain incorrect to five significant digits. But when they are rounded off to four significant digits to 3.142 and 3.143, respectively, the first becomes correct to four significant digits as an approximation to 1T. The latter becomes correct when rounded off to three significant digits. We are thus led to the following extension of Definition 3.
1. NUMBERS AND ERRORS
6
DEFINITION 4. If a number a with k + m significant digits when rounded off to k + 1 significant digits is not correct to k + 1 significant digits as an approximation to a number n but when rounded off to k significant digits is correct to k significant digits, then a is said to be correct to k significant digits as an approximation to n. Thus, 1.33530 is correct to four significant digits when considered as an approximation to sec 41 °30' = 1.3352 and is correct to two significant figures when considered as an approximation to t. Similarly, t expressed as a decimal would be correct to two significant figures as an approximation to sin 19°30' = 0.33381 and to three significant figures as an approximation to vo]TI = 0.33317.
EXERCISE 1.1 1. State the numerical unit of each of the following numbers and write each numerical unit in the form IOu.
a. 436 b. 750.2 c. 2.006 d. 0.05 f. 400.0 I. 0.00000 h. 1.976530 i. 1.000001
e. 0.000050 J. 883.09000. 2. Do the same for each of the following numbers; give all the possibilities if there are several. a. 956000 b. 906000 c. 1000000 d. 1000001 e. 999999 f. 3020010. 1. How many significant digits are there in each of the following numbers? a. 4029 b. 40.29 c. 53.670 d. 0.0002 e. 190 f. 2.000000 I. 2.000006 h. 3.0002 I. 83.10400 J. 0.08040. 4. Write each number in examples 1,2, and 3 in standard notation. 5. Round off each of the following numbers to four significant digits. a. 4.32974 b. 682.548 c. 28.9956 d. 102843.1 e. 0.0765402 f. 8976.49 I. 0.999996 h. 1.35000 I. 407.391 J. 32.1089. 6. Write each of the following numbers correct to four significant digits. a. 22/7 b 'IT c. 100000/3 d. cos O· e. cos 25' f. VO:OOS09 I. {/6~00000685 h. IO! I. 'ITa J. the number of inches in a mile. 7. Write each of the numbers of example 6 correct to the nearest tenth. S. The first number in each of the following pairs is an approximation to the second number. Write each approximation as a decimal if not already so written and state the number of correct significant figures in the approximations. a. 563.201,563.257 b. 0.00632,0.00636 c. 52,000,000,52,475,913 d. 4.732093,4.732102 e. 3800,3826.4 f. V3/IO, sin 10· I. 3/4, log 5.624 h. I, cos 30' I. 19/6, v'W J. {/3.87, 'IT/2.
1.2. Errors. It was pointed out in the last section that for a variety of reasons a number used by a scientific worker is usually an approximation to some true value. We propose to examine these errors a Htth further in this section.
7
1.2. ERRORS
The difference e between a number n and an approximation a to it is defined as the actual error in a; in symbols, e = n - a,
(1.2: 1)
whence (1.2:2)
n
=
a
+ e.
The relative actual error is defined by the statement (1.2:3)
and the per cent relative actual error is defined as 100,%.
(1.2:4)
It is to be noted that for a and n real, e may be positive, negative, or zero, whereas the relative errors are zero or positive only. Thus, the 'actual error committed in approximating 17 by 22/7 is e
= =
22/7
17 -
3.14159265+ - 3.14285714+
= -0.0012645-; the relative actual error is - 0.0012645- _ 000040+' r - 3.14159265+-' ,
and the per cent relative actual error is 0.040+%.
The actual error in approximating e=
= =
17 -
17
by 3.14 is
3.14
3.14159+ - 3.14 0.00159+,
and the relative actual error is - 0.00159+ _ 000050+ r - 3.14159+ - . .
1. NUMBERS AND ERRORS
8
Note that in these two illustrations the actual and relative actual errors can be calculated to as many significant figures as we wish provided that 1T is given with a sufficiently great number of correct significant figures. Let us now imagine that the mem bers of a class read, one by one, a barometer furnished with a vernier scale. Their readings will not be all alike and range, say, from 761.5 to 762.5 mm; let us suppose that it is decided to record the atmospheric pressure as 762 mm. This value, 762 mm, is, of course, an approximation to the true value of the atmospheric pressure and is the a of formula 1.2: 1. However, the true value n is not known and therefore the value of e is not known. The best we can say is that n is between 761.5 and 762.5 and that the actual value of e is at most 0.5. In general, if the true value of a number t is not known but it is known that it differs from an approximation a by an amount which is less than a positive number h, we have (1.2:5)
a- h
~
t
~
a
+ h.
We call h the margin of error or the maximum error of a; the ratio (1.2:6)
m =
I~ I
is called the maximum relative error of a; and (1.2:7)
is called the per cent maximum relative error. Note that the maximum relative error has the approximate number in the denominator whereas the relative actual error has the exact value in the denominator. The approximate number must be used here because the exact value is not known. Some authors use the approximate value in all cases, but it seems more natural to use the exact value when it is known. To illustrate these definitions, suppose that the height of a mountain is given as 6703 ft but is in error by 6 in. or less, that is, the margin of error or the maximum error is 6 in. The true height of the mountain is between 6702.5 and 6703.5 ft; the maximum relative error is approximately 0.0000746 or 0.00746%. Again, suppose the width of a paper is measured as 10.0 in. with the true value so mew heres between 9.95 and 10.05 in. The maximum error is 0.05 inches and the maximum\ relative error is 0.005 or 0.5 %. Thus, the maximum error in the first
1.3. ACCURACY AND PRECISION
9
case is 120 times as great as it is in the second, but the maximum relative error is about (1 /67)th of the maximum relative error in the second case. Let us also recall that whenever we write a number in the decimal notation and the actual error or margin of error is not stated or otherwise implied, it will be assumed that the margin of error is one-half of the numerical unit. EXERCISE 1.2 1. Each pair listed below is a number followed by an approximation; give for each pair the actual error, the relative error, and the per cent relative error. /a. V 2, 1.4 b. e,2.7
c. V150, 49/4 e. {/19700,27 I. inches in a meter, 40
d. 1902 ,36000 f. 1000/909, 1.1 h. tan 9°39', 0.17
J.
millimeters in an inch, 25.
2. What is the maximum error and the maximum relative error in each of the following numbers?
a. 17.03 b. 0.3200 c. 47 d. 8043 e. 9500 i. 1.9 ;. 2. f. 0.00003 g. 8765.1 h. 0.301 3. Find the value of." - tan 72°20.5' correct to three significant figures. 4. Find the numerical difference between (e/2)v'aand (V 2)"/ 2 correct to three significant figures.
1.3. Accuracy and Precision. table.
Consider the entries in the following
Number
Approximation
Actual error
Relative error
."
22/7 76/5 4,100,000
-0.0013-0.0013+ 625
0.0004+ 0.00008+ 0.00015+
------
Vi31 45'
Which is the best approximation? If we compare the first two rows, we would say that 76/5 is a better approximation to V23T than 22/7 is to 1T because their actual errors are about the same and the relative error of 76/5 is only about ith oUhe relative error in 22/7. Also, 76/5 is a better approximation to V231 than 4,100,000 is to 45 4 because its actual and relative errors are smaller than the corresponding errors of 4,100,000. Thus, 76/5 appears to be the best approximation to its true value. Which is the poorest approximation? Here there is legitimate
1. NUMBERS AND ERRORS
10
doubt, for while the actual error in 4,100,000 is much greater than the actual error in 22/7, the relative error is smaller. Since there is no compelling reason to choose one type of error over the other as a criterion of the goodness of an approximation, we adopt two measures for the degree of closeness, precision and accuracy. DEFINITION 1. Of two given approximations to two given numbers, the one with the numerically smaller actual error is called the more precise; and the one with the smaller relative error is called the more accurate. Hence, 22/7 is the most precise of the three approximations above and 4,100,000 is the least precise; 76/5 is the most accurate and 22/7 the least accurate. In the case of measurements or in the case of numbers whose maximum errors are known but whose actual errors are not, we state this rule:
2. Of two given approximations to two numbers of which only the margins of errors are known, the one with the smaller maximum error is called the more precise, the one with the smaller maximum relative error is called the more accurate. In short, precision is gauged by the actual or maximum error while accuracy is gauged by the relative or maximum relative error. Thus, in the illustrations at the very end of the last section, the mountain approximation is the more accurate but the less precise. Also, to give the precision of a result we state the actual or maximum error; to give the accuracy we state the relative or maximum relative error. Let all the significant figures of an approximation a to a number n which is known exactly or to within its margin of error be correct, and let lOu be the numerical unit of a; then the actual error satisfies the condition DEFINITION
(1.3:1)
and the maximum error h satisfies the condition (1.3:2)
h
=
5.10.. - 1 •
Also, the relative error r satisfies the condition (1.3:3)
T
~
5 . 10..- 1
In I
'
and the maximum relative error m is given by (1.3:4)
m=
5 . 10..- 1
Ia I
1.4. COMPUTATIONAL ERRORS
11
which becomes, if we put a
=
(1.3:5)
m =
a' . lOu, 1
2Td!'
We see at once from the forms of the right-hand members of relations 1.3:3 and 1.3:5 that the greater the number of correct significant figures in the approximation a (and hence the smaller the numerical unit lOU), the smaller the values of these two fractions. That is, the upper bound for the relative error and the value of the maximum relative error decrease as the number of correct significant figures increases. We shall frequently omit the adjectives "actual" and "maximum" and talk merely of the errors and the relative errors when the context makes the meanings clear. REMARK. It should be pointed out that the terminology regarding "accuracy" and "precision" is not uniform either in usage or in the literature. Some authors reverse the meanings of the two words as they are used here; some use them with slightly different meanings; some use the' two words more or less interchangeably. The words are also used, in different but allied context, to designate the reliability of the arithmetic mean of a series of measurements of the same quantity.
EXERCISE 1.J 1. Determine the accuracy and precision of a 12 in. ruler if it actually is 12.01 in. long. 2. Determine the accuracy and precision of a weight intended to be 1000 gm but actually is 999.2 g. J. The thickness of a sheet of paper is measured as 0.004 in. by use of a micrometer which can be read to the nearest thousandth of an inch. What are the precision and accuracy of the measurement? 4. The Empire State building is 1250 ft high to within 6 in. A 3-in. cylinder is ground with a tolerance of one one-thousandth of an inch. Which measure is the more precise? The more accurate? 5. Assume that the error is spread evenly over the ruler of Example I. Three distances measured with this ruler are found to be 3 in., 6 in., and 2 ft, respectively. What are the precision and accuracy of each measurement? 6. Is the number of correct significant digits in a stated measurement directly related to the accuracy or to the precision of the measurement? Explain your answer.
1.4. Computational Errors. (1.4: 1)
The well-known formula
T= 2n~;
expresses the time of a complete swing of a pendulum in terms of its length and the acceleration of gravity. Students evaluating T from the
12
1. NUMBERS AND ERRORS
results of recorded data or, more generally, students and others making similar calculations are frequently perplexed with a variety of questions concerning the number of significant figures to be used or kept. The answers to most of these questions can be found in the answers we will give to the two following questions. First, how precise or accurate is the result of a calculation performed upon numbers whose errors or maximum errors are known? And second, how precise or accurate must each of a set of numbers used in making a calculation be in order to obtain a result of preassigned precision or accuracy? We attack the first of these questions in the present section and the second in the next section. We first wish to remark, however, that the number of significant figures used to express a measurement depends directly on the construction and capability of the measuring instrument and on the quality of the magnitude that is being measured. Suppose we are using an ordinary cheap protractor to measure an angle. The very best we can do with it is to determine a carefully drawn angle to the nearest half degree. If the angle were drawn freehand with chalk on a blackboard, the nearest multiple of 5° would be precise enough. If, furthermore, the measure of such an angle where 25°, say, and it were necessary to indicate one-third of the angle, the measure of the smaller angle should be written as 8°; neither the drawing nor the instrument justify the use of 8!0, and he who uses 8.33333° is obviously living in a world of illusion. Also, one should suit his instrument to the character of the magnitude to be measured. Thus, to measure the length of a shadow (in order to find the length of a flagpole, say) it is quite unnecessary to have a steel tape graduated to sixty-fourths of an inch. A close examination of a shadow, even one cast by a pole on a bright day, will reveal that its edge is rather nebulous; the best we can do is to obtain its length correct to the nearest eighth of an inch. Similarly, in the notoriously crude calorimeter experiments it is unnecessary to use thermometers capable of measuring a variation in temperature of one-thousandth of a degree. We turn now to the study of the first of the two questions just raised, namely, how precise or accurate is the result of a calculation performed on approximate numbers? Or, to put the question in lither words, how many significant figures shall we use in writing the result of a computation performed upon approximate numbers? Let Xl , XI , •.• , Xn be the numbers involved in the computation and let y be the result of the computation; y is then some function of the x's which we write as (1.4:2)
13
1.4. COMPUTATIONAL ERRORS
We can regard the x's as independent variables and y as a variable dependent on them; we assume that the function I and its partial derivatives Ix 1 ,Ix2 , "', Ix • exist and are continuous, at least in a neighborhood of the values under consideration. If we assign the (positive, negative, or zero) increments LlXI , Llx2 , "', Llx" to Xl' X2 , "', X,,, respectively, y takes on an increment Lly and we have (1.4:3)
whence
If we now consider Xl , X 2 , "', Xn as approximations to the respective "true" values Xl + LlXI , X2 + LlX2 , "', X" + Llx" occuring in the computation, then Lly given by 1.4:4 is the error in the result of the computation due to the errors LlXI , Llx2 , "', Llx" , respectively. We seek a more easily estimated form for this error. The right-hand member of the equality 1.4:4 can be put into the form
+ ... + [f(Xl , X2 , ... , X"-l , X" + Jx,,) -
f(Xl 'X 2 , "', Xn-l , x,,)].
It follows from the Law of the Mean that the successive brackets on the right-hand side of this equality are equal to
fzt(x 1 , X2 + 82 Jx 2 , Xa (1.4:5)
+ Jxa , "', x" + Jx,,) Jx 2, f".(x 1 'X 2 , Xa + 8a JXa , X4 + Jx, , "', .:t" + JXn) JXa ,
respectively, where all the 8's are positive quantities less than unity.
14
1. NUMBERS AND ERRORS
Since the partial derivatives that occur here are continuous functions, they are, in turn, equal to
(1.4:6)
where El , E2 , ... , En are functions of the x's and their increments that approach zero as LlXl , LlX2 , ... , Llxn approach zero. Hence (1.4:7)
Lly
= !"I(xl , ... , xn) LlXl
+ !.,z(xl , ... , xn) LlX2
+ ... + !"n(x xn) Llxn + El LlXl + E2 LlX2 + ... + E" Llx" . l , ... ,
We now rename LlXl ,Llx2 , ... , Llxn; we call them dx1 , dx2 , ... , dXn , respectively, and then define the "total differential" dy by (1.4:8) dy
= !"I(Xl' ... , x,,) dXl + !"z(Xl' ... , x,,) dX2 + ... + !"n(Xl' ... ,x")dx,,.
Then dy and Lly differ by the amount (1.4:9)
which ordinarily is small compared to dy. Consequently, the value of the total differential dy given by 1.4:8 is a good estimate of the error committed in the computation on the approximate numbers Xl , X 2 , ••• , Xn . We remark that each term on the right-hand side of 1.4:8 may be positive or negative since, apart from the partial derivatives, the differentials may be positive or negative. Hence, to find the maximum error in y, we put 1.4:8 in the form (1.4:10)
I dy I ~ 1!"I(xl' ... , x,,) II dX1 I + 1!"a(x1 ,
..• ,
x,,) II dx2 1
+ ... + I!"n(xl , ... , x,,) II dXn I· We obtain from 1.4:2 and 1.4:8,
\
(1.4:11)
an expression for the relative error dy/y in terms of the relative errors dXl/X l , dX 2/X 2 , ... , dxn/xn , where for the sake of brevity we omitted
1.4. COMPUTATIONAL ERRORS
1S
from the!'s the arguments Xl' X2 , ••• , X" . Since the preceding remark applies here too (indeed, the relative error was defined as an absolute value), we rewrite the preceding formula as (1.4: 12)
I; I~ IXl;Zl II ~:1 I+ IX;ZI II ~21 + ... + IXn~Zfi II ~n I·
We summarize the preceding results. If the absolute values of dx l , dX 2 , ... , dXn are the maximum errors in the approximate numbers Xl' X2 , ••• , Xn , respectively, and if y is the result of the computation
1.4: 1 performed on these numbers, then the maximum error I dy I in y is given by formula 1.4: 10 and the maximum relative error I dy/y I is given by formula 1.4:12. More precisely, the right members of 1.4:10 and 1.4: 12 are good estimates of the maximum magnitudes of the respective errors. If, in particular, y is a function of a single variable X, then (1.4:13)
dy = f'(x) dx,
(1.4:14)
where the primes indicate differentiation with respect to x. We also note the algebraic identities
dy =y;,
(1.4:15) (1.4:16)
I
dy
1=
Iy II; I·
We illustrate the use of formulas 1.4: 10 and 1.4: 12 by an example .. EXAMPLE. Determine T, its maximum error, and its maximum relative error from formula 1.4: 1, given 1T = 3.1416, 1 = 51.32 cm, g = 980.62 cm/sec2• (It is understood that all significant figures are correct. Also, it should be remarked that this well-known formula from physics is itself inaccurate. The present discussion makes no attempt to gauge the errors resulting from the inexactitude of the formula; we are here supposing that the formula is exact and we wish to determine the errors in T due to the errors in 1T, I, and g.) The errors in 1T, I, andg are d1T = 0.00001, dl = 0.005, and dg = 0.005 respectively. Note that for the purpose of this discussion, 1T must be
1. NUMBERS AND ERRORS
16
considered a variable. Taking the total differential of T and replacing each term by its absolute value, we find 1
I dT I ~ I!gi (21g I d1T I + 1Tg I d/l
(1.4:17)
+ 1T/I dg I).
On substitution, we find the error to be I dt I ::::;; 7.8 X 10-6 • Hence, T = 1.437388 ± 0.000078. The relative error is 0.000054- or 0.0054-%. The error and relative error are usually written with at most two significant figures. An alternate method for calculating the error and relative error is based on formula 1.4: 16 and usually involves far less computation. We first calculate the relative error and then the value of the error. Since the relative error of a product is equal to the sum of the relative errors of the factors and the relative error of a quotient is equal to the sum of the relative errors of the dividend and divisor-see examples 2(b) and (c) at the end of this section- and since the relative error of a square root is equal to one-half the relative error of the radicandexample l(b)-the relative error in T is equal to the relative error in 1T plus one-half the sum of the relative errors in I and g. We obtain by this shorter method the same results as before.
EXERCISE 1.4 All numbers in examples 3-19 are correct as far and only as far as they are written unless otherwise implied or known to be exact. Give all numerical answers with as many correct significant figures as possible. 1. Derive for each of the following functions an expression for the error in y in terms of x and the error in x and an expression for the relative error in y in terms of x and the relative error in x. •• y = x"; c. y = sin x (x in radians); e. y = In x = log. x;
g. y
=
e";
b. d. f. h.
vx;
in particular, y = y = cos x (x in degrees); y = loglo x; y = aZ , a > O.
2. Prove: •• if s = XI ± X2 ± ... ± x .. , then I ds I < I dXI I + I dX 2 I + ... b. if P = XIX2 ... x .. , then I dp I < ~;:'I I pIx, I I dx, I and I dp/p I c. if q = x/y, then I dq/q I < I dx/x I + I dy/y I .
+ I dx .. I; < ~:"I I dx./x, I;
1. The length of a side of a square is 23.4 mm. Find its perimeter, the length of a diagonal, and its area. 4. The radius of a circle is 9.S in. Find the circumference, the area, and the length of a chord 7 in. from the center.
17
EXERCISES
5. The hypotenuse c of a right triangle is 13.4 cm, one leg a is 9.2 cm. Determine the precision and accuracy of sin A calculated from the formula sin A = a/c.
6. Find the area of a triangle whose sides are 23.4 ft, 30. I ft, and 45.9 ft. 7. The diameter and length of a right circular cylinder are 4.13 and 12.90 in., respectively. Find the accuracy and precision of the total area and the volume.
8. A solid sphere of radius 2.50 in. is made from a metal that weighs 0.223 Ib/cu in. Determine the accuracy and precision of the weight. M
9. Find the accuracy and precision ofF given by the formulaF = 53.74, , = 200, and k is a constant, known exactly.
M
10. Determine the accuracy and precision of F given by the formula F = 9.2, a = 3.0, x = 1.2" = 6.1.
=
kmM/,2 if m =
=
0.32,
Ma'/,' if
11. An equation for simple harmonic motion is s = a cos t. What are the maximum and relative maximum errors in s if a = 23.8, and t = 0.9? 12. The distance s in centimeters of an oscillating point from an origin is given by s
=
~e-'cos (~+ 8) 22'
where t is time (in seconds) and 8 is an initial angle (in radians). If t and 8 are 2.0 sec and 0.3 rad, respectively, find the maximum error and relative maximum error in s. 11. The cosine of an angle is computed from the sine by use of the identity cos 2 8 = I - sin· 8. Show that for angles close to 45° the maximum error in cos 8 is approximately equal to the maximum error in sin 8. In general, prove that the maximum error in cos 8 is approximately equal to the maximum error in sin 8 multiplied by tan 8 and that the maximum relative error in cos 8 is approximately equal to the maximum relative error in sin 8 multiplied by tan 2 8. 14. Solve the equation 1.37x'
+ 2.05x
- 3.21
=
O.
15. Find the error in a root, of the equation aoxn errors in the coefficients ao , al , ... , an .
+ a1Xn - 1 + ... + an
=
0 for given
16. The earth is an oblate spheroid with equatorial radius 3963.3 mi, polar radius 3949.9 mi. Find its volume. (An oblate spheriod is formed by the rotation of an ellipse about its minor axis. If a and b are the major and minor axe~, respectively, of the ellipse, the volume of the ellipse is given by the formula V = ~1Ta2b.) 17. If air resistance is proportional to the square of the velocity, the velocity v in em/sec of a body falling from rest is given by gt v = ktanh k , where g is the acceleration of gravity, k is the maximum velocity, and t is the time. If = 5275 cm/sec, g = 980.6 cm/sec·, find the velocity at the end of 1.0 sec. When is the velocity 500 cm/sec? 1000 cm/sec ? 2000 cm/sec? 5000 cm/sec ?
k
18. The standard length Ho of a mercury barametric column in millimeters, at a temperature O°C, at a point at latitude L, and at a height h ft above sea level, is given by Ho
=
760
+
1.9456 cos 2L
+ 0.00004547h.
1. NUMBERS AND ERRORS
18
Find the standard lengths of barametric columns at the following places: Latitude
Place
Altitude (ft)
- - - - - - - - - - - - - _ ..
40°36' N 40°44' N 40°44' N 71 °23'30" N 29°56'53" N 38°55'15" N 51°30' N 0°35'20" S
Brooklyn Foot of Empire State b'ldg Top of Empire State b'ldg Pt. Barrow, Alaska New Orleans Washington, D. C. London Mt. Cotopaxi
50 46.7 1296.7 Sea level Sea level 150 100 19,498
19. Find the value of the following determinant; assume all numbers are exact.
32.1
D
=
I -1.6 35.0
I
5.3 7.0 12.7 7.2 . 5.8 7.4
What is the maximum error in D if the element 7.0 is correct only to the nearest tenth? If the element 7.2 is correct only to the nearest tenth? What are the maximum and minimum values of D if every element is correct only to the nearest tenth?
1.5. The Inverse Problem. In the preceding section we estimated the maximum error and the maximum relative error in the result of a calculation due to stated errors in the numbers involved. In this section we discuss the inverse problem, namely, how precise or accurate must the numbers used in a calculation be to obtain a result of preassigned precision or accuracy? We answer this question and explain the various methods by means of an example. EXAMPLE. The time T is to be calculated from formula 1.4: 1. If the values of 1 and g are about 51.3 cm and 980.6 cm/sec2, respectively, just how precisely must the values of 1T, I, and g be taken if the error in T is not to exceed 0.0001 sec? We refer first to formula 1.4: 17 which we now write in the form (1.5:1)
I dT I ~ 21tg-11 d1T I + 1THg-! I dll
+ 1T1!g-i I dg I ~ 0.0001.
This time, I dT I (~0.0001), I, and g are the known quantities; I d1T I, I d/l, and I dg I are the quantities to be determined. Essentially, then, we are faced with the algebraic problem of solving a single linear equation in three unknowns, I d1T I, I d/l, I dg I, in which the coefficients are not exact. We simplify the problem by supposing for the moment that the coefficients are exact. Elementary algebra tells us that we have a double infinity of solutions or that we are free to impose two additional
19
1.5. THE INVERSE PROBLEM
conditions on drr, dl, dg. These conditions can be imposed, of course, in a great variety of ways. One method of imposing two additional conditions is to demand, quite arbitrarily, that each term of the middle member of 1.5: I contribute equally to the error dT in T. This is equivalent to stating that (1.5:2)
21!g-! I drr I = rrHg-I I dll = rrl!g-il dg I ~ 0.000033.
Substituting 51.3 for I and 980.6 for g, and solving, we find I drr I ~ 0.000073, I d/l ~ 0.0024, I dg I ~ 0.045. These results mean that if rr is taken as 3.1416, so that the error in rr is actually less than 0.00001, if I (about 51.3 cm) is measured to within two-thousandths of a centimeter, and if g (about 980.6 cm/sec S) is determined to within four-hundredths of a centimeter per second per second, then the error in T will be at most 0.0001 sec. Roughly, the error in T will be within the prescribed bounds if the values of rr, I, and g are each taken correctly to five significant figures. The values for I drr I, I d/l, and I dg I were calculated on the assumption that the original values for I and g were exact. Since we found out that both I and g had to be measured somewhat more precisely, it is natural to ask: are the answered affected? That is, what are the errors in I drr I, I d/l, and I dg I due to the errors in I and g? We have
I drr I = 0.0000167Hgl; whence d I drr I = 0.0000167(-
! l-ig! I dll + ! l-lg-ll dg I).
We find by substituting the values of I, g, dl, and dg in the right-hand member of this equality that the value of d I drr I, that is, the error in I drr I, is indeed insignificant compared to drr itself. Similar results hold for d I d/l and d I dg I. Hence the inexactitude of the coefficients in 1.5: 1 does not affect the answers. Reference to the inequalities 1.5: 1 and 1.5:2 shows that for a fixed I and g, multiplication of dT by an arbitrary constant has the effect of multiplying each of I drr I, I d/l, and I dg I by the same constant. That is, the error in T will not exceed O.OOOlk if the errors in rr, I, and g do not exceed 0.000073k, 0.0024k, and 0.045k, respectively. The example we have just completed exhibits the general procedure. To determine the maximum errors in the quantities Xl' Xs , "', Xn that will yield an error in y which does not exceed a preassigned limit, where y and the x's are related by the equality 1.4:2, equate each of the terms of the right-hand member of 1.4: 10 to (I/n)th of the allowable
20
1. NUMBERS AND ERRORS
error in y and solve for 1dX I I, 1dX 2 I, "', 1dX n I. This method uses what is known as the principle of equal effects. A second but essentially equivalent method uses the formula 1.4: 12. In this case we first compute y and then the relative error 1 dy/y I. We then impose the condition that each term of the right-hand member of 1.4:12 contribute equally to the allowable error 1dy/y I. Since this method is similar to the preceding one and yields the same results, it needs no further elaboration. The preceding two methods for determining the unknowns take the easiest way out, so to speak. A third and somewhat more reasonable method would go about as follows. The number 7r can be obtained to any practical degree of precision by merely looking it up in a table; we may then assume that for the problem at hand, d7r is zero. Assuming further that the length of the pendulum and the acceleration of gravity can be obtained with equal precision, we put dl equal to dg. Under these assumptions, 1.5: 1 becomes (1.5:3) whence
1dT 1 ~ 7r(I-tg-l 1
d 'g
1
+ lig-i) 1dg 1~ 0.0001,
~ O.OOOll!gi """"
7r(1 + g) .
On substituting the given numerical values for I and g (and using 3.142 for 7r, a value which does not effect the first two significant figures in dg), we find 1dll = 1dg 1 ~ 0.0068. It follows that the error in T will not exceed the allowable limit 0.0001 if the length I and the acceleration of gravity g are each determined to within six units in the third decimal place and if the value of 7r is taken correct to six significant figures. Comparing these results with those previously obtained, we see that this time I need be determined somewhat less and g somewhat more precisely than before. In general, we would use the principle of equal effects to determine the allowable errors in the quantities Xl' X2 , "', Xn involved in the computation of a result y that are necessary to yield an error dy in y which does not exceed a preassigned limit if and only if we have absolutely no guide to the imposition of conditions on the errors dX I , dX 2 , "', dX n . Whenever possible, however, the last method should be used. It assumes, of course, that one is familiar with his instruments, both physical and mathematical and that the user knows what numbers can be easily obtained with great precision and what numbers can be obtained only with great difficulty. Even when this information is
21
EXERCISES
lacking, it may be desirable at times to weight the errors sought according to some arbitrary but reasonable plan rather than use blindly the principle of equal effects. EXERCISE 1.5
The examples referred to below are the examples of Exercise 1.4. In each case, state clearly the assumptions made regarding the distribution of the errors. 1. How precisely must the length of the side be measured (example 3) to determine the perimeter to within 0.02 mm ? The area to within 5 sq mm ? How precisely must the side be measured to determine the perimeter to within 0.03 % ? The diagonal to within 0.03 % ? The area to within 0.03 % ? 2. How accurately must the radius be measured (example 4) to determine, to within one part in a thousand, the circumference? the area? the chord? 3. How precisely must a and c be measured (example 5) to ensure five correct significant figures in sin A ? 4. How precisely must the sides be measured (example 6) if the area is desired to within 10 sq in.? 5. How precisely must the radius be determined and to how many significant figures must the weight in pounds per cubic inch be known (example 8) if the total weight is desired to within 0.1 oz ? 6. How accurately must m, M, and r be determined (example 9) if F is desired to within 0.35 % ? 7. How precisely must a and t be known (example 11) if s is desired to within 5 % ? 8. How precisely must t and 8 be measured (example 12) if s is desired to within a thousandth of a millimeter?
t. What are the allowable errors in the coefficients (example 14) if each root is desired correct to three decimal places? if each root is to have a maximum relative error of 0.0006 ? 10. How precisely must the values of b, A, and B be determined if a, given by a =
bsinA sin B '
is desired with a maximum error of 0.005 if, approximately, b B=53°12'?
=
42.36 em, A
11. Find R, its maximum and relative maximum errors if
R
G- I
=
Jc-G '
and J = 778, c = 0.339, G = 1.25. Ii is known that c can be determined about twice as accurately as either J or G; use this information to determine the allowable maximum errors (actual and relative) in J, c, and G so that R is correct to within one part in a thousand.
Chapter 2
The Approximating Polynomial; Approximation at a Point
2.1. Introduction. The scientific worker soon becomes aware that some compromise with reality is necessary in almost every attempt to develop and formulate the principles that describe the quantitative aspects of natural phenomena. The world and its workings are so complex that it is usually impossible to write down, exactly, the mathematical laws they obey. It is almost always necessary to simplify by idealization and neglect. Thus, in the attempt to describe the apparently simple phenomenon of a body falling through air, it is necessary to neglect or at least to idealize air resistance. The scientific worker realizes his limitations and is ever faced with the problem of balancing the advantages of simplicity with the disadvantages of inaccuracy. Nor is pure mathematics entirely free from the necessity of similar compromise. Indeed, it is frequently convenient and sometimes imperative that a function (2.1:1)
y
= f(x)
be replaced by a simpler function (2.1 :2)
y = a(x)
so that the properties and values of f(x) can be studied or obtained from the corresponding properties or values of a(x). We give two instances below. If we put (2.1 :3)
f(x) = a(x)
+ E(x),
then by analogy with equality 1.2:2, we may regard a(x) as an approximation to f(x) and E(x) as the error function. Again, it is necessary to balance the advantage of simplicity gained with the disadvantage of precision lost. As soon as it has been decided what the type of the simple, approximating function a(x) shall be-for the most part, a(x) will be a polynomial-our ability to weigh the advantages and the opposing disadvantages will depend on the ease with which a(x) can be obtained 22
2.1. INTRODUCTION
23
and used and on our ability to estimate E(x) [the error must always be an estimate, for if it were known exactly, f(x) would be known exactly and there would be no need for a(x)]; it is this twofold problem which is our main concern in this and the next few chapters. To appreciate some of the reasons why it is advisable at times to replace a function by a simpler one, consider the differential equation d 28 1dt 2
= -gsin8
which arises in the study of a swinging pendulum. This equation is difficult to solve as it stands, but if we replace the function sin 8 by the function 8, the new equation is quite easy to solve (and as a matter of fact, leads to the formula 1.4:1). It turns out that the replacement causes a negligible error if 8 and consequently sin 8 are small in absolute value. Another instance in which one function is replaced by anotherthis time the replacement is usually performed quite unconsciouslyis afforded by the process of interpolation. The reader is familiar with the method of evaluating, say, log 2.956 (=0.4707) from a four-place table of common logarithms which lists log 2.95 = 0.4698 and log 2.96 = 0.4713. A superficial analysis of the process reveals that log x has been replaced or approximated by a first degree polynomial; the process is, indeed, frequently called linear interpolation. We delve into this interpolation process somewhat further. Suppose that ten-place common logarithm tables were used instead of four-place tables. We have log 2.95 = 0.4698220160, log 2.96 = 0.47129 17111, whence, by linear interpolation, we obtain log 2.956 = 0.4707038331. However, the value of log 2.956 correct to ten decimal places is 0.4707044297, a result quite different from the preceding one. Why the discrepancy? Why do we get an answer correct to four decimal places when we use a four-place table but an answer correct to only six decimal places when we use a ten-place table? To understand this apparently unnatural situation, let us note first that 0.4698 and 0.46982 20160 are rounded-off values; they are approximations to and are not the exact value of log 2.95. Therefore, since the computations of log 2.956 involved the use of these rounded-off values, We should expect some errors in the answers. Furthermore, log x was replaced by a linear polynomial in each of the computations; since log x is not a linear polynomial, we should expect some error in the answers due to the replacement. Now, it happens that the replacement error is small and negligible compared to the rounding-off error when
24
2. APPROXIMATING POLYNOMIAL; APPROXIMATION AT A POINT
four decimal places are used but large and dominant when ten places are used. (Note that the rounding-off error in a number correct to four decimal places is at most 0.00005, at most 0.00000 00000 5 when the number is correct to ten decimal places.) It is for these reasons that linear interpolation was adequate when a four-place table was used and inadequate when a ten-place table was used. What can we do, then, if we wish to compute log 2.956 correct to ten decimal places by use of a ten-place table? Since in linear interpolation log x was replaced by a first degree polynomial, it is reasonable to try the substitution of a polynomial of higher degree for log x. As a matter of fact, if log x is approximated by a suitable third degree polynomial, the cubic will yield the value of log 2.956 correct to ten decimal places. The succeeding sections will develop and elaborate the underlying concepts. 2.2. Representation of a Function by a Polynomial.
(2.2: I)
y
Let
= f(x)
be a function of x. For the reasons indicated in the first section, it is desirable at times to replace f(x) by a polynomial
(2.2:2) whose degree does not exceed a preassigned n and which approximates f(x) as well as possible. For the sake of brevity, a polynomial of degree not greater than n will be called a polynomial of max-degree n. For the present, we evade the question of what is meant by "as well as possible." Since Pn(x) has n + I coefficients that are at our disposal, we can impose an equivalent number of conditions for the determination of the polynomial. Let us suppose first that A : (xo , Yo) is a point on the graph of y = f(x). The max-degree n being given, we obtain in this section a polynomial whose graph approximates as well as possible in some intuitive sense the graph of y = f(x) in the neighborhood of point A. It would seem natural to require that the graph of the polynomial pass through A, that its tangent coincide with the tangent to the graph of y = f(x) at A, and that its radius of curvature coincide with the radius of curvature of y = f(x) at A. These requirements will be satisfied if
We use primes to designate differentiation and drop the subscript n from Pn if there is no danger of misunderstanding.
25
2.2. REPRESENTATION OF A FUNCTION BY A POLYNOMIAL
The generalization is clear. Let us choose the a's in 2.2:2 so that
We assume that f(x) possesses all the derivatives in question, but it remains to show that the conditions just imposed uniquely determine the a's. It follows from 2.2:2 that to satisfy these conditions we must solve the linear equations ao
+ a 1x O + a1
+ ... + +2aro + ... + a2x 02
anxo"
= f(x o),
nanx~-1
= f'(x o),
for ao , a1 , "', an . We solve the last equation for an , then the preceding one for an-I, and so on. It develops that the a's are uniquely determined and are given by ao
= f(x o) -
xof'(xo) +
1
2
a1 = IT f'(x o) -
;,2- f"(x o) =t= ... + (-1 )"~!" p")(xo),
;0 f"(xo) +
n~
... + (-1 )"-1 n~!
j 0), then it can be shown that I R2k I is less than the absolute value of the first term neglected, that is,
I R2k I
0.
·. . fi ed 1·f a o = 32' 3 16 15 Th ese con d ItlOns are satls a l = 32' a 2 = 32' an d therefore y = l2 (3 + 16x + l5x 2 ) is the required polynomial. It is suggested that the reader graph this parabola and y = t(x + I x I) on the same set of axes. EXAMPLE 2. If f(x) = sin x, find the parabola y = a o + alx + a2x2 which minimizes the integral Is given by 3.1:4 in the interval [0,11]. We have (again we omit the subscript S)
I
=
(Sin x - (a o + alx
+ ar 2))2 dx.
This time we calculate the partial derivatives before we integrate; we obtain lao
= -2 =
lal
r o
(sin x - (a o + alx
-2 (2 -
= -2
r
• 0
= -2 (
'TT2 _
;2
x(sin x - (a o + a 1x
= -2 ('TT - ~0'TT2 lal
~1
ao'TT -
+ a2x2)) dx
-
;1'TT3 -
x 2 (sin x - (a o
= -2 ('TT2 - 4 -
'TT 3 ),
+ ar2)) dx ~ w4),
+ a1x + a2x2)) dx
;0 wi - 7w4 -
~ 'TTO).
70
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
We find on imposing the conditions 3.1:5 that 12 ao = w3 (172 - 10) = -0.050,
60
a 1 = -rr4 (12 - r) = a2
1.312,
60
= -rr5 (172 - 12) = -0.418,
and therefore the equation of the required parabola is Y
12 [r - 10 + :5; . (12 = w3
172 ) X
+ 1752 (172 -
12) x2]
= - 0.050 + 1.312x - 0.418x2 • The reader should graph the parabola and sine curve on the same set of axes. EXERCISE 3.1 1. If f(x) = I x I, find the polynomials of max-degree 1 and max-degree 2 which minimize the integral Is given by 3.1:4 in the interval [-1, 1]; in the interval [-1, 2]. Draw the graphs of the given function and your answers. 2. Same as example 1, but withf(x)
=
e'".
3.2. Polynomial Thr.ough n + 1 Points; Determinant Form. In the preceding section we saw that it is possible to approximate a function throughout an interval by a polynomial by imposing the condition that a certain integral be as small as possible. As a rule, the polynomial is a good approximation, but unless its degree is small, it can be found only by the expenditure of much time and labor. Another method of determining a polynomial that approximates a function well throughout an interval is based on the requirement that the graphs of the polynomial and the function have a number of common points in the interval, or what is the same thing, that the polynomial graph pass through a certain number of points chosen on the function graph. The polynomial obtained in this manner does not, as a rule, approximate the given function as well as the polynomial obtained by the previous method but the loss is more than made up for by the facility with which the new polynomial can be obtained. Moreover, the polynomial derived from the new requirements lends itself much better to many of our later developments than does the old polynomial.
3.2. POLYNOMIAL THROUGH n
+
1 POINTS; DETERMINANT FORM
71
Our immediate general problem is then to find a polynomial
(3.2:1)
Y = P..(x) = a o + alx
+ ... + a,.x"
of max-degree n whose graph passes through each of the n
+I
points
i = 0, 1, ... , n.
(3.2:2)
These points may be assumed to be quite arbitrary (although it will develop in a moment that the abscisses must be distinct) or they may be chosen on the graph of the function
(3.2:3)
= f(x).
Y
In the latter case, our requirement stated in algebraic terms is that
(3.2:4)
Yi
i = 0, 1, ... , n.
= P..(Xi) = f(Xi),
Our second general problem is to determine how well the polynomial approximates the function and to learn how to use it to interpolate for values of the function. To find the required polynomial we substitute in turn the coordinates of the n + I points for x and y in the polynomial equation; we obtain the n + I linear equations
+ alxO+ ... + a,.xo" = Yo , a o + alx l + ... + a,.Xl" = Yl' ao
(3.2:5) Solving for the a's we get
i = 0, 1, ... , n,
(3.2:6) where
X~-l
Yo
x~+1···
xu"
Xl .•• X~-l
YI
x~+1···
xt"
X.. ...
Y..
x~+1
Xo ...
Di= and
D=
X~-l
1 Xo ... xo" 1 Xl··· Xl" 1 x .. ... x ....
... X....
72
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
However, a unique solution will exist only if D =1= O. To determine the circumstances under which this holds, we note that the expansion of D is a homogeneous polynomial in the x's of degree In(n + I). Moreover, the determinant and hence the polynomial vanish when Xi = xi' i =1= j, hence Xi - Xi is a factor of D. There are tn(n + I) such linear factors. A simple calculation shows that D = IIi>i (Xi - Xi)' It follows that D will be different from zero if the x's are distinct. Indeed, since a polynomial is a single-valued function, this condition might have been anticipated. (D is the famous Vandermonde-Cauchy determinant and appears in a great many different places in mathematics.) The coefficients of the polynomial y = p,,(x) are thus determined by the a's of 3.2:6. The polynomial, however, can be written in a much neater form. The determinant Di is equal to the determinant 0 0 .. ·0 Xo ... X~-l
Xi 0
.. ·0
0
0
Y
Xi+l ... Xo" 0
Xl ... X~-l
... Xl" YI Xi+l I ............................................. Xi X" ... X~-l y" XHI ... X "
Xi I
"
Hence
Xi Di
"
"
is equal to
o
0 0 .. ·0
Yo
Xo ... X~-l
XOi
x~+l .. • xu"
YI
Xl ... X~-l
Xli
x~+l .. · xt
x,,'" X~-l
X"i
x~+l .. · x,,"
Y"
1
The latter determinants, for different values of i, differ only in their first rows; hence summing them from i = 0 to i = n, we see that the polynomial p,,(x) can be written as the quotient of two determinants, y = p,,(x) = -E/D, where
o E =.
1 1
X
x2
Yo
Xo
X02 ... xo"
y"
1
X"
X,,2 ...
.. ·x"
x,,"
3.2. POLYNOMIAL THROUGH n
+
1 POINTS; DETERMINANT FORM
The preceding polynomial equation can be written as Dy and hence can be put into the form
(3.2:7)
y
1
Yo
1 Xo
x2 ···x" X02 ... xo"
y..
1 x..
X ..2 •••
X
73
+E =
0
= O.
x....
This is the determinant form of the polynomial 3.2: I which we were seeking. REMARK. We repeat that the n + I points may be assumed to be points within some interval on the graph of a function y = f(x), but since the function f(x) does not enter into the determination of the polynomial P..(x), the n + I points are quite arbitrary subject to the condition that they have distinct abscissas; in particular, the x's and the corresponding y's may be the observed or measured values of some magnitudes in a laboratory experiment or some natural phenomenon. We summarize this section in the THEOREM. If (xo, Yo), (Xl' YI)' ... , (X.. ,Y.. ) are n + I points with distinct abscissas, there is one and only one polynomial of max-degree n, y = P..(x), whose graph passes through these points, that is, such that y., = P..(Xi), i = 0, I, ... , n. EXAMPLE 1. Let y = f(x) = i(x + 1X I). The points of each of the three sets (-1,0), (0,0),(1, I); (-I,O),(-l,O),(O,O),(i,i),(I, I); (-I, 0), (- i, 0), (- 1, 0), (0, 0), (1, i), (i, i), (I, I), are equally spaced on the graph of the function. The equation of the parabola determined by the first set of three points is y
o o 1
X
x'l.
-1
1 = 0, 0 0 1 1
or y = lx + lx2. The equations of the curves determined by the second and third sets can be similarly found; they are y = x/2 + 7X2/6 - 2x4/3, y = x/2 + 37x2 /20 - 27x4/8 + 8Ix8 /40, respectively. The reader should draw the graphs of the three polynomials and compare them with the previously drawn graph of the parabola obtained by the former method. EXAMPLE 2. Find the equation of the parabola which coincides with the sine curve y = sin X at x = 0,17/2,17.
74
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
The values of y corresponding to the given values of x are y 1, 0; hence the equation of the parabola is
=
0,
X x2 0 0 'TT 'TT2 =0 2 4 'TT 'TTl
y 0
0 or y = 4x/'TT - 4X2/'TT2.
EXAMPLE 3. Find the equation of the cubic curve which intersects the logarithmic curve y = loglo x at x = i; 1, 2, 4. The equation of the cubic is
1 X Xl x3 1 l -1 .l8 1 1 1 1 = 0, 1 2 4 8 1 4 16 64
y -log 2 0 log 2 2 log 2 or y = log 2( -104
+ 147x -
49x2 + 6x3 )/21. EXERCISE 1.2
Note: all required equations in this exercise are of the form y = Qo + Q1X + Q1Xl + ... + QnXn and are to be found by means of determinants. 1. Find the equation of the parabola determined by the points (-I, -I), (1,0), (3, S). 2. Find the equation of the cubic determined by the points of the preceding example and (4, 0).
1. Find the equation of max-degree 3 determined by the points (-2, -17), (0, -I), (1,4), (4,7). 4. Find the equation of max-degree 3 determined by the points
(-2,-17),
(0,-1),
(1,4),
(4,8).
5. Find the equation of the parabola which coincides with y .,,/2. Draw the graph of each curve using the same axes. 6. Find the equation of the parabola which intersects y graph of each curve using the same axes.
=
=
e' at x
sin (xI2) at x
=
=
0, .,,13,
-I, 0, I. Draw the
7 .•• Find and graph the equation of max-degree 2 which coincides with y = I x I at -1,0, I.
x
=
x
=
b. Find and graph the equation of max-degree 2 which coincides with y = I x I at
1,2,4.
3.3. LAGRANGE INTERPOLATION FORMULA
75
3.3. Polynomial through n + 1 Points; Lagrange Interpolation Formula. We proved in the preceding section that there is one and only one polynomial of max-degree n whose graph passes through n + 1 arbitrary points with distinct abscissas. The determinant form 3.2:7, however, lends itself neither to arithmetic computation nor to most theoretic developments, hence it is desirable to obtain the polynomial Y = P..(x) in other more suitable forms. It turns out that a polynomial of the form
(3.3:1) n
= ~Li(X)Yt' i~O
where the L's are polynomials of degree n in x is quite suitable for computational and theoretical needs. Since Yk = P..(Xk), the forms of the polynomial multipliers of the y's will be determined if we impose the conditions that Lk(xj) be 0 or 1 according as j does not or does equal k. Since Lk(x) is a polynomial of degree n, it must have the form A(x - xo)(x - Xl) ... (X - xk_l)(X - xk+l) ... (X - X.. ), where A is a constant. Since Lk(Xk) = 1,
A=
1 (Xk - xo) ... (Xk - Xk-l)(Xk - Xk+1) ... (Xk - x,,)
.
Hence
(3.3:2) (3.3:3)
.( ) _ L ,x -
(x - xo) ... (x - Xt_I)(X - Xi+1) ... (x - x..) , (Xt - xo) ... (Xi - Xi-I)(Xt - Xi+1) ... (Xi - x,,) i = 0, 1, "', n, Y = p,,(x) (x - Xl) ... (x - x,,) (x - xo)(x - X2) ... (x - x,,) = (xo - Xl) ... (xo - x,,) Yo + (Xl - XO)(XI - Xl) ... (Xl - X,,) YI
+ ... +
(X - Xo) ... (X - X"-l) Y (X" - Xo) ... (X" - X"-l) ".
The form 3.3:3 is called the Lagrange Interpolation formula and the coefficients of the y's given by 3.3:2 are called the Lagrange coefficients. This form of the approximating polynomial is very useful and important since many of our later developments will be based on it. EXAMPLE. The polynomial through the points (- 2, 3), (0, 0), (1, 4). (5, -1) is given by
Y=
(x - O)(x - 1)(x - 5) 3 + (x (-2 - 0)(-2 - 1)(-2 - 5) (0
+ 2)(x + 2)(0 -
1)(x - 5) 0 1)(0 - 5)
76
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
(x -f 2)(x - O)(x - 5) 0)(1 - 5) 4
+ (I + 2)(1 or
y
=
(x + 2)(x + (5 + 2)(5 -
1 420 (1256x
O)(x - I) 0)(5 - I) (-I),
+ 597x· -
I 73x3).
The Lagrange coefficients, 3.3:2, may be given other useful forms. Let k be anyone of the integers 0, 1, .... n and let a, b "', g, h be the remaining integers in any order whatsoever. It follows that (3.3:4.0) L () I kx =
x - Xk Xa
+ Xk -
+ ... + (3.3:4.1)
= x - Xa Xk - Xa
+
(x - Xk)(X - xa) (Xk - Xa)(Xk - Xb)
(x - Xk)(X - xa)(x - Xb) Xa)(Xk - Xb)(Xk - xc)
+ (Xk -
(x - Xk)(X - xa) ... (x - Xg) . (Xk - Xa)(Xk - Xb) ... (Xk - x h) ,
II +
x - Xk Xk - Xb
+
(x - Xk)(X - Xb) (Xk - Xb)(Xk - xc)
(3.3:4.2)
(x - xa)(x - Xb) (Xk - Xa)(Xk - Xb)
I+ I
x - Xk Xk - Xc
+ ... +
j.
(x - Xk)(X - xc) ... (x - Xg) (Xk - Xc)(Xk - x,,) ... (Xk - x h) ,
(3.3:4.(n - I)) = (x - x,,)(x - Xb) ... (x - Xg) (Xk - Xa)lXk - Xb) ... (Xk - xo)
II +
(3.3:4.n)
(x - xa)(x - Xb) ... (x - xg)(x - Xh)
= (Xk - Xa)(Xk - Xb) ... (Xk - Xg)(Xk - x h) . The last form is the same as 3.3:2; we have included it for the sake of completeness. To verify that anyone of the other forms holds, add the first two terms within the braces, add the result to the third term, add that result to the next term, and so on; multiply the final result by the fraction in front.
77
3.4. DIVIDED DIFFERENCE FORM
EXERCISE 3.] 1. Find the polynomial equations of lowest degree determined by the following sets of points. Use the Lagrange Interpolation formula.
a. (-I, 2), (0,-1) b. (-2,7), (1,9) c. (3, 4), (2, 4) d. (-I, -I), (1,0), (3,5) e. (-1,0.2), (1,2.3), (4, -6.8) f. (-I, -I), (1,0), (3,5), (4,0) g. (-2, -17), (0, -I), (1,4), (4,7) h. (-2, -17), (0, -I), (1,4), (4,8) I. (-4,3), (1,7), (-2,0), (5, -I), (7,0) ;.(-2,-13), (10,11), (0,1), (4,17), (6,19). 2. Do examples 5, 6, and 7 of Exercise 3.2, this time using the Lagrange Interpolation formula. ]. Alongside is an abbreviated table of natural logarithms. Find the polynomials, P..(x), that coincide with the logarithmic function at x equal to
a. b. c. d. e.
402, 402, 401, 401, 400,
403, 403, 402,' 402, 401,
n = I; 404, n = 2; 403, 404, n
= 3; 403, 404, 405, n = 4; 402, 403, 404, 405, n
=
5.
x
Inx
400 5.9914645471 401 5.99396 14273 402 5.99645 20886 403 5.99893 65619 404 6.00141 48780 405 6.00388 70671
f. Use ordinary (linear) interpolation to find In 402.6. g. Use each of your answers to a, ... , e, in turn, to find In 402.6. h. Compare your answers to f and g. What is the value of In 402.6?
4. Prove l:~=OLi(X) Xit = xt, 0 < k ..; n, where Li(X) is defined by 3.3:2. [Hint: use
3.3:3 with y = xlt]. S. Derive the Lagrange Interpolation formula 3.3:3 directly from 3.2:7 by expanding the determinant in terms of the elements of the first row.
3.4. Polynomial through n + 1 Points; Divided Difference Form. The polynomial through n + I points can be put into yet another form which is frequently superior to the Lagrange form for computational purposes. The means used in deriving the third form are so useful In so many places that we give this method special attention. As before, let (3.4:1)
be a set of n (3.4:2)
+ I points with distinct abscissas. i-::pj,
The fraction
78
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
will be designated by the symbol (3.4:3)
and is called the first-order divided difference of the y's. In particular, etc. Also, For the sake of convenience in writing some expressions later on, we put (3.4:4)
so that the fraction 3.4:2 can be written in the form (3.4:2.1)
and we have (3.4:5)
Similarly, we define a second-order divided difference of the y's by the symbol
i, j, k all distinct;
(3.4:6)
a third-order divided difference by the symbol (3.4:7)
[
XiXjXkXm
]
=
[XtX/Xk] Xi -
[x;x~m] Xm
,
i,j, k, m all distinct.
In general, we define an rth-order divided difference of the y's, r ::::;; n, by the symbol (3.4:8)
+
where io , i1 , ... , ir are r I distinct integers in the range 0, I, ... , n. In actual practice, the subscripts in 3.4:8 are almost always consecutive integers.
* The context will make it clear whether the symbol [x] signifies the zeroth order divided difference or the greatest integer in x.
79
3.4. DIVIDED DIFFERENCE FORM
It is convenient for many applications to exhibit the numbers 3.4: I and the divided differences determined by them in the form of a triangular array known as a divided difference table. The x's and their corresponding y's are written in two vertical columns, the first-order divided differences are written in a third column, the second-order divided differences in a following column, and so on. The complete array for n + I number pairs then contains n + 2 columns, the last one consists of but a single entry, the only nth-order divided difference. The divided difference table for (xo ,Yo), ... , (X4 ,Y4) will look as follows: Xo
Yo
Xl
Yl
[XoXl] [XoXIXI] [XIXJ XI
[XoXIXIXS]
[XIXsXS]
Y. [XsXs]
Xs
[XoXIXsXsXC] [XIXaXsXc]
[XsXsx,]
Ys [XsxJ
X,
y,
As a concrete illustration, the divided difference table for the values (-2,234), (0, to), (5, 13135), (-1,31), (2, -86), 1S:
-2
234
0
10
-112 391 2625 5 13135
50 441
2184 -1
31
25 150
741 -39
2
-86
If the x's are arranged according to size, the array takes on the form: -2
234
-1
31
-203 91 -21 0
-25 -9
10
2
891
-86 4407
5 13135
25 150
-48
80
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
We remark that a divided difference table need not be carried out to completion; we may truncate it at any column. Note also that each divided difference in the table is the vertex of a triangle whose opposite side is in the y column. Thus, in the array above, [X I X 2X 3X4] is the vertex of a triangle whose sides are the vertical column YI' Y2' Ya, Y4'
the descending diagonal [Xl]'
[X IX2],
[X IX2X3], [XIXraXJ,
and the ascending diagonal [X4] , [xaxJ,
[Xr3X4] ,
[X IXraX4]·
It follows readily from the definition of the divided differences that [XoXI] =
Yo Xo -
~~=
h
(xo - XI)(XO- X2)
Xl
+ Xl YI - Xo
+ (Xl -
~
XO)(XI - X2)
+ (X2 -
h
XO)(X2 - Xl)
A simple induction proof yields
As an immediate consequence of the preceding formula, we see that a divided difference is a symmetric function of the x's and their corresponding y's; the value of a divided difference is therefore independent of the order in which the x's are written within the brackets. It is for this reason that we find the two 25's and the two ISO's in identical places in the two arrays exhibited above. The subscripts in formula 3.4:9 can be chosen more generally. Let i j ,j = 0, 1, ... , r,• be r• 1•distinct integers and (Xi I ,Yi), j = 0, • • I 1, ... , r, r + 1 pOints with distinct abscissas; then
+
(3.4:10)
Yt. + ... + -:----.,..,.....---:----;------:(x. - X· )(x. - x, ) ... (x. - x· ). 1,
'0
I,
.1
I,
',.-1
81
3.4. DIVIDED DIFFERENCE FORM
Let a difference table be constructed for the n + I points 3.4: I, where X o , Xl , ... , Xn occur in that order in the first column. Each divided difference in the table is adjacent to two divided differences that precede it and, unless it is the last or first entry in its column, to two that follow it. The sequence of divided differences (3.4: 11) (where, since the order of the x's written within a pair of brackets is immaterial, they may be rearranged so that the subscripts occur in natural consecutive order) is called a sequence chain if the first term of the sequence is one of the y's, the last term is the one and only divided difference of the nth order, and the intervening terms have the property that each is adjacent in the difference table to its predecessor and to its successor. Of the 2n possible sequence chains (we leave it to the reader to prove that there are exactly 2n distinct sequence chains), we take special note of four: first, the sequence chain (3.4:12) whose terms form the uppermost descending diagonal of the difference table; second, the sequence chain (3.4:13) whose terms form the lowest ascending diagonal. Then, if n is even and equal to 2m, say, we mark the sequence chains (3.4:14)
[x m],
[xmxm+l]'
[Xm-IXmXm+l]'
[X m-IXmXm+lXm+21 • ... , [XoXl ... xn],
(3.4:15)
[x m],
[Xm-IXm],
[xm_IxmX",+l]'
[xm-~m-IXmXm+l]'
if n is odd and equal to 2m (3.4:14')
[Xm],
(3.4: 15')
[xm+1]'
... , [XoXl ... xn];
+ I, we note the sequence chains
[xmXm+l]' [xmxm+l]'
[xm-IXmXm+l]' ... ,
[XoXl ... xn],
[xmxm+lxm+2]' ... , [XoXl ... xn]·
In either case, the terms of the last two sequence chains we have marked for special attention start with the middle y or y's of the difference table and zigzag to the final nth order divided difference. Because of the manner in which new subscripts are introduced into the successive divided differences 3.4:12-15, 14', IS', we call the sequence chain 3.4: 12 a sequence chain of forward divided differences, 3.4: 13 a sequence chain of backward divided differences, and the remainder,
82
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
sequence chains of central divided differences. More briefly, we shall refer to chains as forward, backward, or central sequence chains. The sequence chain 3.4: II is now used to build the polynomial equation
The law of formation of the polynomial is rather 0 bvious and consequently need not be explicitly stated. Since each divided difference is a constant, the polynomial is of max-degree n. Since there are 2" sequence chains, there are ostensibly 2" polynomials of the form 3.4:16. However, we shall prove that all of these polynomials are identically equal to each other and, indeed, each is the polynomial through the n + I points (3.4: I). Before doing so, we call attention to the four special forms of the polynomial corresponding to the four special sequence cnains noted above; we write explicitly only the first of these polynomials, to others are left to the reader. (3.5:17) y
= [xo]
+ [XoXI](X - xo) + [XoXIX2](X - xo)(x - Xl) + ... + [XoXI .•• x..](x - xo)(x - Xl) •.. (X -
x..- I ).
To prove the statement made above, we have, from 3.4:4 and 3.4: 10,
Now multiply the first of these identities by I, multiply the second of these identities by x - Xi o ' the third by (x - Xio)(x - Xi), ... , and the (n + I )st by (x - Xio)(x - Xi 1) ... (X - Xi n_l ); then add all the products.
83
3.4. DIVIDED DIFFERENCE FORM
The result is an identity whose left-hand side is the polynomial of 3.4: 16. The right-hand side can be written as
I+
x - Xi 0 XiO - Xii
I
Yi o
+
i
Y
I
+
(x - xd(x - xd 0 I + (XiO - Xil)(XiO - Xi a)
I+
X - Xi 0 I Xii - XiO
X - Xi I Xii - Xiz
+ ... +
... + (x - xd ... (x -
Xi
0
(XiO -
Xii) ...
(XiO -
n_1
)!
Xi n)
)!
(X - Xi ) ... (X - Xi I A_I (Xii - Xi.) ... (Xii - Xi n)
+ ........................................... . (X - XiO)(X - Xii) ... (X - Xi n _ l ) + Yin (X.In - X·10 )(X.In - X.) ... (X.1ft - X·'n-l). 11
But by formulas 3.3:4.0 - 4.n, the coefficient of Yi k is precisely Lik(X); hence the right-hand side is the Lagrange interpolation polynomial and our assertion is proved. That is, the polynomial equation 3.4: 16 is the equation of the polynomial of max-degree n through the points 3.4: 1. EXAMPLE. The equation of the polynomial through the five points given at the beginning of this section is
Y
+ 39lx(x + 2) + 50x(x + 2)(x - 5) + 25x(x + 2)(x - 5)(x + I) = -86 - 39(x - 2) + 741(x,- 2)(x + I) + 150(x - 2)(x + I)(x + 25x(x - 2)(x + I)(x - 5) = 10 - 2lx + 9lx(x + I) - 25x(x + I)(x + 2) + 25x(x + I)(x + 2)(x - 2), =
234 - 112(x + 2)
5)
etc. n
The divided difference form, 3.4: 16, of the polynomial through the points
+I
(3.4: 18)
in that order, has one noteworthy feature. It determines the sequence of polynomials
Y
= =
Y
=
Y
(3.4: 19)
[XiJ,
+ [XioXil](X [Xio] + [Xtox;J(x [XiJ
Xi o)' Xi o) + [XioXiIXil](X - Xio)(x - Xii)'
84
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
of max-degrees 0, 1,2, ... , respectively, determined by the first, the two, the first three, ... , points, respectively, of 3.4: 18. This suggests that to find by interpolation the value f(x') from a table of f(x), the most precise result can be obtained by choosing the points 3.4: 18 so that (3.4:20)
and stopping the process when succeeding terms no longer affect the answer (or when we run out of points). See the second half of Section 6.
EXERCISE 3.4
t. Write out the complete divided difference table for each set of points of example I, Exercise 3.3. 2. Write out the divided difference table for the set of points (0, sin 0°), (10, sin 10°), ... , (90, sin 90°), as far as the column of third order differences. (Obtain the values of the sines from any five-place table.) 3. Do examples 1,2,3 of Exercise 3.3 using divided differences. 4. Prove
[XoXl ••. x,,] =
,,-I
I
Xo
Xo
x.
X,.
Xo
t
•••
ft.-I
x"
Yo
Y.
....:...._....;:..-=---:--....;:..-....:...;;;..-
I
Xo
xo·
...
xo"
Xl
XII...
Xl"
S. If y = f(x) = I/x, then [XoXl ... x,,] = (-I)"/xoxl •..
X" •
6. If y = f(x) = x", then [XoXl •.. x,,] = 1. 7. If y = f(x) = x"+1, then [XoXl •...~,,] = Xo
+
Xl
+ ... + X".
8. The divided difference of the sum of two functions is the sum of the corresponding divided differences. 9. A divided difference of cf(x) equals c times the corresponding divided difference of f(x), where c is a constant.
to.
Derive the equality 3.4:9 by mathematical induction.
3.5. Polynomial through n + 1 Points; Aitken-Neville Forms. The polynomial through the n + 1 points (3.5: 1)
+
3.S. POLYNOMIAL THROUGH n
1 POINTS; AITKEN-NEVILLE FORMS
8S
can be obtained in yet another form. Let
(3.5:2) be r
+I
of the n
+I
points, and, introducing a new notation, let
(3.5:3) be the polynomial through the first r points of 3.5:2 and
(3.5:4) the polynomial through the last r points of 3.5:2. Then
(3.5:5) is the polynomial through all r for 0 ~ j ~ r, Y(Xi j )
=
(Xij -
Xio)
+ 1 points q(Xi,) - (Xi j X - X i.
of 3.5:2. Indeed, we have -
Xi.) P(Xi j )
io
Hence
(3.5:6)
In particular, if we put {Xk} = Yk' then {Xio}
= Yio ' (x -
{XioXil }
Xio){Xil } -
(x -
Xil){Xio}
= ----'---=-------'-_..:.... 1
=. X·
'I
Xii -
Xio
I
Xio
X -
-x·'0 x-x. I
'I
{x;o}
{x} l i
,
86
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
are the polynomials through the first, the first two, and the first three points of 3.5:2, respectively. Analogous to the divided difference table, we can form polynomial tables; in particular, the tables (illustrated for n = 5): Xo
{Xo}
Xl
{Xl}
XI
{XI}
{XoX.}
{XoX1X.}
Xa X,
{Xa}
{XoXa}
{XoX1Xa}
{X,}
{xoX,}
{XoX1X,}
{XoX1XaX,}
{XoX1X.XaX,}
X,
{X,}
{xoX,}
{XoX1X,}
{XoX1X.X,}
{XoX1X.XaX,}
Xo
{Xo}
Xl
{Xl}
{XoXl} {XoX1XaXa} {XoX1X.XaX,xa}
and
{XoXl} {XoX1X I} {XiX.} XI
{XI}
{XoX1XaXa} {X1X.Xa}
{X.Xa} Xa
{Xa}
X,
{X,}
X,
{X,}
{XoX1X.XaX,} {XoX1XaXaX,X,}
{X1XaXaX,} {X1XaXaX,X,}
{XaXaX,} {xaX,}
{x.x.x,x,} {XaX,X,}
{x,x,}
In each table, the sequence of polynomials at the top of each column, after the first, is precisely the sequence of polynomials 3.4: 19. The process of interpolation based on the first table is due to Aitken, the process based on the second is due to Neville. The particular virtue of these forms of the (n + I)-point polynomial lies not in the form of the polynomial itself which is, as a matter of fact, rather unwieldy, but in the simple and repetitive nature of the process of interpolation that ensues.
3.6. COMPUTATIONAL FORMS
87
3.6. Magnitude of the Error in the Polynomial through n + 1 Points. Computational Forms. We found, in the last four sections, four different ways of writing the polynomial (3.6: 1)
of max-degree n whose graph passes through the n
+ 1 points
(3.6:2)
with distinct abscissas. If no further information is available concerning the n + I points, nothing further can be said about Pn(x) as far as approximation or interpolation is concerned. But if it is known that the n + I points also lie on the graph of a function (3.6:3)
y
= f(x),
then it is natural to regard Pn(x) as an approximation, in some sense, to f(x). In particular, we may regard Pn(x) as an interpolating polynomial for f(x), that is, for a value x' of x, f(x') can be approximated by evaluating Pn(x'). We will then want an estimate of the magnitude of the error E(x) = f(x) - Pn(x) at x = x'. To this end, put y' = f(x'). Construct the polynomial through the n + I points 3.6:2 and the point (x', y') by the method of divided differences. If Pn+l(x) is this polynomial and if x' is the last entry of the first column of the difference table used in its construction, then it follows from the form of equation 3.4: 16 that (3.6:4)
Since f(x') = Pn+l(x'), we have f(x') - Pn(x') Consequently,
= Pn+l(x') - Pn(x').
(3.6:5)
The magnitude of the error in approximating f(x') by Pn(x') will then be determined if a value for [XOXI ... xnx'] can be found. We proceed to attack this problem. The form of the identity 3.6:5 suggests an examination of the function
This function vanishes for the n + 2 distinct values xo , Xl , "', Xn , x' (we may suppose that x' is distinct from the other x's, otherwise, E(x') = 0); hence by Rolle's theorem, tp'(x) will vanish for at least
88
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
n + 1 distinct values of x; tp"(X) will vanish for at least n distinct values of x; and so on to tp(n+ll(x) which will vanish for at least one value of x, say X. [We assume thatf(x), and consequently tp(x), possesses all the necessary derivatives.] But from the definition of tp(x) it follows that tp(n+lI(X) = j«n+ll(x) - [XoXl ... xnx'](n + 1)1,
since Pn(x) is a polynomial of max-degree n and the coefficient of the divided difference is a polynomial of degree n + 1 whose leading coefficient is unity. Hence , j«n+lI(X) [XoXI'" xnx] = (n + I)! '
(3.6:6) and substituting error E(x'),
(3.6:7)
E(x')
In
3.6:5, we obtain the desired expressIOn for the
= f(x')
- Pn(x')
=
j«n+lI(X) (n + 1)1 (x' - xo)(x' -
Xl) ...
(X' - xn),
where X is some value between the smallest and the largest of the numbers Xo , Xl , "', Xn ,x'. (Compare this result with the error term in the previous case, formula 2.2:8.) The number X is not known in actual practice, hence it is customary to replace pn+lI(X) by the maximum absolute value of pn+ll(x) in the interval in question. As a rule, this replacement causes an exaggerated estimate of the error. Formula 3.6:6 deserves some special comment. Let us first rewrite it as
(3.6:8)
[XoXl ... xn]
=
j«nl(X) - - I-
n.
.
This formula reduces for n = 1 to the Theorem of the Mean for derivatives, hence the formula may be thought of as a generalization of the theorem. Furthermore, if f(x) is a polynomial of max-degree n - 1, then
and if f(x) is a polynomial of max-degree n, then
where an is the coefficient of xn in f(x).
89
3.6. COMPUTATIONAL FORMS
The last two results are restated and rounded out in the THEOREM.
If
are arbitrary but distinct numbers and
XO ' Xl , ••• , X"
Yo, YI , ... , y" are the corresponding y's determined by the polynomial y = ao + alx
+ ... + a"x",
then
(3.6:9) and conversely, if y = f(x) is a single-valued function defined for every x, and if for every set Xo , Xl , ••• , X" of n + 1 distinct numbers and the corresponding set Yo, YI , ... , y" determined by f(x) Eq. 3.6:9 holds, then f(x) is a polynomial of max-degree n whose leading coefficient is an . The proof of the converse is immediate. Let p,,(x) be the polynomial of max-degree n determined by Xo , Xl , ••• , X" and the corresponding Yo = f(x o), YI = f(x l ), ... , y" = f(x,,). Let x' be a number distinct from Xo , Xl , ••• , X" • Since by assumption all nth-order differences are constant, all (n + l)st-order differences are zero, and hence, by 3.6:5, p,,(x') = f(x:); or f(x) = p,,(x). We illustrate some of the preceding ideas by two examples. EXAMPLE 1. The following values are taken from a table of the exponential function:
y:
eZ
\_0-2-.7-18-7-.3-28-9-54-.5-:-8
The divided difference table is: 0
1.000 1.718 2.718
1.477 4.671
2
7.389
4
54.598
1.209 6.311
23.605
Hence y
=
1 + 1.718x + 1.477x(x - 1)
+ 1.209x(x -
1)(x - 2)
is an interpolating cubic for eZ through the four given points. For = 3, the cubic yields the value 22.27 which is not a particularly good
X
90
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
approximation to e3 = 20.09. The maximum error as predicted by formula 3.6:7 is I 55(3 - 0)(3 - 1)(3 - 2)(3 - 4)/4! I = 14-. EXAMPLE
2.
We obtain from the same table:
I
x y
=
eZ
0.6 1.822
~
0.7
0.8
2.014
2.226
1.0
2.718
The divided difference table is: 0.6
1.822
0.7
2.014
1.92 1.00 2.12 0.8
2.226
0.33 1.13
2.46 1.0 2.718
The interpolating cubic is y
=
1.822
+ 1.92(x -
0.6)
+ 1.00(x -
0.6)(x - 0.7)
+ 0.33(x -
0.6)(x - 0.7)(x - 0.8);
at x = 0.9, Y = eO. 9 = 2.460. The estimated maximum error is 12.718(0.9 - 0.6)(0.9 - 0.7)(0.9 - 0.8)(0.9 - 1.0)/4!
I=
0.0001-.
Actually, the answer, 2.460, is correct to four significant figures. The error given by formula 3.6:7 in approximating f(x') by p,,(x') is the error inherent in the method of polynomial approximation. There are, however, still other sources of error. In the first place, the coordinates of the n + 1 points 3.6:2 may not be exact. If the points arise as recorded data of some experiment, then both the x's and the y's are likely to be inexact; if the y's are values of a function taken from a table for the corresponding x's, then the y's alone are inexact. Again, there are the accumulative errors inherent in all computations. In all cases, if we assume that the approximate numbers are written so that all their significant figures are correct, the errors due to computation and inexact data can be computed by the methods of Chapter I. Although these errors, which for want of a better name we shall call the computational errors, are usually negligible, they should be considered, particularly when the number of points is large.
91
3.6. COMPUTATIONAL FORMS
It should be further remarked and carefully noted that the estimation of the error committed in approximating f(x) by p,,(x) at x = x' as given in formula 3.6:7 depends on the existence of p"+ll(X) in the neighborhood of x = x'. If the (n + l)st derivative does not exist, the formula, of course, can not be used. There is, however, an important special case where we can say something definite about the magnitude of the error even though p"+ll(x) does not exist, or if it exists, is not known. Let us refer back to the equality 3.6:5; it is an expression for the error which involves the unknown quantity [XOXI ... X"X']. If we assume, as we did, that f(x) possesses an (n + l)st derivative, we are led to the evaluation of [XoXl ... X"X'] given by 3.6:6. If the abscissas Xo , Xl' "', x" ,X' all lie within an interval [a, b], say, then X also lies in [a, b]. If these abscissas are replaced by n + 2 other (distinct) abscissas lying in [a, b], then the corresponding X' will also be in [a, b]. If the interval [a, b] is sufficiently small, f'n+ll(x) will not vary greatly for different points within it; that is, P"+ll(X) and p"+ll(X') will be almost equal. In other words, the right member of 3.6:6 determined by the particular set of n + 2 abscissas XO, Xl , "', X" ,X' may be taken as a good approximation to the (n + l)st order divided difference determined by any set of n + 2 distinct points within the interval [a, b]. These observations lead us to the following conclusion. Suppose that we can prove, or have reason to believe, that for a given function f(x) and for any set of n + 2 distinct numbers Xo , Xl , "', X" , X' within an interval [a, b] there exists a positive constant K such that the inequality
(3.6:10)
1
[XoXl ... xnx']
1
< (n : I)!
holds, then we have (3.6:11 ) 1
E(x')
1
= If(x') - Pn(x') 1 .::;:; (n :
I)! 1 (x' - xo)(x' -
Xl) ...
(X' - Xn) I·
This last expression for the magnitude of the error does not involve the (n + l)st derivative. Another method of approach is also of interest. The statement (3.6:12)
f(x)
= Pn(x) + pn+ll(X) (x - xo)(x(:- :l~;!" (x - xn )
is an identity provided that the (n + l)st derivative exists and X is properly chosen. A consideration of the derivation of X reveals that it is a function, usually multivalued, of X O , Xl , "', X" and x. Since
92
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
Xo , Xl , ... , Xn are constants in a particular problem, X may be regarded as a function of X only and hence j«n+l)(X) is a function, usually multivalued, of x. Let tp(x) be one branch of this function, then we may write
f( )
(3.6:13)
=
X
() Pn X
( ) (x -
+ cp X
xo)(x -
(n
Xl) ... (X -
+ 1)1
Xn)
•
The last form was obtained on the assumption that pn+l)(x) existed in a certain interval [a, b]. On the other hand, we can write the form just above whether the derivative does or does not exist and we have there a usable estimate of the error in approximating f(x) by Pn(x) provided we know something about tp(x). In particular, if in the interval [a, b], I tp(x) I < K, we are back to the estimate given in 3.6: 11. The determinant 3.2:7, the Lagrange interpolation formula 3.3:3, the divided difference form 3.4:16, and the last entry, {XoXl ... x n }, in the Aitken-Neville tables are all the polynomial through the n + 1 points (xo , Yo), ... , (x n , Yn). Each form has its particular uses, advantages, and disadvantages. The determinant form is easy to differentiate and is convenient for some special purposes, but as a rule, it is seldom used for either approximation or interpolation because of its unwieldy nature. The Lagrange form is good for further theoretical purposes and is most convenient for interpolation for a single value of the argument. The divided difference form is also good for further developments and is convenient for interpolation if many values are desired. The AitkenNeville process is cumbersome if the polynomial is wanted, but is convenient for interpolation for many values of the argument. The various methods and convenient forms for the arrangement of the computations, are exhibited in the example below, an elaboration of example 2. EXAMPLE 3.
Find e0,8, given:
__X_I y =
e~
0.6
0.7
0.8
1.0
1.3
I 1.82212 2.01375 2.22554 2.71828
1.4
3.66930 4.05520
The Lagrange form yields, for the interpolation, (2)(1)(1)(4)(5) (3)(1)(1)(4)(5) (1)(2)(4)(7)(8) 1.82212 - (1)(1)(3)(6)(7) 2.01375 (3)(2)(1)(4)(5)
+ (4)(3)(2)(3)(4) 2.71828 =
2.45960.
(3)(2)(1)(4)(5)
+ (2)(1)(2)(5)(6) 2.22554
(3)(2)(1)(1)(5) (7)(6)(5)(3)(1) 3.66930
(3)(2)(1)(1)(4)
+ (8)(7)(6)(4)(1) 4.05520
93
3.6. COMPUTATIONAL FORMS
Some ISO steps are required (each addition, subtraction, multiplication, and division is counted as one step; the tabulation or recording of a number is not counted), but many of the steps here can be done mentally. If this form were to be used for the evaluation of ez for several values of x, the fractions -1.82212/(0.1)(0.2)(0.4)(0.7)(0.8), ... , which remain constant, would be calculated first, and then the multipliers (x - 0.6)(x - 0.7) ... (x - 1.4), ... , for each value of x. After the fractions are evaluated, each y can be found with the expenditure of about 65 steps, most of which can be done mentally. To evaluate eo.B by means of divided differences, we first form the array:
0.6
1.82212
0.7
2.01375
1.91630 1.00800 2.11790 0.8
2.22554
0.36167 0.10254
1.15267 2.46370
1.0 2.71828
0.43345 0.11789
3.17007
1.3
0.01919
1.41274
3.66930
0.51597 1.72232
3.85900 1.4 4.05520
Then (we will use the forward difference form 3.4: 17), we evaluate 1 I' x 1 x -
Xo 1
x -
II
Xl
(x - xo)(x -
Xo
x -
(x - xo)(x -
Xl)
X"_l Xl) •••
(x -
X"_l)
Here, for x = 0.9, 1 1 0. 3
1
0.21
1 0:31 0.06
0.1 0.006
I I
-0.1 -0.0006
-0.4 0.00024
The entries in the second row are multiplied into the corresponding entries of the uppermost descending diagonal of the divided difference table, and the results added to yield 2.45960. It takes 45 steps to compute the difference table and about 20 more steps to reach the final result. Since the same divided difference table can be used to evaluate additional values of ez (in the range 0.5 ::::;;; x ::::;;; 1.5), only 20 steps are necessary to calculate each additional value.
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
94
The tables for the Aitken and Neville processes are: 0.6 0.7 0.8 1.0 1.3 1.4
0.3 0.2 0.1 -0.1 -0.4 -0.5
1.82212 2.01375 2.39701 2.22554 2.42725 2.71828 2.49424 3.66930 2.61377 4.05520 2.65952
0.6
0.3
1.82212
0.7
0.2
2.01375
2.45759 2.46183 2.46926 2.47201
2.45966 2.45984 2.45991
2.45960 2.45960
2.45960
and
2.39701 2.45749 2.43733 0.8
0.1
2.22554
2.45966 2.46038
2.47191 1.0
-0.1
2.71828
1.3
-0.4
3.66930
1.4
-0.5
4.05520
2.45960 2.45960
2.45951 2.45778
2.40127
2.45960 2.45984
2.47016 2.12570
respectively. Each takes about 65 steps to reach the answer 2.45960, and, because of the nature of the process, will take exactly the same number for the calculation of additional values. Note that a column of differences 0.9 - 0.6 = 0.3, 0.9 - 0.7 = 0.2, ···,0.9 - 1.4 = -0.5, has been inserted between the column for x and that for {x}. In the Lagrange and divided difference processes, we obtain, so to speak, the interpolating polynomials first and then we substitute the value of the argument; in the Aitken-Neville processes, the answer is obtained by immediate use of the value of the argument. All the methods are repetitive in nature and hence are convenient for the computor and lend themselves for automatic machine computation; the AitkenNeville processes are repetitive in "purest" form since, after the evaluation of the differences, each stage is a calculation of the form (ab - cd)/e. The error inherent in polynomial approximation can, of course, be estimated by the methods of the first half of this section, but the divided difference and Aitken-Neville processes have built-in error indicators. The top entries in the columns of the Aitken-Neville tableaux and the successive sums in the last stage of the divided difference
EXERCISE
9S
process are precisely the values of the polynomials of 3.4: 19 for the given value of the argument. Hence, if these values are unaltered at the end, as in the example above, we are assured that the error inherent in the interpolation process is too small to affect the last significant digit. Since rounding-off errors may mount up, some computers use one, sometimes two, significant digits more in their computation entries than in the given data to reduce the rounding-off errors; the final answer is, of course, written with the proper number of digits. This was not done in the example worked out above; the final answer is, nevertheless, correct as far as it is written. EXERCISE 1.6
t. Find by use of the determinant form, the Lagrange formula and the method of divided differences, the cubic polynomial determined by each set of points. a.(-3,-I), (-2,2), (1,-1), (3,10); b. (- 3.10, -1.05), ( -1.98, 2.13), (1.01, -0.83),
(2.64, I Q.42).
2. Find by use of the Lagrange formula and the method of divided differences, the polynomial of. max-degree determined by each set of points.
a. (-5,87), (-1,7), (0, -3), (2, -II); b. (-5, -8.345), (-3, 1.756), (0, -2.003),
(1,7.984).
1. Find, by any method, the polynomial P.(x) which has the same values as x' at x = -I, 0, I, 3. Approximate 2' by evaluating P3(2) and estimate the error. What is the actual error? Approximate 2 5 by the Aitken-Neville processes using the given values of x and the corresponding values of y. 4. Find the polynomial equation y = pz(x) whose graph intersects the graph of y = sin x at x = 0, .,/4, .,/3. Use pz(x) to approximate sin (.,/6), sin (.,/2), sin 200. Estimate the respective errors and determine the actual errors. Find each of the required values by the Aitken-Neville processes from the given data.
Sa. Find the equation of the parabola which intersects the cosine curve at 100, 20 0, 400 (use a five-place cosine table). Calculate the value of cos 300 from the polynomial equation. What is the actual error? the predicted error? b. Same problem as a, but this time use the equation of the quintic which coincides with the cosine curve at 0 0, 100, 200, 400, 500, 600. c. Same problem as a, but this time use the equation of the parabola which coincides with the cosine curve at 20 0, 25 0, 35 0. 6. Find the missing entries and estimate their margins of error wherever possible.
x a.--y
=
e z/Z
I-I
i 0.6065
x_i_a
b. _ _ y = r/Z 11.0000
0
2
1.0000
2.7183
1.2
1.4
1.8221
2.0138
3
7
5 12.1825 1.6
1.8 2.4596
2.0
96
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
arcsin k
c.
r.'1 o
d.
6°
5°
d~
VI - k' sin ' ~
I
Day 1 Altitude of star 46°15'
1.5738 2
7°
8°
1.5767
1.5785
3
46°25'
4 47°02'
7. The following table is self-explanatory:
vx correct to: (I)
2 sig fig (2)
3 sig fig (3)
4 sig fig (4)
5 sig fig (5)
6 sig fig (6)
7 sig fig (7)
8 sig fig (8)
900 950 1000 1050 1100 1150 1200 1250 1300
30 31 32 32 33 34 35 35 36
30.0 30.8 31.6 32.4 33.2 33.9 34.6 35.4 36.1
30.00 30.82 31.62 32.40 33.17 33.91 34.64 35.36 36.06
30.000 30.822 31.623 32.404 33.166 33.912 34.641 35.355 36.056
30.0000 30.8221 31.6228 32.4037 33.1662 33.9116 34.6410 35.3553 36.0555
30.00000 30.82207 31.62278 32.40370 33.16625 33.91165 34.64102 35.35534 36.05551
30.000000 30.822070 31.622777 32.403703 33.166248 33.911650 34.641016 35.355339 36.055513
x
•• The positive square root of 930 is computed by linear interpoilltion to 2. 3..... 8 significant figures. respectively. by successive use of the entries in columns 2. 3... ·.8. At what point does the error inherent in linear interpolation exceed the rounding-off error? Obtain your answer by use of the appropriate formula and check it by evaluating v930 from as many entries as are necessary in the last column. b. Calculate V1010 from the entries in column 4. c. Calculate V1258 from the entries in column 6. d. Calculate V1034 from the entries in column 8. e. The following pairs of square roots are evaluated from the entries in column 7:
vi0i2. V1013; ViOi2.T. VlOI2.2; v'i0i2.i4. V1o'i2.i"S; V1012.136. VI012.1361.
V1012.1362;
V1012.13606.
VI012.13607;
VI012.137;
VI012.136064.
V1012.136065. At what point is it no longer possible to distinguish between the two values in a pair? How many significant figures do the entries in a table of square roots need to distinguish between the roots of the last pair? ... A table of natural sines to five decimal places is given with entries at one degree intervals. What is the maximum error of linear interpolation. both direct and inverse? b. Same as problem a. if entries are given for every minute. c. Same as problem a. if entries are given for every second. 9. Same as problem 8. if entries are given to ten decimal places.
3.7. EQUALLY SPACED POINTS; FINITE DIFFERENCES
to.
97
Same as problem 8, if a log sin table, to five decimal places, is used.
t t. Same as problem 8, if a log tan table, to five decimal places, is used. t2. Linear interpolation is inaccurate for log sin x for very small angles. What degree interpolation will suffice for interpolation in the range 10 < x < r if a five place table with entries at minute intervals is used?
t3. If y = f(x) has a continuous nth derivative, and x, approaches Xo , i prove lim [Xo:&l ••• x,,] = j1n'(xo)/nl. [Hint: use 3.6:8.]
=
I, 2, ... , n,
t... If y = f(x) has a ,. + 1 times, to be the [xo:&o ... X1Xl distinct.
••
continuous nth derivative, define [xoxo··· xo], where Xo occurs limit in the preceding example. Use this definition to define x"xt ...], where x, occurs n, times, i = 0, I, ... , k, and Xo , Xl , ••• Xt are
tSa. Form the complete divided difference table for the function Xi for the values x = I, I, 1,2,4,7. b. Form the complete divided difference table for the function V x - I for the values x = 5,5,5,10,17,17. t6. Find the polynomial equation y = p(x) of max-degree 3 whose graph intersects the graph of y = In x at x = 2, 5, and which is tangent to it at x = 1. [Hi,.t: use the divided difference table for x = I, 1,2,5.] t7. Find the polynomial of max-degree 4 which has third order contact with cos x at x = O. Compare your answer with the Maclaurin expansion of cos x.
3.7. Equally Spaced Points; Finite Differences. It frequently happens that the abscissas of the n + I points 3.6:2 are equally spaced, particularly when the y's are tabulated values of a function for successive values of the argument x. The points themselves will be called equally spaced when the abscissas are equally spaced. In these cases, the formulas of the preceding sections can be rewritten in more convenient forms. Let the notation be chosen so that Xo < Xl < ... < x".' and let the x's be equally spaced so that
i = 0, 1, ... , n - 1,
(3.7:1) say. Then
(3.7:2)
Xi
=
Xo
+ ih,
i = 0, 1, ... , n;
and
(3.7:3)
i, j = 0, 1, ... , n.
Divided differences are usually replaced by the more convenient finite differences when we work with equally spaced points. They are defined as follows: a first-order finite difference is defined by
(3.7:4)
98
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
a second-order finite difference is defined by
(3.7:5) and, in general, an rth-order finite difference is defined by
(3.7:6) Finite differences are more convenient than divided differences because they do not involve divisions. There is a finite difference table for finite differences analogous to the divided difference table discussed in Section 3.4. The general finite difference table will have the appearance of the array: Xo
Yo ..::IYo
x, Y,
..::IzYo ..::Iy,
Xz
..::1 3"0 ..::I.",
Yz ..::IYz
X3 Y3
For example, the finite difference table for the previously given data '\ 0.4
x Y =
e~
0.6
1.492
0.8
1.0
1.822 2.226 2.718
IS:
x
Y
0.4
1.492
0.6
1.822
..::Iy
..::I."
..::I 3y
0.330 0.074 0.404 0.8
2.226
0.014 0.088
0.492 1.0 2.718
A finite difference LlrYk in a finite difference table is a vertex of a triangle whose other two vertices are Yk and Yr+k . Each of the formulas 3.7: 13-15 below can then be interpreted as an expression for a vertex of this triangle in terms of the elements of the side opposite.
3.7. EQUALLY SPACED POINTS; FINITE DIFFERENCES
99
It follows directly from the definitions of the divided and the finite differences and from 3.7:3 that [xoxll = LJYo/h, [xoxlx21 = LJ2Yo /2!h 2; by induction it can be shown that -..., ... x ] _ .1'yo [x 17'"1 , rlh' .
(3.7:7)
Although finite differences for y's corresponding to nonconsecutive or nonequally spaced x's can be defined, they are rarely used and it is not necessary to express the more general divided difference 3.4:8 in terms of finite differences. However, the subscripts in 3.7:7 can all be raised (or lowered, if it is convenient to use negative subscripts) by an arbitrary integer, hence we can rewrite it in the more general form [ X12x 12+1 ... x 12+'] _- .1'YI2 rlh' ,
(3.7:8)
where a is any integer. It follows from 3.4:9 and 3.7:3 that (3.7:9)
1 r . -..., ... x] ~(-I)'-i Y. [x 17'"1 , h' i-O ~ ·I( - I·)1. • I r
Combining the last equation with 3.7:7, we obtain (3.7:10)
.1'Yo =
±
(-I)'-i
i-o
(~) Yi ,
r = 1,2, ... , n,
I
an expression for the rth-order finite difference in terms of the y's. This expression can be written in the symbolic form (3.7:10')
.1'Yo
= (-1 + y)"
r = 1,2, ···,n,
where (-1 + y), means the expression obtained by expanding (-1 + y)' by the binomial theorem and then changing the exponents on the y's (including the exponent 0) to subscripts. Conversely, to express y, in terms of the finite differences Yo , LJyo , ... , LJ'yo (we may regard Yo as a Oth-order finite difference), we eliminate Yo, Yl , ... , y,-l from the r + 1 equations obtained from 3.7:10 by putting r = 0, 1, ... , r in turn; we obtain (3.7:11)
r
= 0, 1, ... , n,
100
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
which can be put into the symbolic form (3.7:11')
Yr
=
(1
+ .dYYo ,
r
=
0, 1, ... , n.
In a similar manner we can obtain the formula (3.7:12)
r
=
0, 1, ... , n,
r
=
0, 1, ... , n.
which in symbolic notation becomes Yo = (-.d
(3.7: 12')
+ yy,
Formulas 3.7:10--12 can be slightly generalized by stepping up, or down, each subscript by the same integer. We obtain (3.7:13)
r
=
(3.7:14)
r
= 0, 1, ... , n;
(3.7:15)
r
= 0, 1, ... , n.
1,2, ... , n;
From formula 3.7:7 and the theorem in Section 3.6, we have immediately the corresponding: If Xo , Xl Yo, Yl' ... , y" y = a o alx THEOREM.
and
+
+ ... +
(3.7:16)
and conversely.
are equally spaced numbers 'With Xi+l - Xi = h, the corresponding y's determined by a"x", then
, •.• , X"
are
.d"yo = n!h"a,.;
3.B. POLYNOMIAL THROUGH n
+
101
1 EQUALLY SPACED POINTS
EXERCISE 3.7
t. Form the complete finite difference table for each of the following sets of numbers.
••
(-3,1.76),
b. (10, 7S.54),
c.
d.
xl
~I ~I
e.
(3,2.S9) (II, 95.03), (12, 113.10), 3.2
3.0
(13, 132.73) 3.4
-3.025
- 3.000
-2.965
-2
-1
0
yl
Xl
(0,0),
0.S102
0.S059
9.1
~12.43
3.S
3.6 -2.922
-2.S74 2
0.8025
0.S036
0.S019
9.2
9.3
9.4
9.5
9.6
2.47
2.49
2.46
2.44
2.45
1. Obtain the values of log sin x from a five-place table; then form the complete finite difference table for log sin x for each of the following sets of values of x: •• 20°,40°, 60°, SO°, 100° b. 2",4°, 6°, So, 10° c. So, SOlO', S020', S030', S040' d. So, SOl:, S02', S03', S04'. e. Discuss the effecta of polynomial approximation errors and rounding-off elrors on the entries of the tables. 3. Derive the identity 3.7: 10 directly from the definitions 3.7:4-6, that is, without using divided differences.
3.•. Polynomial through n + 1 Equally Spaced Points. In this section we obtain the expressions for the polynomials through n + I points when the latter are equally spaced. Although the preceding formulas can be used, the new expressions will be simpler. When we deal with equally spaced points, it is frequently advantageous to replace the variable x by a variable u linearly related to x by the equation
(3.8:1)
or
u
1
= h (x -
xo)'
Hence
(3.8:2)
x-
Xt
= (u -
i) h,
i = 0, 1, ... , n.
If we substitute the values given by 3.7:3 and 3.8:2 in the Lagrange coefficient 3.3:2, we obtain, after simplification,
(3.8:3)
Li(X)
=
.H
(-1)
u(u - 1) ... (u - i
+
1)(u - i - I ) ... (u - n) il(n _ i)1 '
i = 0, 1, "., n;
102
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
or
i = 0, I, ... , n.
(3.8:4)
The Lagrange interpolation formula then becomes
(3.8:5)
Y
u )n
+ I) (n + 1 ~
= (n
( -I )n-i
u_ i
(n)i Yi·
Note that this form of the interpolating polynomial through the n + 1 equally spaced points cannot be used for u = i because of the presence of u - i in the denominator; we know, however, that y = y., for u = U i . EXAMPLE 1.
Find the value of eo.? from the following set of values:
_x_/ y
Here, yields
Xo =
=
e'l
0.4
_0_.6_ _ 0._8_ _ __
1.492
0.4, h = 0.2,
x =
1.822 2.226 2.718
0.7,
U =
I,
n =
3. Formula 3.8:5
1.5) 3 (_I)H (3 y=4 ( 4 ~1.5-i i)Yi=2.014,
which is correct to four significant figures. Extensive tables have been prepared which list the values of Li(x) for various ranges of U and n (see, for example, Natl. Bur. Standards, "Tables of Lagrangean Interpolation Coefficients," Columbia Univ. Press, New York, 1944). The use of these tables greatly facilitates the process of interpolation. We next obtain the equation of the polynomial through the n + 1 equally spaced points in terms of finite differences. It follows at once from 3.8:2 that
(3.8:6)
(x - xo)(x - Xl) ... (X - X,_l)
= u(u - I) ... (u - r = rl (:) hr,
+ I) hr
r = 1,2, ... , n
+ 1.
Using this and 3.7:7 in 3.4: 17, we find that
(3.8:7)
Y
n . (U).. = ~.1·Yo
i-O
'
We also have from 3.7:3 that (x - xa)(x - xa+l) ... (x - Xa+,_l)
(3.8:8)
=
(u - a)(u - a-I) ... (u - a - r
+ I) hr
r= I,···,n-a+ 1.
3.S. POLYNOMIAL THROUGH n
+
1 EQUALLY SPACED POINTS
103
Using this and 3.7:8 in that form of the interpolating polynomial generated by the sequence chain 3.4: 13, we obtain (3.8:9)
(U -
n
=
Y
k.1 iYn_i
n
+. i-I) •
i-O
'
In a similar manner we derive the formulas below from the formulas 3.8:8, 3.7:8, and 3.4:14, 15 for n = 2m: (3.8:10) Y
=
~ 2' ~.1 IYm_i
m - 1+
(U -
2i
i-O
~.1 m
2' I
2i
Ym-i
(U -
m
2i
+ i)
+ ~.1 m
and from 3.4:14', 15', for n = 2m (3.8:10') _ Y -
m - 1+
(U -
2i _ 1
i) .'
i-I
(3.8:11) _ Y -
i) + ~ ~.1 I-Ym+1_i
mI' A2i (U - m 2i- + ') ~ ~ Ym-i ~
(U -
2i-1
Ym-i
m - 1+
2i _ 1
i) .'
+ 1, m+l
~
+ ~~
(U Ym+1-i
A2i-1
m-
2i -
1
. + ') .' 1
(3.8:11') _ Y -
m I ' .12i (U - m 2i- + ') Ym+1-i
~
-4 1=0
The variables Xo , Xl , in the respective orders
... , Xn
XO '
xI
Xn ,
Xn _ 1 , .. ',
,
... ,
Xn ; Xo; X m +2
, ... , X n ,
Xo;
Xn;
Xm+l ,
Xm+l , Xm_ l ,
X m - 2 , ••• , X o , X m +2,
Xn;
,
X m +2 ,
X m _ l , ••• , X n ,
Xm+ l ,
,
Xm_ l ,
Xm ,
Xm+l,
appear in formulas 3.8:7, 9-11, 10'-11'
Xm_ l ,
Xm , Xm
m I ' ~ .12i+1 (U - 2im+- I + ') . + 1=0 -4 Ym-i
Xm
... , X o ,
XO'
Formula 3.8:7 is known as Newton's Interpolation formula with forward differences; formula 3.8:9 is known as Newton's Interpolation formula with backward differences; the remaining formulas are known as the Gauss' formulas or central difference formulas. We wish to stress the fact that for a given n, Eq.3.8:7, 9-11 (or 10' and 11') are only different forms of the same polynomial through
104
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
the n + 1 points 3.6:2. Why, then, do we bother with this multiplicity of forms? We postpone the answer for a moment and turn first to the equation for the magnitude of the error. The magnitude of the error in the general case was given in formula 3.6:7. If in that formula we use 3.8: 1 and 3.8:6, we obtain the following expression whose absolute value is an upper bound of the magnitude of the error for equally spaced points, (3.8:12) where, as before, X is a value between the smallest and largest of the numbers Xo , Xl , ... , Xn , X' and where u = (x' - xo)/h. Let us again remark that consideration should be given not only to the error above inherent in polynomial approximation but also to the computational errors due to the use of inexact values of the coordinates of the n + 1 points and to those that accumulate in the process of computation. Formula 3.8:12, like formula 3.6:7 from which it was derived, is meaningless if the (n + l)st derivative does not exist. We recall that the expression 3.6: 11, which may be rewritten as (3.8:12') can then take the place of 3.8:12. We illustrate the use of the preceding formulas by an example. The values of y = sinh x for x = 1.50, 1.60, "',2.60 are taken from a table of hyperbolic sines. We wish to compute the values of sinh 1.52, sinh 2.03, sinh 2.54. We form first the finite difference table on the next page. (In practice, it is usual to omit the decimal point and the zeros in front of the first significant figure in writing the numbers in the difference columns.) We use 3.8:7 for the computation of sinh 1.52; we have x' = 1.52, Xo = 1.50, h = 0.1, u = 0.2, n = 5; (i) = 0.2, Gt) = -0.08, (3) = 0.048, (4) = -0.0336, = 0.025536; whence
m
sinh 1.52
= 2.12928 + 0.2(0.24629) - 0.08(0.02377) + 0.048(0.00271) -0.0336(0.00026)
+ 0.025536(0.00003)
= 2.17676. The answer is correct as far as it is written.
3.8. POLYNOMIAL THROUGH n
Ay
sinh x
x
+
105
1 EQUALLY SPACED POINTS
A2y
A8y
Aty
Aiy
1.50 2.12928 0.24629 0.02377
1.60 2.37557 0.27006
0.00271 0.02648
1.70 2.64563 0.29654 1.80 2.94217 3.26816
2.00
3.62686
0.00326 0.03271
0.35870
0.00359
0.39500
0.00395
0.43525
0.00435
0.47985
5.46623
-0.00001
0.00482 0.00046 0.00528 0.05470
0.58397 2.50 6.05020
0.00007 0.00047
0.04942 0.52927
2.40
0.00004 0.00040
0.04460
2.30 4.93696
0.00003 0.00036
0.04025
2.20 4.45711
0.00004 0.00033
0.03630
2.10 4.02186
0.00003 0.00029
0.02945 0.32599
1.90
0.00026 0.00297
0.00012 0.00058
0.00586 0.06056
0.64453 2.60
x'
6.69473
We use formula 3.8:9 for the evaluation of sinh 2.54. We have = 2.54, xo = 2.10, h = 0.1, u = 4.4, n = 5; sinh 2.54 = 6.69473
+ 0.64453 (-~.6) + 0.06056 (°24) + 0.00586 Cj4)
+ 0.00058 (244) + 0.00012
et)
= 6.30039. The result is in error by one unit in the last decimal place. If we omit the suspicious last term (just why it is suspicious will develop later), we get the value 6.30040 which is correct to all five decimal places. Finally, we compute sinh 2.03 by use of formula 3.8: 10' (formula 3.8:11' may also be used). We have x' = 2.03, xo = 1.80, h = 0.1, u = 2.3, n = 2m + 1 = 5; sinh 2.03 = 3.62686 + 0.39500 (Oi 3) + 0.03630 3) + 0.00395 (l j3)
(°2
+ 0.00036 C43) + 0.00004 e53) = 3.74138.
106
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
The last term can be omitted without affecting the answer which is correct to six figures. We compute sinh 1.8276 as an additional illustration. We use formula 3.8: 10' again with x' = 1.8276, Xo = 1.60, h = 0.1, u = 2.276, n = 2m + 1 = 5; we obtain sinh 1.8276 = 2.94217
+ 0.32599 (;76) + 0.02945 (;76)
+ 0.00326 (;76) + 0.00029 (;76) + 0.00004 e·~76) = 3.02909. The correct result to five decimal places is 3.02907. The solutions of the preceding examples require some further explana- . tions in answer to some questions which undoubtedly have arisen in the minds of some readers. Why was the finite difference table truncated at the column of fifth differences? Or, what is essentially the same question: why was a polynomial of degree 5 used? Why should the entry 0.00012 have been suspicious? Which entry should be called xo? Which formula should be used? We endeavor to answer these questions in turn. We recall the theorem given at the end of Section 3.7 concerning the differences of a polynomial and also the statement that in evaluating a function f(x) at x = x' by computing Pn(x'), where Pn(x) is the approximating polynomial of max-degree n, there are two principle sources of error, first, the inherent error found in all polynomial approximation and, second, the computational error due to inaccurate data and the accumulation of errors of computation. One expression for the inherent error was given in formula 3.8: 12; an upper bound for the computational error is usually readily found. Let us suppose, as in the data given for the examples just worked out, that the entries for f(x) are all given to the same number of decimal places and that each is correct as far as it is written. Then the error in each y is at most one-half unit in the last decimal place, the error in each Lly is at most one unit in the last decimal place, the error in each Ll2y is at most two units in the last decimal place; in general, the error in each Llry is at most 2r - 1 units in the last decimal place. Now, if we use formula 3.8: 12 for the data given above, taking n = 5 and various values for u, it develops that the absolute value of the inherent error is less than one-half unit in the sixth decimal place. On the other hand, the computational error may be as large as 16 units in the column of fifth differences. Inspection of the preceding difference
3.8. POLYNOMIAL THROUGH n
+
1 EQUALLY SPACED POINTS
107
table confirms these observations and explains why the table was truncated at the column of fifth differences. The entries in that column were more or less erratic but fairly constant implying that in the use of a fifth degree polynomial, the inherent error will be negligible compared to the computational error. (A similar reason explains why ordinary or linear interpolation is usually adequate in the use of the ordinary trigonometric tables.) We conclude from the preceding observations that a difference table should be carried out until a column is reached in which the entries are more or less constant (but read the remarks further on on page 113). The last column will determine the degree of the polynomial to be used. An entry in the last column which deviates greatly from the other entries should be avoided if possible. The deviation is usually due to rounding-off and computational errors and may result in an error slightly larger than necessary. This is why the entry 0.00012 was suspicious in the table on page 105. We present the two difference tables below to illustrate the relation between the number of decimal places and the degree of the approximating polynomial. Each was carried out until a column of more or less constant entries was obtained. To obtain a value for sinh x with a precision approximately equal to the precision of the given values, a polynomial of degree 3 should be used in the first case and one of degree 8 in the second. We also observe that the number of the column of (more or less) constant differences will also depend on the size of the argument interval h; the reader should construct examples to illustrate this relation. In general, we find that for a given function and for a. given range of the argument, the smaller the argument interval and the fewer the number of significant figures required, the smaller will be the degree of the interpolating polynomial necessary. We turn next to the choice of the entry to be called Xo • In the examples worked out above, we chose six points quite arbitrarily provided only that Xo < x' < X5 , where x' was the value of the argument for which we were interpolating. There was no compulsion about the choice of Xo , indeed, it was not necessary to satisfy the preceding inequality although it will develop that greater precision will result if it is satisfied. However, it is convenient for the sake of simplicity and greater precision to rewrite formulas 3.8:7, 9-11,10', II' by introducing a new variable t and raising or lowering all subscripts in such a manner that the two arguments in the table that bridge x' are called Xo and Xl when we use forward differences (or when we use a central difference formula that starts with a forward difference) and X-I' Xo when we use backward differences (or when we use a central difference formula that starts
108
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
x
sinh x
.:Iy .:Iay.:lay
1.50 2.129 247 23
1.60 2.376 270 1.70 2.646
3 26
296 1.80 2.942
4 30
326 1.90 3.268
3 33
359 2.00 3.627
3 36
395 2.10 4.022
4 40
435 2.20 4.457
5 45
480 2.30 4.937
4 49
529 2.40 5.466
6 55
584 2.50 6.050
6 61
645 2.60 6.695
x
sinh x
.:Iy
.:lay
.:lay
.:I'y
.:I 6y
.:Ily
.:I7y .:lay
1.50 2.129279455 246288498 1.60 2.375567953
23775483 270063981
1.70 2.645631934
2702890
296542354 1.80 2.942174288
2967897 29446270
325988624 1.90 3.268162912
32708872
2.00 3.626860408
327364
36298838
363291
40252095
2.20 4.457105171 2.30 4.936961806 2.40 5.466229214 2.50 6.050204481
70 492
4953 53016
547535 5844621
60552480 644527747
4461
494519
54707859 583975267
422
48063
5297086
19
4039
446456
49410773
35 403
43602
4802567
529267408
3636
402854
44608206
61 368
39563
4356111
479856635
307 3268
35927
3953257
435248429
2961 32659
3589966
394996334 2.10 4.021856742
29698 294705
3262602
358697496
2.60 6.694732228
265007
26478373
3.8. POLYNOMIAL THROUGH n
+
109
1 EQUALLY SPACED POINTS
with a backward difference). The successive arguments of the table are then named ... , X_a, X_B , X_I' X o , Xl , X B , •.• , respectively. Formula 3.8:7 is rewritten as (3.8: 13)
where x' = Xo + th, or t = (x' - xo)/h. The only change has been the renaming of the variable u. For the revision of formula 3.8:9, we put t = u - n + 1, whence X = Xn - l + tho We also have
If in 3.8:9 we replace the binomial coefficients by their equivalents from the preceding identity and reduce all subscripts by n, we obtain (3.8:14)
where x' = X-I + th, or t = (X' - x_l)/h. Formulas 3.8:10 and 3.8:10' can be coalesced. We put, in either case, t = u - m and reduce the subscripts by m. We obtain (3.8: 15)
Y
[nIB]
= ~
.
.:jB·Y _ i
(t - 2·1 + i) + I
i-O
[("+1)/B].
~
.:jB.-IYI _ i
(t -2·1_+1i) ' I
i-I
where X = Xo + th, or t = (x - xo)/h, and where [n/2] means the largest integer not greater than n/2, etc. Formulas 3.8: 11 and 3.8: 11' can also be coalesced. In the first case, put t = u - m + 1, and after substitution reduce the subscripts by m; in the second case, put t = u - m, and after substitution reduce the subscripts by m + 1; in either case we get (3.8:16)
_
Y-
[ .. /B] ~ ABi
~~
;-0
Y-i
(t - 1 + i) + [(.. 2· ~
+1)/B] ~ A2i-1
'
i=1
~
Y-i
(t - 2 + i) 2· - 1
'
'
where X = X_I + th, or t = (X - x_l)/h. It should be carefully noted that whereas formulas 3.8:7, 9-11, 10', 11' all represent the same polynomial, formulas 3.8:13-16 will yield in general different polynomials since they represent polynomials through different sets of points. It should also be noted for future use that two polynomials given by the latter (or equivalent formulas) will be identical if, whatever the notation, the highest order differences
110
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
occuring in each are identical. This is important because it may be convenient to raise or lower the subscripts for some purposes. Thus, if the final term of one polynomial involves J6Y _ 2 and the final term of another polynomial involves J5y8 , but if J5Y _2 and J6Y8 represent the same entry in the difference table (implying, of course, that different entries were named Xo in the two cases), then the two polynomials are identical. The notation of the last group of four formulas was chosen in such manner that the variable t always equals the difference between the argument for which we are interpolating and the preceding argument in the table, divided by the tabular difference between two successive arguments; hence 0 :::;;; t < 1. We have thus answered our question concerning the argument to be called Xo' It is the argument in the table that precedes x' when we use a formula that starts with a forward difference, 3.8:13 or 3.8:15, and the argument in the table that follows x' when we use a formula that starts with a backward difference, 3.8:14 or 3.8:16. We move on to the question of which formula to choose. We see that we have no choice for the calculations of sinh 1.52 and sinh 2.54 in the examples worked out above provided that we use the formulas in terms of t and only the information given in the table on page 105. Formula 3.8:13 must be used for the computation of sinh 1.52 since we do not have the necessary finite differences for the other formulas; similarly, formula 3.8: 14 must be used for the computation of sinh 2.54. However, either one of these two formulas or either one of the central difference formulas 3.8: 15 and 3.8: 16 can be used for the computation of sinh 2.03. Which one? Inspection and study of the error term3.6:7 is the most convenient form-indicates that since the factor pn+1l(X)j(n + I)! is not apt as a rule to vary considerably with the choice of x' within the interval from Xo to Xn , the magnitude of the error will depend on the productg(x' ) = (x' - Xo)(x' - Xl) ... (X' - x n ). The particular equations y
=
(x
+ 3)(x + 2)(x + I) x(x -
I)(x - 2)(x - 3)
= x(x2 - 1)(x2 - 4)(x 2 - 9), Y
=
(x
+ 3)(x + 2)(x + I) x(x -
I)(x - 2)(x - 3)(x - 4)
= x(x2 - 1)(x2 - 4)(x2 - 9)(x - 4), indicate the behavior of the polynomial in the general case. Their graphs, drawn in Fig. 3.8:fl, show that for a random choice of x'
3.8. POLYNOMIAL THROUGH n
+
1 EQUALLY SPACED POINTS
111
within the interval from Xo to Xn the product g(X') will tend to be smaller when x' is chosen in the middle rather than at an end of the interval. It is not necessary to state the facts more precisely; these considerations indicate that the product (x' - xo) ... (x' - xn) will be numerically least when for a given x' ::f=. Xi , the argument Xo is so chosen that x' lies in the middle interval or in one of the two middle intervals.
y
y
700 300
600 500
200
400 300 200
·200 -300 -200
-400 -500 -600
-300
y = x(x 2 -IJ(x 2 - 4)(x 2 -9J(x-4)
FIG. 3.8:f1.
As a consequence, one of the central difference formulas will usually give the best results and should therefore be used. We now see too why it was necessary to develop the multiplicity of forms for the interpolating polynomial. Before we close this section we derive some new expressions for the polynomial through n + 1 equally spaced points that are advantageous
112
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
for some special applications. If n is even, say n = 2m, formula 3.8: 15 may be written as _ y - Yo
1.12• (t - 2i1 + i) + .12.-1Yl-. (t 2i- -1 +1 i) I\' +~ ~ I y-.
.-1
or (3.8:17)
The last expression is known as the Newton-Stirling formula; it involves even order differences and the averages of odd order differences. Similarly, if n = 2m + 1, formula 3.8:15 may be rewritten as (3.8:18)
_ ~ (t - 2i1 + i) fl"1~(.12··Y-. + .12') t -I .12 ·Yl-. + 2i + 1
y - ~
i+l
I
Y-• . '
This expression is known as the Newton-Bessel formula; it involves odd order differences and averages of even order differences. Formula 3.8:15, n = 2m + 1, may also be rewritten as (3.8:19)
This expression is one form of the so-called Laplace-Everett formula; its virtue is that it involves only differences of even order. REMARKS. We conclude this section with some remarks and observations on interpolating or approximating polynomials. Let y = f(x) be a [a, b]. (single-valued) function defined throughout the interval I Let
=
(3.8:20)
be the sequence of polynomials whose general term Pn(x) is the polynomial of max-degree n determined by the n + 1 points
equally spaced in the interval I so that the first abscissa is a and the last is b. The sequence 3.8:20 is called the polynomial interpolation sequence for f(x) in the interval 1. This sequence is analogous to the
3.8. POLYNOMIAL THROUGH n
+
1 EQUALLY SPACED POINTS
113
sequence of polynomials given in 2.3:5, but there is one important difference. In the earlier case, the polynomial Pn(x) was precisely the polynomial Pn-l (x) plus the term an (x - xo)n; no such simple relation exists between Pn(x) and Pn-l(X) in the present case and hence there is no simple transition from the infinite sequence to an infinite series. Let x' be in the interval 1. The polynomial interpolation sequence is said to converge to f(x) at x = x' if the sequence of constants
Pl(X'), P2(X'), ... , P..(x'), ... , converges to f(x'). The polynomial interpolation sequence is said to converge to f(x) throughout the interval I if it converges to f(x) at each point of the interval. The general theory of the convergence of polynomial interpolation sequences is beyond the scope of this text; we content ourselves with the remark that the convergence of the polynomial inte~polation sequence implies that the error term, 3.8:12 or 3.8:12', approaches zero as n tends to infinity. Or, in other words, the convergence of the polynomial interpolation sequence implies that if n is sufficiently large, the corresponding difference table will certainly contain a difference column whose entries are mote or less constant (assuming that computational errors are negligible). In the preceding observations, it was supposed that the points were all contained within a given interval I, hence as the number of points increased, the distance h between two successive points necessarily decreased. There is a corresponding theory for the case where h is kept fixed and I is made to increase with increasing n; but again, this study is beyond the scope of this text. It may be of interest to know some of the reasons the polynomial interpolation sequence fails to converge either at a point or uniformly throughout an interval. Since the graph of a polynomial is of a very special type, it cannot accomodate itself to certain peculiarities of the graphs of some functions. Thus, if f(x) or its graph is periodic or almost periodic, if it has a discontinuity, an asymptote, or a vertical tangent, or if its slope increases very rapidly with increasing x, to mention only some of the possibilities, it is not reasonable to expect a polynomial to be a good approximation to the function except over a very small range. We give several examples to illustrate the phenomenon of nonconvergence; note that the difference tables do not and will not contain columns of more or less equal numbers. The reader will find it instructive to calculate approximating polynomials for the various examples, interpolate for certain values of the functions, and then compare his answers with the results obtained directly from the functions.
114
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
EXAMPLE
1.
Periodic function, y = sin(x
x
y
..::Iy
..::I."
..::I 3y
+ i)1T. ..::ICy
0 -2 -I
4 -8
2 -4
2
16
-2 3
-I
8 -16
4 2
-8 -4
4 -2 5
EXAMPLE
2.
-I
Discontinuous function, y = 1/(2x
x
y
-3
-0.2000
-2
-0.3333
-I
-1.0000
0
1.0000
..::Iy
..::Ily
+ 1).
..::I 3y
..::I 4y
-0.1333 -0.5334 -0.6667
3.2001 2.6667
2.0000
-5.3334 -2.6667
-0.6667 0.3333 0.2000
3.2001
0.1429
-3.6573 -0.4572
0.0762 -0.0571
3
8.5335
0.5334 -0.1333
2
-8.5335
3.8. POLYNOMIAL THROUGH n
+
1 EQUALLY SPACED POINTS
115
3. Asymptotic function, y = 1/( I + x 2 ). This function has received consideral attention in the literature.
EXAMPLE
x
y
.dy
.d1y
.day
.d'y
.diy
-4 0.0588 0.0412 -3 0.1000
0.0588 0.1000
-2 0.2000
0.1412
0.3000 -I
0.5000
0
1.0000
I
0.5000
-0.1412
0.2000
-1.2000
0.2000 -1.2000
0.5000 -1.0000 -0.5000
3.6000 2.4000 -3.6000
1.2000 -1.2000
0.2000 -0.3000
2 0.2000
-1.0588
0.0000
0.0000
-0.1000
1.0588 -0.1412
0.2000 0.1412 0.0588
3 0.1000 -0.0412 4 0.0588
EXAMPLE
4. x
Function with vertical tangent, y = {ix. y
-4
-1.5874
-3
-1.4422
.dy
.dly
.day
.d'y
.d'y
0.1452 0.0371 0.1823 -2
-1.2599
0.0405 0.0776
0.2599 -I
-1.0000
0
0.0000
0.7401 1.0000
1.4422
4
1.5874
0.0000 -0.7401
-0.7401 0.2599
3
1.4026 1.4026 -2.0246
0.6625 -0.0776
0.1823
-0.6220 0.0405
-0.0371 0.1452
1.4026
-0.740\
1.0000
1.2599
-2.0246 -1.0426
0.0000
1.0000 2
0.6220 0.6625
116
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
EXAMPLE
x
5.
Function with rapidly increasing slope, y = rl. y
1.0
2.718
1.1
3.353
..:Iy
..:I1y
..:I'y
..:I1y
..:Ily
..:Ily
..:I 7y
0.635 0.233 0.868 1.2
4.221
0.097 0.330
1.3
5.419 7.099
1.5
9.488
1.6
12.936
1.7
17.993
1.8
25.534
1.9
36.966
2.0
54.598
2.1
82.269
2.2
126.469
2.3
198.343
2.4
317.348
2.5
518.013
0.020
0.482 1.680
1.4
0.055 0.152
1.198
0.075 0.227
0.709 2.389
0.123 0.350
1.059 3.448
0.077
0.550
0.125
0.875
7.541
0.370
2.309
0.883 2.004
0.770 1.653
3.657
11.145 8.312 19.457
1.450 3.103
6.760 15.072
47.131 119.005
0.390
1.121
4.655
27.674 71.874
0.493
2.651 6.490
44.200
0.235
0.628
3.839
16.529
0.095 0.258
1.530
10.039 27.671
0.163
0.902
6.200 17.632
0.081
0.207
1.407
11.432
0.034 0.082
0.532
3.891
0.019 0.048
0.325
2.484
0.001 0.029
0.200
1.609 5.057
0.028 0.048
34.529 81.660
200.665
EXERCISE 3.8
t. Find, from a table of square roots or otherwise, Vx correct to four decimal places for x = 400, 402, 404, 406, 408, 410. Find, by interpolation, V401, v405.2, V409.25. Estimate the errors of the approximations and determine the actual errors. 2. Copy the values of tan x from a five-place table for x = 20°, 25°, 30°, 35°, 40°, 45°,50°,55°,60°. a. Use an appropriate finite difference formula and as many of the above values as are necessary to find tan 21 ° to five decimal places. b. Find tan 42" by use of three different formulas.
3.9. EXTRAPOLATION
117
3. Use appropriate finite difference formulas and as many entries as are necessary from the corresponding tables below to find the required values as precisely as possible. a. Find lOOe-e.oz, lOOe- B.33 , lOOe-B.U6. b. Find the values of y for x c. Find the values of y for x
= 1.371, 1.403, 1.468, 1.4296. =
O.oI 1,0.019, 0.028, 0.0193, 0.0117,0.0284,0.02015.
d. Find the values of 1= 2/vwf:e-t"dtforx = 0.13,0.41,0.92,0.137,0.149, 0.925,0.1371,0.4192,0.9258. e. Find fo{2.015), fo{2.381), fo{2.407), fo{2.926); ].(2.115), J,(2.507), J,(2.604), J,(2.834).
b
a x
lOOe-z
6.0 6.1 6.2 6.3 6.4 6.5
0.2479 0.2243 0.2029 0.1836 0.1662 0.1503
x y=tanx
1.37 1.38 1.39 1.40 1.41 1.42 1.43 1.44 1.45 1.46 1.47
4.9131 5.1774 5.4707 5.7979 6.1654 6.5811 7.0555 7.6018 8.2381 8.9886 9.8874
c x
0.0100 0.0125 0.0150 O.oI 75 0.0200 0.0225 0.0250 0.0275 0.0300
y
=
e
d (I +x)-ZO
0.819544 0.780009 0.742470 0.706825 0.672971 0.640816 0.610271 0.581251 0.553676
x
I
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
0.00000 0.11246 0.22270 0.32863 0.42839 0.52050 0.60386 0.67780 0.74210 0.79691 0.84270
x
fo{x)
].(x)
2.0 0.2239 0.5767 2.2 0.1104 0.5560 2.4 0.0025 0.5202 2.6 -0.0968 0.,4708 2.8 -0.1850 0.4097 3.0 -0.2601 0.3391
4a. Estimate the error due to linear interpolation in the several parts of example 3. b. How can one determine if linear interpolation is adequate for a given table? 5. Where possible, do example 3 using Lagrange coefficient tables.
6. Derive formulas 3.8; 17-19.
3.9. Extrapolation. In all of the examples of the previous section, a functionf(x) was calculated for an argument x' which was between the smallest and largest arguments in the table used. The process of calculating f(x' ) where x' is smaller than the first argument or larger than the last argument of the table is called extrapolation. When x' is smaller than the first argument of the table, we name the first argument Xo and use the forward difference formula 3.8:7; when x' is larger than the last argument of the table, we name the last argument Xn and use the backward formula 3.8:9. In either case, the factor (x - xo)(x - Xl) ... (x - x n ) in the error term and consequently the error term itself grows rapidly in magnitude as the interval between x' and the nearest entry of the table increases.
118
3. THE APPROXIMATING POLYNOMIAL; APPROXIMATION IN AN INTERVAL
1. Compute sinh 1.32 from the difference table on page 105. We use formula 3.8:7; we have x' = 1.32, xo = 1.50, h = 0.1, u = -1.8, also = -1.8, = 2.52, = -3.192, = 3.8304, = -4.443264. Hence EXAMPLE
m
m
m
m
m
sinh 1.32 = 2.12928 - 1.8(.24629) + 2.52(.02377) - 3.192(.00271) + 3.8304(.00026) - 4.443(.00003) = 1.73807.
The result correct to five decimal places is 1.73814. 2. Compute sinh 2.70 from the same table. This time we use formula 3.8:9; we have x' = 2.70, xo = 2.10, h = 0.1, u = 6, n = 5; (1£1") = (U-~+l) = (U-~+2) = (U-~+3) = (U-~+4) = I, whence EXAMPLE
sinh 2.70
= 6.69473 + 0.64453 + 0.06056 + 0.00586 + 0.00058 + 0.00012 = 7.40638.
The result correct to five decimal places is 7.40626. Had we used the larger table on page 108, we would have obtained 7.406263142. The two italicized figures are incorrect; they should be 06. EXERCISE 3.9 Extrapolate for the values below by using appropriate finite difference formulas and the tables from the corresponding examples of Exercise 3.8. Estimate the error in each case and, where possible, determine the actual error.
1. v'395, v'399, v'412, v'415. 2. Tan 15°, tan 18°30', tan 61°10', tan 70°15'. 3a. lOOe-', lOOe-I.8, lOOe-I.I, lOOe-I.711.
b. Tan 1.35, tan 1.367, tan 1.475, tan 1.5. c. (I + x)-ao for x = 0.009,0.04,0.05. d. I for x = 1.1, 1.3, 1.5, 2. e. 10(1),10 1T, 1= 1T,+11 = ... = 1T,+I_ll > 1Tn. I·
It can be shown that the approximations 5.2:24 for Bg , Bg+1 , ... , Bg+s- 1 are replaced by the approximations
(5.2:26)
The entries for the table for the transformed equations are evaluated as in Case I; this time, however, the double cross products directly underneath Bg2, B:+l , B:+S- 1 will not become small or negligible. We illustrate the procedure in:
+
EXAMPLE 3. Find the roots of x 8 + x 7 - 27x6 - 21x5 + 254x" 128x3 - 948x 2 - 180x + 1080 = 0, given that all roots are real. We rewrite the equation as x 8 - (-I)x7 + (-27)x 6 - 21x5 + 254x" - (-128)x3 + (-948)x 2 - 180x + 1080 = 0 and then evaluate as in example 2 the entries in the table on pages 178 and 179. The work was carried out to the 64th power equation although it should have been carried out further for greater precision. The letters underneath the coefficients of the 64th power equation indicate entries that would appear in all further tabulations; the single asterisks (*) indicate entries that have already become negligible or will become negligible at the next step; the double asterisks (**) indicate entries that will ultimately become negligible. In view of the discussion just above, it
5.2. THE ROOT-SQUARING METHOD
181
appears that there are two roots with equal absolute values, then three roots with equal (and smaller) absolute values, then a sixth root, and finally, two more roots of equal absolute values. Incidentally, because the number of significant figures decreases from step to step in this example, it is necessary to start with a large number of significant figures to get a reasonably reliable set of answers. If we change the usual notation and call the distinct roots of the final equation Rl , R2 , R3 , R" then the approximate equations 5.2:26 (for all eight roots, and again using equality rather than approximation signs) become R12 = 3R12R2 = 3R12R22 = R 12R23 =
B2 = B3 = B4 = B5 =
1.2099 1.1004 3.6197 4.0483
X
X
1084 , 1095 , 10125 , 10155 ,
= 7.4683
X
10174 ,
2R12R23R3R4 = B7 = 6.4110 R12R23R3R42 = B8 = 1.3776
X
10184 , 10194 •
R 12R23R3 = Be
Hence
1'1 I =
R~/84
X X
X
-+
B )1/84 =( = 3.165,
B )1/84 = (_3_ = 2. 994 I ' 2 I = Rl/84 2 3B2 , B )1/84 = (_8_ = 2000 I ' 3 I = Rl/84 3 B5 ., B )1/84 I '4 I = R!/84 = ( 2~8 = 1.414.
Substitution into the original equation will determine the signs of the roots. Since I '21 occurs three times and both 2.994 and -2.994 appear to be roots, the sign of the third corresponding root can be obtained from the sum (= -1) of all the roots, or otherwise. [It may be well to recall that if f'(x) is the derivative of f(x) with respect to x, then an s-fold root of f(x) = 0 is an (s - 1)-fold root of f'(x) = 0.] The actual roots of the equation are ± yTO, 3, -3 (a double root), 2, ± Y2. Case 3. There are equalities in 5.2: 15 due to the presence of imaginary roots. Multiple roots of the given equation f(x) = 0 can be detected by finding the highest common factor of f(x) and its derivative f'(x) and
182
5. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS IN ONE UNKNOWN
can be obtained first. We may then suppose that the equation to be solved has no multiple roots. Let us assume further that no imaginary root has the same absolute value as any other root except, of course, as its conjugate which must also be a root. Let rf/ be an imaginary root and rf/+l its conjugate, and let rand 0 be the modulus and amplitude, respectively, of rf/' so that I rf/ I = I rf/+l I = rand rf/rf/+l = r2. It follows that R, + RHI = 2r2m cos 2mB, (5.2:27) R,R'+1 = r2m+!; and it can be shown that in place of the approximation for Bf/ given by 5.2:24, we have (5.2:28)
Hence, again using equalities in place of approximations, (5.2:29)
R,
+ R'+1 =
B,/B'_l'
R,R'+1 = B,+1/B,-l'
so that Rf/ and Rf/+l are the roots of the equation (5.2:30)
The existence of imaginary roots is readily determined from the root squaring tabulations. As in the case of real roots with equal absolute values, the cross product term 2Bf/- 1Bf/+l does not become negligible in comparison with Bf/2 since by a line of reasoning similar to the previous one it can be shown that its absolute value is approximately equal to Bf/2/2 cos 2 2mO. Hence, as before, the nonvanishing double cross product points to the presence of two roots with equal absolute values. To distinguish the present case from the one in which the two roots are equal, we note that if all the roots of f(x) = 0 are real, the roots of the very first transformed equation as well as the roots of all the later equations are positive. Hence, by Descartes' Rule of Signs, the actual coefficients of all the transformed equations must alternate in sign and therefore, in view of our notation, all the coefficients of the transformed equations that appear in the tabulations must be positive. The appearance then of one or more negative coefficients in the equations in the table whose roots are the second, fourth, eighth, ... , powers of the original roots would immediately indicate the presence of imaginary roots.
5.2. THE ROOT-SQUARING METHOD
183
In the rare cases where there are imaginary roots but all the coefficients remain positive, they may be detected when the suspected roots are substituted into the equation. This complication may arise if a root Tg = U + iv is such that v is very small so that both Tg and Tg+l are approximately equal to u. If a pair of imaginary roots has been detected from the tabulations, we find, as before, R 1 , ••• , Rg - 1 • Then Rg and Rg+l can be found from 5.2:30, and from them, Tg and Ta+l , using 5.2:27 or DeMoivre's theorem, or we can proceed as in example 4. We continue in a similar fashion until all roots have been found. 4. Find the roots of X4 - 5xa + 8x 2 - 3x - 3 = O. The root squaring tabulations are shown on page 184. We stop at the 64th power equation because after that point all coefficients with the exception of the coefficients of x 2 will be merely the squares of the previous corresponding coefficients. The appearance of negative signs in the coefficients of x 2 indicates the presence of imaginary conjugate roots. We have R t = I Tl 164 = 3.1451 X 1024 ; whence 10g1 Tl I = 0.38278 and I Tl I = 2.4142. Next, since T2 and Ta are apparently imaginary roots, we put I T2 I = I Ta I = T and we have, using 5.2:29, EXAMPLE
R2R3
Finally,
=
I T2Ta l84 = (T2)84 = 1.0800 x 1055/3.1451 X 1024 ; log T2 = 0.47712 and T2 = 3.0000.
= I TIT2Tal 84 I T, 18' = 3.4337 x 1()30; log I T41 = 9.61722 - 10, I T41 = 0.4142.
RIR2R3R4
A graph or substitution into the original equation shows that the two real roots are Tl = 2.4142, T4 = -0.4142. If we put T2 = u + iv, Ta = u - iv, then Tl
+ T2 + T3 + T4 = 5 =
2.4142 + (u
+ iv) + (u -
if) - 0.4142,
so that u = 1.5000. Then v = V;! - u2 = Y3-~ 2.25 = 0.8660 and T2 = 1.5000 + 0.8660i, Ta = 1.5000 - 0.8660i. The roots are correct as far as they are written; the roots are actually 1 ± y2, (3 ± Y3t)/2. The present method can be extended to cover the cases where the given equation has several sets of roots, real or imaginary, with repeated absolute values. The details of recognition and computation are left to the reader. Real or imaginary roots can also be found by the methods to be discussed in the succeeding sections.
184
5. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS IN ONE UNKNOWN
(1)
(2)
(4)
5
8
(16)
9
6.4 -3.0 -0.6
1
0.9
1
2.8
1
8.1 -5.6
1
7.84 • -10.26 0.18
3.249 3 -0.504
2.5
1
-2.24 •
2.745
1.073
3
5.71
9 8.1 •
3
8.1 •
5.0176 ' -13.7250 0.0162
7.53503 I 0.03629
6.561
3
-8.6912 '
7.57132
6.561
3
8
1.15133 0.17382
8
7.55370 • -16.24805 0.00001
5.7324913 0.00011
4.30467
7
1.32515
I
-8.69434 •
5.73260 13
4.30467
7
1.75602 0.01739
11
3.28627
17
1.85302
16
1. 77341
11
-7.63396
11
3.28627
17
1.85302
16
3.14498 0.00015
II
5.82773 -11.65581
31
1.07996 I i
3.43368
30
3.43368
80
7.55915 -15.19311
11
*
* (64)
9 48
1
* (32)
-3
2.5 -1.6
6.25 • 4.48 (8)
3
3.14513
II
-5.8280881
* 1.07996 I i
EXERCISE 5.2
1. Find by the root-squaring method, correct to three decimal places, the roots of the equations of example I, Exercise 5.1. 2. Find by the root-squaring method, correct to three decimal places, all the roots of a. x' + Xl - 9x· - 6x + 18 = O. b. 9x' - 6x1 - 5x· + lx + 1 = O. c. 5x' - 16x' - 36xl + 110x· + 57x - 187 = O. 3. Find by the root-squaring method, correct to three decimal places, all the roots of the equations of example 2, Exercise 5.1. 4. Find by the root-squaring method, correct to three decimal places, all the roots of a. lx' - 4Xl - Xl + 12x + 18 = O. b. x' - 6x' + IOx3 + 11x· - 6lx + 70 = O. c. x' - lxl + 4x· - 28x + 196 = O.
5.3. THE METHOD OF ITERATION
185
5.3. The Method of Iteration. The method of iteration for finding the roots of an equation, unlike Horner's and the root-squaring methods, applies not only to polynomial equations but to equations of all types. In its pure form, an approximation to a root of an equation f(x) = 0 is substituted into a suitably chosen function 9'(x) to yield a better approximation, the latter is substituted into 9'(x) to yield a still better approximation, and so on until a result is obtained of satisfactory precision. Modifications of the pure form of the method will also be discussed. The process when properly used is usually very efficient and is well suited for computation on high speed machines. The method owes its validity to the following two theorems. THEOREM 1. Let 9'(x) be a single-valued function and ro an arbitrary constant. Let the sequence of constants
(5.3:1) be defined by the recursion formula n = 0, 1,2, ....
(5.3:2)
If the sequence 5.3:1 has a limit, say limn ...."" r n = r, and 9'(x) is continuous at x = r, then
(5.3:3)
r = 9'(r) ,
that is, r is a root of the equation
(5.3:4)
x = 9'(x).
The proof follows readily enough. Since 9'(x) is continuous at x = r, it is true that for any sequence such as 5.3: I which approaches r, the associated sequence 9'(ro), 9'(r1), 9'(r 2 ), " ' , will approach 9'(r). Since the latter sequence is identical with the sequence 5.3: I minus its first term in virtue of the definition 5.3:2, the two limits are equal or r = 9'(r). Theorem I is of consequence only if criteria or conditions are given which will assure the convergence of the sequence 5.3: I. A sufficient condition for convergence is furnished by the next theorem. THEOREM 2. A sufficient condition for the convergence of the sequence 5.3:1 is that the derivative 9"(x) and a constant m exist such that the double inequality
(5.3:5) holds for all x's.
I 9"(x) I < m
0 for all x's between, and '0 . 34. If a > 0, prove that
*"
*"
'I'(x) =
!n (n -
I) x
+ _a_) X"-l
is suitable for iteration to yield a l/ft ; in particular a. tp(x) = x(2 - ax) is suitable for I/a; b. cp(x) = 1[x + (a/x)] is suitable for c. Find by iteration, correct to four decimal places, (i)
Va.
t (ii) v'1Q.3 (iii) {/4.2-:-
192
5. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS IN ONE UNKNOWN
5.4. The Method of False Position (Regula Falsi); The Method of Chords. Another method of wide application for finding an isolated root r of an equation f(x) = 0 is the method of false position or regula falsi. The method which is essentially nothing but inverse linear interpolation and is related to the method of iteration, as we shall see, does not involve directly the concept of slope and hence can be used if f(x) fails to have a derivative at r or in some neighborhood of r. Let a < r < b, and suppose that r is the only root in the closed interval [a, b]; then f(c) has the same sign as f(a) if c is in the "left interval" or "left neighborhood" [a, r) and the same sign as f(b) if c is in the "right interval" or "right neighborhood" (r, b]. Suppose now that f(a) and f(b) have opposite signs so that the graph of y = f(x) actually crosses the x-axis at a point R whose abscissa is r. The root r is approximated by the abscissa ro of the intersection point Ro of the x-axis and the chord joining the points A: (a,f(a)) and B: (b,j(b)). See Fig. 5.4:fl. It is readily found that (5.4:1)
ro
=
af(b) -- bf(a) f(b) -- f(a) ,
or (5.4:2)
b--a ro = a -- f(b) __ f(a/(a).
Hf(ro) = 0, ro is the root and the process stops; if ro is in the left (right) interval, it is regarded as a new a (b) and combined with the old b (a) or with a new b (a) selected in the right (left) interval to yield a second approximation. The process is continued until we have an approximation to the root of desired precision. Since we can always contrive to enclose the root and an approximation in an interval of arbitrarily small length, we have a self-contained evaluation of the maximum error. y
----------~°r_~~~--------x A (0, f(a)) FIG. 5.4:fI.
5.4. THE METHOD OF FALSE POSITION; THE METHOD OF CHORDS
193
An example will illustrate the method and the manner in which it can be judiciously modified. EXAMPLE I. Find the positive root of {IX--=-l five significant figures.
-
cos x = 0 correct to
Solution 1. It is readily determined that there is only one positive root and that it is slightly greater than unity. We have f(l) = -0.54, f(1.2) = 0.22; hence the root is between a = I and b = 1.2. We use = 1.1. Since f(l.l) = 0.01, we regard 1.1 as 5.4: 1 or 5.4:2 and find a new b; using the new b and the old a = I, we find = 1.098. Since f(1.098) = 0.00566, 1.098 is also a new b. We continue in this fashionit will take quite a number of additional steps-to get the answer 1.0957 correct to five significant figures. Note that as the work proceeds, we will need more and more significant figures in the values of f(x).
'0
'1
Solution 2. The preceding method of solution is poor on two counts, the rate of convergence to the root is quite slow and the length of the interval within which the root is known to lie does not become arbitrarily small so that we do not have a good measure of the precision of the approximation at any step. To overcome these defects, we proceed as follows. Take, as before, a = I, b = 1.2 to find = 1.1. Since f( 1.1) = 0.0 I, the root is between 1.00 and 1.10 and probably closer to 1.1. As a conservative guess, take the new a = 1.06 and the new b = 1.10. Using these values, we obtain the approximation '1 = 1.096. Since f( 1.096) = 0.00073, 1.096 is a new b and we choose 1.095 as a new a. Since f(1.095) = -0.00176, 1.095 is indeed a new a. If it had turned out that f( 1.095) were positive, 1.095 would have been a new and better b than 1.096. Another step yields f(1.0957) = -0.00001, f(1.0958) = 0.00023. Hence, not only is the root between 1.0957 and 1.0958, but the former is certainly correct to five significant figures. If in the right-hand member of 5.4: I or 5.4:2 we replace a by x to obtain
'0
(5.4:3)
tp(x)
=
xf(b) - bf(x) b- x f(b) _ f(x) = x - f(b) _ f(x/(x),
then for b close to the root " tp(x) is suitable for iteration. Compare 5.4:3 with 5.3: 13 and 5.3: 15. In the example just worked out, start with b = 1.2 and '0 = I. We obtain on successive substitutions into 5.4:3, '1 = 1.14, '2 = 1.09, '3 = 1.097, '4 = 1.0955, '5 = 1.0957, with no further change in the fourth decimal place.
194
5. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS IN ONE UNKNOWN
REMARK.
(5.4:4)
To pave the way for a later generalization, rewrite 5.4: I as f(b) '0
= a f(b) _ f(a)
f(a) - f(a) .
+ b f(b)
Put (5.4:5)
ml
=
f(b) f(b) - f(a) ,
m2
=
f(a) f(a) - f(b)'
so that (5.4:6)
and (5.4:7)
That is, if f(a) and f(b) are of unlike sign, then the weighted average 5.6:6, where the weights are determined by 5.4:5 (so that 5.4:7 holds), is likely to be a good approximation to a root r of f(x) = O. The method of chords is an adaptation of the method of false position. In some problems, it may be advantageous for computational arrangement to rewrite the equation to be solved, f(x) = 0, in the form G(x) = g(x) so that a root r of f(x) = 0 becomes the abscissa of a point of intersection R of the graphs of y = G(x) and y = g(x). We assume that G(x) and g(x) are single-valued and continuous in a neighborhood of r and that G(x) - g(x) has opposite signs in suitably small left and right neighborhoods of r. Let the chord joining A: (a, G(a» and B: y = g(x)
A'(O, g(o)
FIG. 5.4:f2.
(b, G(b» meet the chord joining A': (a, g(a» and B': (b, g(b» in the point R 1 • See Fig. 5.4:f2. It is readily determined that the abscissa r 1 of Rl is given by (5.4:8)
'1 = a + h,
5.4. THE METHOD OF FALSE POSITION; THE METHOD OF CHORDS
195
where h =
(5.4:9)
b_ a (
G(a) - g(a) ) G(a) - g(a) + g(b) - G(b)
EXAMPLE 2. Find the real root of (x + 1) 10gIO x = 1, correct to four decimal places. The given equation is put into the form log x = Ij(x 1), and we set G(x) = 1j(x 1), g(x) = log x. The root T is clearly greater than unity (since otherwise the left-hand member of the given equation will be negative or imaginary); since G(I) = 0.5, g(l) = 0, G(x) > g(x) for x < T. The computations below are self-explanatory.
+
+
h
=
x
G(x)
g(x)
2 3
0.33 0.25
0.30 0.48
(3 - 2)
0.33 -0.30 0.33 - 0.30 + 0.48 - 0.25
2.1 2.2
h
=
(2.2 - 2.1)
0.3226 0.3125
=
0.1
0.3222 0.3424
0.3226 - 0.3222 0.3226 - 0.3222 + 0.3424 -
0.3125
2.1013 2.1012 2.1011
0.32244 0.32245 0.32247
0.32249 0.32247 0.32245
2.10115
0.322461
0.322457
=
000 3 .
I
Hence, the root is 2.1012 correct to four decimal places. EXERCISE 5.4 1. Do the indicated examples by the method of false position or by the method of chords; the numbers refer to the examples of Exercise 5.3.
a. 1 b. 2 c. 5 d. 6 e. 7 f. 8 I. 9 h. 10 I. II j. 13 k. 17 I. 18 m. 19 n. 21 o. 25.
196
5. ALGEBRAIC AND TRANSCENDENTAL EQUATIONS IN ONE UNKNOWN
2. Solve the following equations by the method of false position or by the method of chords. Follow the directions of Exercise 5.3 . •• lO(x - 2)· + 5x - II = O. (3 dp) b. (x - 1)1/3 = In 2x. (4 sf) C. 21+1/Z - 7 cos x = O. (3 dp) d. I sin x I - ez - 2 = O. (4 sf) e. 5(x + I) I log x I = J. (3 dp)
5.5. Imaginary Roots. Some of the methods described in Sections 5.3 and 5.4 for the determination of real roots are applicable with little or no modification to the determination of imaginary roots. For example, the method of iteration, of which the Newton-Raphson method is a special case, is particularly suited for the computational process. We illustrate the method by working: EXAMPLE
1.
Find the imaginary roots of f(x)
= x4 - 5x3 + 8x2 -
3x - 3
= O.
It is readily ascertained by Descartes' Rule of Signs and by substitution that the equation has two real and two imaginary roots. Since /(2) = -1, /(3) = 6; /( -I) = 14, /(0) = - 3; it appears that the real roots are approximately 2.2 and -0.2. The sum and product of the real roots are approximately 2 and -0.44, respectively; since the sum and product of all four roots are 5 and -3, respectively, the sum and product of the imaginary conjugate roots are approximately 3 and 6.8, respectively. It follows that the imaginary roots are approximately 1.5 ± 2i. Since f'(x) = 4x3 - 15x2 + 16x - 3, the Newton-Raphson formula for iteration becomes 44 - 5x3 + 8x2 - 3x - 3 x = x - _:--=---:-::---=--::--::-----::-4x3 - 15x2 + 16x - 3
We start with To = 1.5 + 2i and find by successive substitutions in the right-hand member of the preceding equation, Tl = 1.5 + 1.5i, T2 = 1.5 + I.li, T3 = 1.5 + 0.9i, T4 = 1.50 + 0.86i, etc. The root was previously found to be i(3 + V3i). Another method that can be used is an adaptation of the method of chords; it is the generalization referred to in the Remark of the preceding section. Let T be an isolated imaginary root of the equation (5.5:1)
f(x)
= o.
Suppose that by trial or otherwise we locate three numbers (5.5:2)
5.5. IMAGINARY ROOTS
197
each of which is close to the root r (and where ai and hi are real) such that the absolute values of (5.5:3)
(where ai and f3i are real) are small. Graph the three points representing the numbers r 1 , r 2 , ra in an x~plane and the three points representing the numbers f(r 1)'/(r2)'/(ra) in an f(x)-plane. See Fig. 5.5:fl. (We will find it convenient to refer to the point representing a number x merely as the point x, etc.) If r 1 , r 2 , and ra are indeed close to the root, and if f(x) is sufficiently regular (as it usually is in practice), then the points fer 1)' fer 2)' and fer a) will be fairly close to their origin (the zero point of the plane) and the triangle whose vertices are rl ' r2' ra will be approximately or roughly similar to the triangle whose vertices are /(r1)'/(r 2), f(ra)· b
21
/3 21
i
1
f~ )
f(r3) r2· •
-O~--~--~----~--~2--0
-2
-I
2
0
·f(rl)
a
-I
-21
x- plane
f(x)-plane
FIG. 5.5:fl.
Now, if the points f(r 1)'/(r2)'/(ra), are given numerical weights or masses, positive, negative, or zero, m 1 , m 2 , ma , respectively, then the center of gravity of the triangle is a + f3i, where
f3
+ m2f32 + m3f33 . m1 +m2 +m3
= m1f31
s.
198
ALGEBRAIC AND TRANSCENDENTAL EQUATIONS IN ONE UNKNOWN
If, on the other hand, we put ex =
fJ =
0, and ml
+ m + ma 2
= 1, then
This means that the origin will be the center of gravity of the triangle whose vertices are f(r l ), f(r2),j(ra) if the vertices are weighted with the masses ml , m 2 , ma , respectively, given by 5.5:4. Since the origin IS the point 0 + Oi = f(r), it is reasonable to expect that the point
(5.5:5) where
(5.5:6)
aI' = mlal
+ m~2 + maaa
bl ' = mlb l
+ m2b2 + maba ,
will be a good approximation to the root r. We can now combine r l ' with two of the previous numbers, or with new numbers, to secure a still better approximation. The process can be repeated over and over until an approximation to the root is obtained with the desired degree of precision. We illustrate this method by using it to find the root of example 1. We have, choosing the arguments more or less by guess, f(1.5 + %) = 0.7 - 0.2i, f(l.4 + 0.5%) = - 1.0 + O.4i, f(1.45 + 0.7%) = -0.6 + 0.4i. Next, 1- 1.0 04 -0.6 0.4 1 ml = -0.2 1 0.7 -1.0 0.4 -0.6 0.4 : 1
2
3'
m2
=
1- 06 04 0.7 -0.2 1 2 = 3' -0.2 1 0.7 0.4 -1.0 -0.6 0.4 :1
I-1.0 0.7
-0.21 0.4 ma= -0.2 1 0.7 -1.0 0.4 -0.6 0.4
:I
=
1
-3·
Hence we expect -i( 1.5 + %) + l(l.4 + 0.5%) - l( 1.45 + 0.7%) = 1.45 + 0.77i to be a good approximation to the required root. Indeed,
5.5. IMAGINARY ROOTS
199
have /(1.45 + 0.77i) = -0.33 + 0.27i. We evaluate next + 0.80i) = -0.25 + 0.16i,/( 1.50 + 0.90i) = 0.15 - 0.07i. Again we compute the m's: we
(1.48
m,
~
1-00.15.25
1-
0.33
-0.25 0.15
m,
~
1-0.33 0.15
1-
0.33
-0.25 0.15
0 .33 1--0.25
. , 1~
0.33
-0.25 0.15
0.16 -0.07 0.27 0.16 -0.07 -0.07 . 0.27 0.27 0.16 -0.07 0.27 0.16 0.27 0.16 -0.07
0.0065
= - 0.0256 = -0.254,
;I 0.0174 0.0256 = 0.680,
:I 0.0147 0.0256 = 0.574.
:I +
The new value of r is -0.254(1.45 + O.77t) + 0.680(1.48 + 0.80t) + 0.90i) = 1.499 + 0.865i. The last value is a good approximation to the root.
0.574(1.50
EXERCISE 5.5
1. Do examples 2, 3, 4 of Exercise 5.2 by the methods of Sections 5.3-5.
Chapter 6
The Numerical Solution of Simultaneous Algebraic and Transcendental Equations
6.1. Introduction. In the present chapter we consider various methods of finding the real solutions of a system of n equations in n unknowns. The discussion will be limited, except for the linear case, to the value n = 2 but generalizations for greater values of n will be outlined. The first and most obvious method of solving n simultaneous equations in n unknowns is the method in which the problem is reduced to the solution of one equation in one unknown, that is, to the type of problem investigated. in the preceding two chapters. As an illustration of the method, we do: EXAMPLE
1.
Find the real solutions of the pair of simultaneous equa-
tions f(x,y) g(x,y)
= x3 + 2y2 - 50 = 0, = x - y + IOglO(XY + 1) = O.
Whatever method we employ for the solution, we will find it convenient to graph the two functions on the same coordinate axes; the graphs are shown in Fig. 6.1 :fl. The real solutions are, of course, the coordinates of the points of intersection of the two curves. It appears that there are three real solutions, approximately x = 0.3, Y = -4.9; x = 2.7, Y = 3.6; x = 3.6, Y = -0.2. We obtain, on solving the first equation for y in terms of x,
whence, by substitution into the second equation, x
~ ~50 ~ x3 + log (± x~50 ~ x3 + 1) = 200
O.
6.1. INTRODUCTION
201 Y
25
I
20
,,
15
I I I I I I
\
\
\
\
-15
-10
,,
10 "-
"',
-5
10
15
20
, ,I
II
I
'" "' .... - -5
,, l " , ,,, ,I
-10
- - - - 11 3 + 2y2 -50=0 - - I09'O(IIY + I) + (11- y)
=0
-15
I I
I
-20
I
FIG. 6.1 :fl.
The solution with positive y is found from the equation obtained by taking the upper signs; the two solutions with negative y's are found by taking the lower signs. We obtain the solution with positive y first. We rewrite the corresponding equation in the form x
= '\jIso -2
x3
(/so -2 xi + 1) ,
- log x '\j
and then compute the entries in the following table: II x
Xl
2.7 2.8
19.683 21.952
IV
III
50 2
Xl
15.159 14.048
vm 3.89 3.75
V x(IV)
+
11.503 11.500
I
VI
VII
log (V)
(IV) - (VI)
1.06 1.06
2.83 2.69
202
6. SIMULTANEOUS ALGEBRAIC AND TRANSCENDENTAL EQUATIONS
The entries in the last column are the values of the right-hand member, call it F(x), of the preceding equation for x = 2.7 and 2.8, respectively. Since F(2.7) > 2.7 and F(2.8) < 2.8, the desired root is between 2.7 and 2.8. Furthermore, the slope of F(x) at any point within the interval from 2.7 to 2.8 is approximately equal to the slope of the chord joining the endpoints of the graph of F(x) in this interval which is (2.69 - 2.83)/(2.8 - 2.7) = -1.4. Substitute this value in the formula for q:>(x) given in example 30, exercise 5.3; we obtain
/SO-x3
'\/ x=
2
(/SO-x3)
- log x '\/
+ I + l.4x
2
---------------=~--------------
2.4
By the method of iteration, we find the root to four decimal places to be x = 2.7541, whence y = 3.8151. The work is shown partially in the tabulations below.
II
50 -
x
2.75 2.754 2.7541 2.75411
III
V
IV Xl
x(IV)
2 20.796875 20.887757 20.890033 20.890260
14.601563 14.556122 14.554983 14.554870
3.82120 3.81525 3.81510 3.81508
VII
VI
+
log (V)
I
11.5083 11.50719 11.50716 11.50716
(IV) -(VI)+ 1.4x
1.06101 1.06097 1.06097 1.06097
2.4 2.7542 2.7541 2.75411 2.75411
We determine next the two solutions with negative y. This time it is necessary to solve the equation
Iso -2
X= - ' \ /
x3
(
/
-log l-x,\/
SO -2 x3 ) .
We examine first the logarithmic argument
Iso -
z=l-x,\/
2
x3
'
the relevant portion of whose graph is shown in Fig. 6.1 :f2. The curve crosses the x-axis at about x = 0.20005 and x = 3.68034 and ends
6.2. THE METHOD OF ITERATION
203
abruptly at the point x = {ISO = 3.684, z = 1. The logarithm of a negative argument is imaginary, hence one of the desired roots is between 0 and 0.20005 and the other is between 3.6803 and 3.6840. By methods similar to the ones used above, we find that the solutions are x = 0.2000147,y = -4.9995999; x = 3.6804025,y= -0.2716742. This method can be extended in an obvious fashion for the solution of three or more simultaneous equations in the corresponding number of unknowns. y
15
FIG. 6.1:f2.
EXERCISE 6.1
1. Plot the following pairs of equations and find the real solutions correct to three decimal places .
+ 2y - 2 = 0, y8 = lxl - 3 + b. Xl - lx + yl - 8 = 0, yxl = 3. c. y = e"/', Y = 2/(1 + x 8 ). •• x
+ cosy = I, + e' = 5, y =
d. sin x
(x - y)1
e. e"'
4(x3
-
=
v'x + 2.
x.
x).
2. Find the real solutions ofthe following sets of equations correct to two decimal places• •• x = y8 - 2, y = x 8 - z, Z = y8 - lx. b. x + y = I, Xl + yl = z, x 8 + Zl = 4.
6.2. The Method of Iteration. This method lends itself to the solution of n simultaneous equations in n unknowns; we explain it for the case of two equations. Let (6.2:1)
f(x,y)
=
0,
g(x,y) = 0,
be a pair of equations for which a common solution
IS
sought.
204
6. SIMULTANEOUS ALGEBRAIC AND TRANSCENDENTAL EQUATIONS
We rewrite them in the forms
(6.2:2)
x
= F(x,y),
y
=
G(x,y),
respectively. Now if
(6.2:3)
x
=
xo ,
y =Yo,
is an approximation to a solution, we determine a second approximation
(6.2:4)
Y =Y1,
from the equations
(6.2:5) and then a third approximation Y =Y2'
by means of the equations
In general, an (n
(6.2:6)
+ l)st approximation x
=
x.. ,
Y=Y.. ,
is obtained from the nth approximation by means of the equations
(6.2:7)
x.. = F(X.._1 , Yn-1)'
Yn
=
G(Xn_1 , Yn-1)'
Our first problem is to determine the circumstances under which these approximations converge to the solution
(6.2:8)
x
=
T,
Y
= s,
that we are trying to find of Eqs. 6.2: 1. We have T = F(T, s),
(6.2:9)
s
=
G(T, s),
and therefore (6.2:10)
T - Xl = F(T, s) - F(xo ,Yo),
s - Y1
=
G(T, s) - G(xo , Yo).
205
6.2. THE METHOD OF ITERATION
Now, by the Law of the Mean for functions of two variables,
= (r G(xo ,Yo) = (r -
F(r, s) - F(xo ,Yo) G(r, s) -
+ (s - Yo)F (t, u), xo) G.,(v, w) + (s - Yo) Giv, w),
xo)F.,(t, u)
lI
u
= Yo + 8(s - Yo);
0< 8 < 1;
w
= Yo + 8'(s - Yo);
0;-1 (. t .), J I - J
by 7.1 :23, it follows that
(7.2:3)
dy dx
= y ' = !h ~ [~ ~ ~ ,=1
;=1
(-1 )H ( t )] Ai . . _. '" Yo . J I J
By rearranging the terms, this formula can be written as
(7.2:4) The last two expressions are the general formulas for the derivative of the polynomial 7.2: I at an arbitrary point. Of special interest, however, are the values of the derivatives at the points 7.1: 1. These can be obtained by putting t = 0, I, ... , n, in turn, in either of the last two formulas. We have, putting t = 0,
(7.2:5) which may be written, if we recall 2.3:16.4, in the symbolic notation
(7.2:5')
Yo'
= ~ In(1 + .1) Yo
(.1 nH = .1n+2 = '" = 0). To facilitate the computation of the coefficients of .1Yo, .1 2yo, ... , in the expressions for Y/, Y2', Ya', ... , rewrite 7.2:3 in the form
(7.2:6)
Y
,
At = Ii1 ~d ~ t.t'" Yo ,
t=1
7.2. NUMERICAL DIFFERENTIATION IN TERMS OF FINITE DIFFERENCES
225
TABLE 7.2:t1a
d,.,
VALUES OF
y/
=
FOR NUMERICAL DIFFERENTIATION
! ~ d,., A'yo h
2
3
1-1
5
4
1 2 1
1 3
2
2
6 1 3 11 6
7
13
2
3
25 12
5
9 2
47
77
6
6
11 2
37
12 57
3
4
10
13
107
2
6
15
73
2
3
17
191
319 12 533 12 275
459 20 743 15 1879 20 1627 10
o
2 3 4
7
8 9 10
3
2 5
1 4
7
6
8
1 9
10
56
72
90
105
168
252
360
140
280
504
840
105
280
630
1260
168
504
1260
56
252
840
8 761 280 4609 280 3601 56
72 1
360
9 7129 2520 4861 252
90
-
1
8
5 1
6 1
7 1
1
12
20
30
42
1
1
12
30
60
1 4
20
60
2
6
4
19
121
2
3
1207 12
10
9
1 1
1 1
-
1
30
5
137 60 87
1
1
-
6
42
49 20 223 20 341 35 2509 30 2131 12
7 363 140 481 35 3349 70 2761 21
1
1
1
1 1
10 7381 2520
where
(7.2:6.1)
.=~(-l)H( ~ . .
de ••
;-1
J
t). ,
1- J
The identity,
(7.2:6.2)
d e•i
=
de- 1• e- 1
+ de-I.; ,
can be readily derived from the definition of the d's. Note that this is actually an identity in the variable t; however, we shall use it only to
226
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
compute the coefficients of Llyo , Ll2yo , LlSyo , "', in the expressions for = 1,2,3, "', in turn. The d's, up to and including the coefficients of LllOyo, are given in Tables 7.2:tlabc. The coefficients in the first row are obtained directly from 7.2:5; the same formula also tells us that every coefficient in the first column is unity. The remaining coefficients are computed by means of 7.2:6.2, each is the sum of the one directly above and the one just above and to the left. In Table 7.2:tla, the coefficients are given in fractional form and are exact values; in Table 7.2:tl b, the coefficients
Yt"Y2',yS', "', by putting t
TABLE 7.2:tlb VALUES OF
d,., FOR NUMERICAL DIFFERENTIATION
y, ,
= -h1 ~ d'i• .d'Yo ,-1
, 1 ~ (-I)-d,., , 1 .d'Y-i Y-t=;; ,-1
Divide
:1
2
3
4
all
entries
5
by 2520.
6
7
8
9
10
-- - - - - - - - - - - 0 2520 -1260 840 -630 504 -420 360 -315 280 -252 1 2520 1260 -420 210 -126 84 -60 45 -35 28 2 2520 3780 840 -210 84 -42 24 -15 10 -7 3 5220 6300 4620 630 -126 42 -18 9 -5 3 4 2520 8820 10920 5250 504 -84 24 -9 4 -2 15 2 5 2520 11340 19740 16170 5754 420 -60 -5 6174 360 -45 10 -3 6 5220 13860 31080 35910 21924 7 2520 16380 44940 66990 57834 28098 6534 315 -35 7 8 2520 18900 61320 111930 124824 85932 34632 6849 280 -28 9 2520 21420 80220 173250 236754 210756 120564 41481 7129 252 10! 2520 23940 101640 253470 410004 447510 331320 162045 48610 7381
i
were written with the common denominator 2520 and the numerators only were entered in their proper places; in Table 7.2:tlc, the coefficients were written in decimal notation and they are, for the most part, correct only as far as written. The table is used in the most obvious fashion. Thus, if y = f(x) = S X 8x + 5, xo = 0, h = I, we find on forming the difference table that Llyo = -7, Ll2yo = 6, LlSyo = 6, and, of course, Ll4yo = Ll5yo =
... =
o.
7.2. NUMERICAL DIFFERENTIATION IN TERMS OF FINITE DIFFERENCES
227
TABLE 7.2:tlc d, •• FOR NUMERICAL DIFFERENTIATION
VALUES OF
\ I I I I I I I I I I I
0 I 2 3 4 5 6 7 8 9 10
2
3
4
5
-0.50000 00000 0.50000 00000 1.50000 00000 2.50000 00000 3.50000 00000 4.50000 00000 5.50000 00000 6.50000 00000 7.50000 00000 8.50000 00000 9.50000 00000
0.33333 33333 -0.1666666667 0.33333 33333 1.83333 33333 4.33333 33333 7.83333 33333 12.3333333333 17.83333 33333 24.33333 33333 31.83333 33333 40.33333 33333
-0.25000 00000 0.08333 33333 -0.08333 33333 0.25000 00000 2.08333 33333 6.4166666667 14.25000 00000 26.58333 33333 44.4166666667 68.75000 00000 100.58333 33333
0.20000 00000 -0.05000 00000 0.03333 33333 -0.05000 00000 0.20000 00000 2.28333 33333 8.70000 00000 22.95000 00000 49.53333 33333 93.95000 00000 162.70000 00000
~
6
7
8
o
-{).16666 66667 0.1428571429 -{).12500 00000 I 0.03333 33333 -{).0238095238 0.0178571429 2 -{).0166666667 0.00952 38095 -{).0059523810 3 0.01666 66667 -0.0071428571 0.00357 14286 4 -{).03333 33333 0.00952 38095 -{).00357 14286 5 0.16666 66667 -{).0238095238 0.0059523810 6 2.45000 00000 0.1428571429 -{).01785 71429 7 11.1 5000 00000 2.5928571429 0.1250000000 8 34.10000 00000 13.7428571429 2.7178571429 9 83.63333 33333 47.8428571429 16.46071 42857 10 177.5833333333 131.4761904762 64.30357 14286
9
10
0.11111 11111 -{).0138888889 0.0039682540 -{).0019841270 0.0015873016 -{).0019841270 0.00396 82540 -{).0138888889 O.lllll11lll 2.8289682540 19.2896825397
-{).IOOOO 00000 0.0111111111 -{).00277 77778 0.0011904762 -{).0007936508 0.0007936508 -{).001l904762 0.00277 77778 -().Ollli lllli 0.10000 00000 2.9289682540
Hence Yl'
= /,(1) =
1(-7) + ~ (6) -
Ys'
= /,(6) =
1(-7) +!! (6) 2
i
=
-5,
+ 373 (6) =
100.
(6)
These values can be checked by ordinary differentiation.
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
228
Note that the value of the derivative at a particular point, say /,(6), can be found in several ways. Indeed, we have if
Xo
= 2,
YII:
= /,(6) =
1(11)
+ ~ (18) + 1: (6) =
if
Xo
=
Y3'
= /,(6) =
1(29)
+ ~ (24) +
3,
Ii
(6)
=
100, 100,
if Xo = 6, Yo' = /,(6) = 1(119) - ~ (42) + ~ (6) = 100, etc. H f(x) is a polynomial of max-degree 10, Tables 7.2:tlab will yield exact values for the derivatives; if f(x) is not a polynomial of max-degree 10, the results will be approximate. The magnitudes of the errors will be discussed in Section 7.5. Incidentally, Table 7.2:tl can be extended backward to enable us to compute Y-l , Y-2 , .... (See Table 7.2:t2.) In all cases, however, we TABLE 7.2:t2 VAI.UD OF
Y':e
2
2 3 4
5
6 7
8 9
10
I
de•1
FOR NUMERICAL DIFFERENTIATION
= ~ d e•1 ..:Ilyo,
3
Ye'
1=1
4
=
~ ~ (-1)1-1 de•1 ..:IIY_I 1-1
5
6
7
8
9
10
761 7129 7381 3 11 25 137 49 363 2 6 280 2520 2520 12 60 20 140 4861 55991 5 13 77 481 4609 87 223 280 2520 2 3 12 10 35 252 20 7 47 3601 42131 44441 57 459 341 3349 2 6 4 70 56 504 420 20 10 9 37 32891 35201 485333 319 743 2509 2761 -2 3 21 168 126 1260 12 15 30 11 107 28271 395243 420983 533 1879 2131 25961 ---2 6 360 12 20 12 84 56 504 13 73 522109 275 1627 323171 348911 20417 22727 -- -60- -35- - -280- 180 2 3 168 10 4 15 191 134159 1207 15797 18107 263111 288851 312875 --- - - - - ------ --- -182 6 72 12 210 120 60 30 17 121 2074783 474742 261395 1135670 -2- - -1691 - -2021 - 30233 --30- - - - -56- - - - -126 126 3 12 210 5 5713839 19 299 477745 8842385 763 11899 96163 108175 --- ---- ------ - - - - - - - 2 6 504 168 20 28 56 4 60 33464927 21 181 831225 8161705 3013 25361 48975 44185 -2- --30- -56- - - - 504 3 12 252 20 7
--
7.2. NUMERICAL DIFFERENTIATION IN TERMS OF FINITE DIFFERENCES
229
are computing a derivative in terms of differences that form a descending diagonal in the difference table. We derive next the table based on formula 3.8:14 which we write again:
(7.2:7) where t
= (x - x_1)/h. We have dy d
X
Put z
= Y' = ~ (-I)' ~Y-I Ai ~ d~ (1
x,-.t).
.-0
= 1 - t, then d dx
(1 -i t) =dxd (Z)i =dxdz dz d (Z) i = _!
±
h ;-1
(-IY-l (. Z .) J ' - J
(by 7.2:2)
Hence
dy= Y '=!~(_I)'A' .~(-I);(I-t) h~ ~Y~~· . ., dX i-I ;-1 J ' - J or
(7.2:8)
i • Y ,=!~[~(-I)H(I-t)] h~ ~ . . . .1Y_i, 1-1 ;-1 J ' - J
(7.2:9)
Y
,
1 ..-1
= h- ~ (-1)1 ( i-O
If we put t
(7.2:10)
1- t .)
';=1+1 J
= 1, we obtain Yo
,
=
..
~ 1
1
.
[~ ~.1'y_;]
Ai ~-:~y-i' 1-1 '
'
.
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
230
The resulting table of coefficients is the same as Table 7.2:t1. To illustrate the use of the table, we take Y = J(x) = x3 - 8x 5, xo = 0, h = 1; whence LlY_1 = -7, Ll2Y_2 = -6, Ll3Y_3 = 6. We have
+
i
Y'-2 = /,(-2) = 1(-7) -
~ (-6) +
Y'-a = /'( -6) =
Ii (-6) + 337 (6) =
1(-7) -
(6)
4, 100.
As before, y' can be computed exactly from the entries in the table if Y = f(x) is a polynomial of max-degree 10. This table too can be extended backward and, in any case, it gives us a derivative in terms of differences that form an ascending diagonal in the difference table. If we start with formula 3.8:15, namely, (7.2:11)
-
Y-
[n/2]
~ Ll2t
~
Y-i
i-O
(t - I + i) + [(n+1)/2] (t - I + i) ~ Ll2i-1 2' ~ Y1-i 2' - I ' I
i=1
I
we obtain (7.2:12)
, _ ! l[n/2] (t -2' I_ +. i)] :t LI 2iY -[2ii :(_I)H t.
Y - h
+
J
;-1
i-I
J
(_Iy-l (t - I + i)] I :t Ll2t _lYl-i [2i-l :t --.-2i - I _. . J J
[(n+1)/2]
;-1
i-I
If t
I
= 0,
(7.2:13)
[2i (-I)H(i-I)] :t LI 2iY-i:t . 2i _ . J J
'_!I[n/2]
Yo - h
;=1
i-I
+ -_ IiI
[2f-l (_I)H (
[(n+1)/2] 2i-l
:t i-I
LI
Yl-i:t
[LI I Ll2 Yo - 2 )'-1
.
J
;=1
-
6"I Lla)'-1
I I - 60 Ll8Y_a - 140 Ll7Y_a
_ _1_LlI011 =!= ...] 1260 J-6·
•
i-I 2i - I - '
J
)]1
I
+ 12I Lifo)'-2 + 30I LI&)'-2 I
I
+ 280 Ll8y _ + 630 Ll9Y fo
-40
7.2. NUMERICAL DIFFERENTIATION IN TERMS OF FINITE DIFFERENCES
231
Finally, starting with formula 3.8:16 or (7.2:14)
[n/2]
Y
.
= i-O ~ .1 2·Y_i
(t - i + I)
+
2· I
[(n+l1/2]. .1 2.-1Y_i
~
(t - 2+ i) 2·-1
i-I
I
'
we obtain (7.2:15)
, _ 1 ![n/2]
Y -
h ~.1
[2i
2i
Y-i
i-I
+ If t
~
;-1
[('I+U/2]
~ .1
(-I)H • J
(t 2i- _1 +. i)] J
2i-l [2i-l Y-i
~
(-I)H •
J
;=1
i=1
(t2i -_ 21+_.i)]1 . J
= 1,
(7.2:16)
, _ ! l[n/2] 2i [2i (-I)H ( i ~.1 Y-i ~ . 2i _
Yo - h
i-I
+
J
i-I
[(n+l1/2]
~ .1
[2i-l
2i-l
~
Y-i
.
J
;-1
i-I
-_ h1 !.1Y-l
(-I );-1
+ 21 .12Y-l - 61 .13Y-2 -
1
+ 60 .1 8Y_3 -
1
140 .1 7Y_40
)]
. J (
i - I )] 1 2i _ 1 _ . J
1 .140 12 Y-2
1
-
280 .1 8Y_40
+ 301 .15Y-3 1
+ 630.1'y-s
+ li60 .1 10Y_6 =f .··1· Formulas 7.2:13 and 7.2:16 give formally different but actually equal expressions forj'{xo).lfwe add and divide by 2, we obtain the particularly simple formula (7.2:17)
, _ ! [.1Y - 1 + .1yo _ ! .1 3Y_2 + .1 3Y_l + .! .1 5Y_3 + .1 5Y_2
Yo -- h
2
6
2
30
2
This formula could have been obtained from 3.8: 17 as the preceding formulas were obtained from their predecessors. Formulas for the second and higher derivatives, Y
"
=
d2y
dx 2
'
Y
If'
= day dx3'
... ,
TABLE 7.2:t3a
'"w '"
VALUES OF Ck,i FOR NUMERICAL DIFFERENTIATION
h It ylk) 0
= ~Cti'. .diy0,
hky(k)
o
i=k
SJ 21 3 1 41 5 I 61 71 8 9 10
2 1 -2
3 1 3 - 1
4 4 11 12 3 2
5
5 5 6 7 4 -2
= ~ (-I)1'+ickit: .diy-i i-k
6
7
1 -6 137 180 15 8 17 6 5 2
7 7 70 29 15 7 -2 25 6 -3
8
9
1 -8 363 560 469 240 967 240 35 6 23 4 7 -2
1 9 761 1260 29531 15120 89 20 1069 144 -9 91 12 -4
10
11
10 7129 -12600 1303 672 4523 945 285 32 3013 -240 105 8 29 3 9 2
11 671 1260 16103 8400 7645 1512 31063 3024 781 48 4781 240 55 3 12 -5
12
13
14
:'"I Z
c
3: m
'"n »-
r-
2"T1 "T1
m
'"Zm
-I
;; -I
0 z »10831 360 99 4 175 12
Z 0
1747 40 65 2
Z m
-I C)
491 8
'"-I »0 Z
......
TABLE 7.2:t3b VALUES OF
hty(t) o
=
kC
._k
i"
k,i
L1'y
0 '
hty(:'
=
k
:I m r-
m
2
3
4
5
6
7
""Zm
-0.5 1
0.33333 33333 -1 1
-0.25 0.9166666667 -1.5 1
0.2 -0.83333 33333 1.75 -2 1
-0.1666666667 0.7611111111 -1.875 2.83333 33333 -2.5 1
0.1428571429 -0.7 1.93333 33333 -3.5 4.16666 66667 -3
;; -I 0 z
~I
-I
Z -I
m
""
:I
II>
0.."
_____
8
5 , 6 ' 7 8 9 10
""n>
(-I)HiCt ,. L1iy _.
.-t
.." .."
1 I 2 I 3 I 4 I 5 I
1l
C
Q
~ _1
Z
Ct .• FOR NUMERICAL DIFFERENTIATION
-0.125 0.64821 42857 -1.9541666667 4.0291666667 -5.8333333333 5.75 -3.5
9 0.11111 11111 -0.60396 82540 1.95310 84656 -4.45 7.42361 11111 -9 7.58333 33333 -4 1
10 -0.1 0.56579 36508 -1.93898 80952 4.7862433862 -8.90625 12.5541666667 -13.125 9.66666 66667 -4.5
11 0.09090 90909 -0.53253 96825 1.9170238095 -5.0562169312 10.2721560847 -16.2708333333 19.9208333333 -18.33333 33333 12 -5
12
13
14 -----
.."
Z
=i m
Q
.." .."
m
""zm
n m
II>
30.08611 11111 -24.75 14.58333 33333
43.675 -32.5
61.375
....
w w
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
234
can be found by repeated differentiation of Eqs. 7.2:3 or 7.2:4, 7.2:8 or 7.2:9, 7.2:12, 7.2:15. If we substitute 0 for t in these results, we ' 1 f or t, we 0 b ' ' ,'Yl ' ' , Yl(4) , ... ; · Yo" , Yo,,, , Yo(4) , ... ; 1'f we su bstltute ob tam tam' Yl and so on. Some of these results are given in Tables 7 .2:t3ab; the entries are self-explanatory and need no further comment. EXERCISE 7.2
1. By use of formula 7.2:3 or 7.2:4, find dyldx at x = 0.5,0.9, I, 1.3,5,5.3,6,6.1, if y = In x. Take n = 3, h = and appropriate values for Xo. Use a five-place table. Determine the error in each case by using dYldx = Ilx.
I,
2. By use of formula 7.2:3 or 7.2:4 and a five-place table for sin x (x in degrees), find d(sinx)/dx at x = 0°, 1°, 1°20',2°,50°,51°15',52°40',88°,89°,90°,91°,92°. Take n = 4, h = 2, and appropriate values for Xo • Determine the error in each case by means of ordinary differentiation. 3. Use formula 7.2:6 and Tables 7.2:tl, 2 to find the derivatives at the indicated points from the tabulated values of the functions . •. x = 28, 32, 34, 38, 46, 50. b, x = 3.70,4.75,5.10,6.50,7.20,7.90. C, x = I, 3, 6, 8, 12, 13. d, x = 25, 28, 32, 36, 40, 45.
•
b
d
C
x
f(x)
x
f(x)
x
f(x)
x
f(x)
34 36 38 40 42 44 46
0.31270 34549 37904 41318 44774 48255 51745
5.10 5.45 5.80 6.15 6.50 6.85 7.20
1.62924 69562 75786 81645 87180 92425 97408
5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0
38.02952 39.14868 40.20726 41.21285 42.17163 43.08869 43.96830 44.81405
30 31 32 33 34 35 36 37 38
0.23137745 22035947 20986617 19987254 19035480 18129029 17265741 1644 3563 15660536
4. Do example 3 using Table 7.2:tl. 5. Use Table 7.2:t3 to find, where possible, the first five derivatives of the functions of example 3. 6. Derive tables similar to 7.2:t3 for the derivatives at Xl
, X2 , Xa ,
x, .
7. Derive the identity 7.2:6.2.
I. Prove the following about the entries in Table 7.2:t3 . •. If hiy~iI = a i •i .:jiyo - a i •i +1 .:jHlyo ai+1,i+l
=
al,'+'_l
+ ai.H2.:ji+2yo =F
+ lai,'+'-2 + !ai,i+l-a + ... , j =
then 1,2,3, ....
7.3. NUMERICAL DIFFERENTIATION IN TERMS OF ORDINATES
235
b. If the numbers in the first row of the table are multiplied by I/ll. those in the second row by 1/2! • ...• those in the kth row by Ilk! • ...• then the sum of the numbers in any column after the first is zero; the sum of the positive numbers is t. c. The ith diagonal (of the original table) is an arithmetic progression of order i - I (read diagonals down and to the right).
7.3. Numerical Differentiation in Terms of Ordinates. In this section we shall present formulas for the numerical evaluation of derivatives of a function Y = f(x) in terms of the ordinates Yo , YI , Y2 , .... The most obvious way of obtaining such formulas merely involves the substitution for the finite differences in the formulas of the last section their values in terms of the ordinates. We recall the equalities 3.7:13 which we repeat here with a slight change of notation:
i = 1,2,3, ....
(7.3:1)
If we substitute these values in 7.2:3 and 7.2:4, we obtain (7.3:2)
and (7.3:3)
dy
dx
= y' = !
2 (t) [±
h i=u I
;-i+l
(-I )H-l . ~ . J I
±
(-I );-k
k-O
(i)k Yk] ,
where t = (x - xo)Jh. These formulas give dyJdx at an arbitrary point in terms of the ordinates Yo , YI , ... , Yn . The formulas for the values of the derivatives at the equally spaced points (xo, Yo), (Xl' YI)' (x n , Yn), are of particular importance. These can be obtained from the entries in Table 7.2:tl by use of 7.3:1. This time it is necessary to list the formulas for each value of n separately since the coefficient of a particular ordinate, Yi , will ordinarily change as n changes. The results will be found in Table 7.3:tl. The entries in this table can be found directly without recourse to the formulas of the preceding section by interesting and instructive methods. We recall that the notation was so chosen that (7.3:4)
Xk -
xi
=
(k -
i) h,
j,k = 0, I, ···,n;
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
236
TABLE 7.3:tl K
VALUES OF Ck./ AND
FOR NUMERICAL DIFFERENTIATION
K ..
Y/ =
.k
2 0 1
3 0
I 4 0
I
I
I
7
-I
I
48 -10 -8
-36 18 0
16 -6 8
I -I
lo
-137 -12 3
300 -65 -30
-300 120 -20
200 -60 60
-75 20 -15
12 -3 2
1
-147 -10 2
360 -77 -24 9
400 -100 80 0
-225 50 -30 45
72 -15 8 -9
-10 2
-I
-450 150 -35 -45
-1089 2940 -4410 4900 1260 -1050 -60 -609 700 10 -140 -329 -4 42 -252 -105
-3675 700 -350 420
1764 -315 140 -126
-490 84 -35 28
1
12
60
o 4~0
o slo I
2 3 4
~ 2120 2 3 4
6
5
-9 6
2 3
9
4
18 -3
1
"6
1
8
3
-I I
2 3 7
2 4 0
2 6 0
I
0
2 5 0
/-0
A l
h ~ Ck,/Yi
-3
-I -ll
-2 -25 -3
-2283 6720 -1l760 2940 -105 -1338 15 -240 -798 60 -420 -5 3 -32 168
8
9
10
2 -3
-I I 60 -10 4 3
15680 -14700 9408 -3920 960 -2940 2450 -1470 588 -140 1680 -1050 560 -210 48 -378 1050 -420 140 -30 -672 0 672 -168 32
-105 15 -5 3 -3
-79380 63504 -35280 12960 11760 -8820 4704 -1680 -4410 2940 -1470 504 3780 -1890 840 -270 -504 2520 -840 240
-2835 360 -105 54 -45
-7129 22680 -45360 70560 -280 -4329 10080 -1l760 5880 35 -630 -2754 135 -1080 -1554 -10 360 -1680 5 -60
280 -35 10 -5 4
10 0 2120 -7381 25200 -56700 100800 -132300 127008 -88200 43200 -14175 2800 -252 28 17640 -15876 10584 -5040 1620 -315 I -252 -4609 11340 -15120 -7 80 6720 -5880 4704 -2940 1344 -420 2 28 -560 -3069 3 1470 -630 189 -35 3 105 -945 -1914 4410 -2646 -7 -2 270' -1440 24 -924 3024 -1260 480 -135 3 -40 4 2 25 -150 600 -2100 0 2100 -600 150 -25 5 -2
--------------------------------------------------------------
237
7.3. NUMERICAL DIFFERENTIATION IN TERMS OF ORDINATES
we use these identities in 7.1:5 to obtain
(7.3:5) Hence, from 7.1: 11 we find (7.3:6)
L '(x) = (-I )k-J-I _1_. k
k- J
J
(~) !h' (j)
j =1= k,
and
the last identity can be rewritten as if n
< 2j,
if n = 2j,
(7.3:7)
if n
> 2j.
As an illustration of the use of these formulas in deriving the entries of Table 7.3:tl directly, we compute the value ofYl' in terms ofthe ordinates Yo, Yl , Y2 , Ya , Y4 . We have from 7.1:12, Yl' = p'(x1 ) = ~;_OL/(Xl) Yi , and from 7.3:6, L'( ) - (-1)-2 _I o Xl -I
L'() 2 Xl
=
(1)0 I -
I
(~)!h -__ 4h~ ' (1)
(~) IiI = (1)
3
2h '
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
238
and from 7.3:7,
,
Ll (Xl)
5. = - (I2 + 3I) Ii1= - 6h
Hence
It follows from 7.3:6 that (x
L' n-k
)
.
(_I)(n-k,-(n-,,-l
=
(_I)H-l _._1_ 1 J-k(n.)h n -J
n-;
(n ~ k) 1-
1
=
(n - k) - (n - j) ( n .) h ' n -J
(n ~ k)
Therefore (7.3:8)
Also, if n
2(n - j) and
~ ( n - ; + 1 + ... + n -
-~(n-;+ 1 + ... + j) =
If n
= 2j, then n = 2(n - j) and
If n
>
2j, then n
(x) = dX
f"l("" "0(""
of(s, x) d _ F( ) dvo F( ) dV I s Vo , x d + VI , x d . 0 X X X
We use this formula to find J'(x)
= Pn'(x) + (n
_1 I)!
f'"'" (x -
s)n-y(n+1l(s) ds,
o
I"(x)
=
p"(x) n
+ (n - 1 2)1 f'"
(x -
"'0
(7.5:11 n)
pnl(x)
=
p';:'(x)
+
r
/,n+1l(s) ds.
"'0
s)n-~(n+1l(s) ds
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
250
Now suppose we wish to find the expression for the error when the derivative of a function f(x) is approximated by a formula, say the first formula of Table 7.3:tl. The error at x = Xo (note that the Xo of 7.5:10 is purposely chosen as the Xo of the table) is given by (7.5:12)
Since the formula we are testing is exact for polynomials of max-degree 2, we put n = 2 in 7.5:10 and 7.5:11 1 and substitute into 7.5:12. We obtain E(xo)
=
pz'(xo) +
I
"'o
(xo - S)/,31(s) ds
"'0
=
IPz'(x o) -
-
~ [-3Pz(xo) + 4P2(X1) -
~ 14 I"'l (Xl
4h
- s)Z /,31(s) ds -
"'0
pz(xz)]
I"'a (xz "'0
I
s)Z /,31(S) ds l .
I
Since P2(X) is a polynomial of max-degree 2 and the formula we are testing is exact for such polynomials, the first brace is identically equal to zero and E(xo) reduces to (7.5:13)
In order to evaluate the preceding expression, we introduce a function U(s I a, b) of the variable s and the constants a and b, a ~ b, defined by the statement if s < a, U(, I _, b) (7.5:14) if a ~ s ~ h, if s > h.
~ I~
The function U(s I a, b) is thus equal to unity in the closed interval from a to b and is zero elsewhere; the function is sometimes called the char-
7.5. MAGNITUDE OF THE ERROR IN NUMERICAL DIFFERENTIATION
251
acteristic function of the closed interval [a, b] on the real axis. * Hence if g(s) is any function of s, the function g(s)U(s I a, b) coincides with g(s) in the closed interval from a to b and is equal to zero for all other values of s for which g(s) is defined. We use the new function to write E(xo) in the form
- f"" (XI -
S)11'31(s) U(s I Xo , XI) dS)
"0
or
Since the range of integration is from Xo to XI , the factor U(s I x o , XI) is really unnec~ssary; we put it in for the sake of symmetry. We consider that part of the integrand within the brackets, namely, R(s)
R(s) = 0 if s
R(s) = -(XI - S)I < 0; R(xl ) = 0; XI. The shape of the graph of R(s) is shown in
* One "explicit" definition for U(sl a, b) is
U(sl a, b)
=
~.~.~a I] [e.~:·: I] ,
where [x] is the greatest integer which does not exceed x. The constant e can be replaced by any other constant greater than unity and there are other "explicit" methods of defining the function.
252
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
Fig. 7.5:fl. It follows that R(s) is never positive and therefore by the Law of the Mean for integrals the identity 7.5: 15 may be rewritten as 1 f"" R(s) ds, E(xo) = - 4hf'3'(X)
(7.5:16)
"'0
where X is a value of x between Xo and X 2 • The important feature of the last expression for the error is that the integrand R(s) is independent of the function f(x). R(s)
----~--------~~--~~~~-------s
FIG. 7.5:f1.
The integral S;: R( s) ds can be evaluated directly or by use of 7.5: 12 and 7.5: 16 where a particular function is chosen for f(x). Indeed, we have by direct integration
f O'· R(s) ds = 4 f"'l (Xl ~o
S)I ds -
%0
= -
4 -3 (Xl -
f""
(XI - S)I ds
Zo
S)3
I",~o +"31 (XI - S)3 I",~0
On the other hand, take f(x) = (x - xo)(x - xl)(x - XI) so that f'(x) = (x - xI)(x - x 2) + (x - xo)g(x) and f'3'(X) = 6. We find on equating the values of E(xo) given by 7.5:12 and 7.5:16 that
7.5. MAGNITUDE OF THE ERROR IN NUMERICAL DIFFERENTIATION
253
Hence
as before. Consequently, (7.5:17)
Let us compare this result with the result given by 7.5:9'. Since t = 0, n = 2, we find by use of Table 7.5:tl that E(xo) = h2J r-
Z
Cl
-4 -5 I
-4
8
44 3
24
1634 45
2336 45
67192 --945
17800 189
1721263 ---14175
26798 -175
88671367 467775
-5
25 2
325 12
1225 24
12575 --144
4455 32
2543875 ---12096
7365875 --24192
- 8831375 -20736 --
168091625 290304
14725896425 19160064
18
- 45
96
1833 10
645 2
74591 --140
29304 35
1768401 ---1400
368431 200
16082039 6160
10401769 8640
7054229 3456
1712943127 518400
2634975 512
530812423351 68428800
-6 !
-6
-7 I
-7
49 2
833 12
1323 8
251027 --720
966427
-8 I
-8
32
304 -3
800 3
27688 --45
6432 5
2353328 ---945
--
611744 135
111071276 14175
184021888 14175
1940263936 93555
-9
81 2
567 -4
3267 8
81891 --80
369603 160
10752669 2240
8361225 --396
109871559
2701401201 89600
100312094331 1971200
50
575 -3
600
29225 --18
70805 18
6602825 ---756
3414400 189
159817025 4536
3661425 56
34808875345 299376
-9 I
-101 -10
1440
6400
'">-I 0 z
Z -I m
'"3:
II>
0"T1 "T1
Z
~ m
Q "T1 "T1
m
'"mz
n m
II>
...,
0-
w
TABLE 7.7:tlb
........ 0-
VALUES OF
Ck,i
FOR NUMERICAL INTEGRATION
{kf(X) dx
=
h
%'0
,diyo
i-O
{o f(x) dx = h
k
(_l)iCk,i ,diY_i
i-O
Z_k
0
k Ck.i
2
3
4
5
k I
1 2 3 4 5 6 7 8 9 10 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10
2 3 4 5 6 7 8 9 10 -1 ~2
I
-3 -4 -5 -6 -7 -8 -9 -\0
0.5 2 4.5 8 12.5 18 24.5 32 40.5 50
-0.08333 33333 0.33333 33333 2.25 6.66666 66667 14.5833333333 27 44.9166666667 69.33333 33333 101.25 141.6666666667
0.0416666667 0 0.375 2.66666 66667 9.375 24 51.0416666667 96 165.375 266.6666666667
-0.02638 88889 -0.01111 11111 -0.0375 0.31111 11111 2.9513888889 12.3 36.27361 11111 87.28888 88889 183.2625 348.61111 11111
0.01875 0.01111 11111 0.01875 0 0.32986 11111 3.3 15.61875 51.91111 11111 139.21875 322.5
0.5 2 4.5 8 12.5 18 24.5 32 40.5 50
-0.4166666667 -2.3333333333 -6.75 -14.6666666667 - 27.08333 33333 -45 -69.4166666667 -101.33333 33333 -141.75 -191.6666666667
0.375 2.6666666667 9.375 24 51.0416666667 96 165.375 266.66666 66667 408.375
-0.34861 11111 -2.9888888889 -12.3375 -36.3111111111 -87.3263888889 -183.3 -348.6486111111 -615.2888888889 -1023.6375 -1623.61111 11111
0.32986 11111 3.3 15.61875 51.9111111111 139.21875 322.5 671.12986 11111 1286.4 2310.01875 3933.61111 11111
600
:"'I Z
c
:I m
""n»r-
~
." ."
m m
""Z
-I
;; -I 0 z »z 0
z
-I m Cl
»""-I 0 z
......
~
TABLE 7.7:lb (continued)
Z
C
L I
k
I
I
2 I 3 4 5 6 7 8 9 10
:I m
7
8
9
10
6
'" n > ,...
Z -t
-0.0142691799 -0.00978 83598 -0.0129464289 -0.0084656085 -0.02273 47884 0.2928571429 3.57858 79630 19.18306 87831 71.0799107143 210.28439 15344
0.0113673942 0.00846 56085 0.01004 46429 0.00846 56085 0.0113673942 0 0.3042245370 3.8941798942 23.08861 60715 94.1798941799
-0.00935 65366 -0.00734 56790 -0.00823 66071 -0.0075485009 -0.00843 94290 -0.0064285714 -0.0157851080 0.27908 28924 4.16390625 27.2431657848
0.00789 25540 0.0064285714 0.00697 54464 0.00663 13933 0.00697 54464 0.0064285714 0.00789 25540 0 0.28697 54464 4.45877 42504
-0.00678 585 -0.0056791460 -0.0060364245 -0.0058468281 -0.00600 12848 -0.00581 16883 -0.0061689669 -0.0050622628 -0.0118481128 0.26834 14836
m
C)
'">-t
(5 Z
z -t
m
'":I VI
0
.." .."
Z ::::j
m
-1 -2 -3 -4 -5 -6 -7 -8 -9 ' -10 i
-0.3155919312 -3.6013227513 -19.2058035714 - 71.10264 55026 -210.3071263228 -532.7928571429 -1203.90844 90741 -2490.2941798942 -4800.2986607143 -8733.8955026455
0.3042245370 3.8941798942 23.08861 60715 94.1798941799 304.47565 31085 837.2571428572 2041.1542245370 4531.4370370370 9331.7243303571 18065.6084656085
-0.29486 80004 -4.1796913580 -27.2589508929 -121.42948 85362 -425.8957851080 -1263.14357 14286 -3304.2884394290 -7835.71611 99295 -17167.43109 375 -35233.0302028219
0.28697 54464 4.45877 42504 31.70983 25893 153.1314285714 579.01932 11254 1842.155 5146.435546875 12982.14377 42504 30149.5669754464 65382.5892857143
-0.2801895964 -4.7321779969 -36.4352247362 -189.5598674576 -768.5724027331 -2610.7206168831 -7757.1493779081 - 20739.28636 63086 -50888.8465559050 -116271.42905 57693
Q
.." .."
m
'"
m
Z
()
m
VI
..., a-
U!
266
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
of 7.7:8 and the right-hand member of 7.7:9 will have corresponding gaps. If we put t = I, 2, 3, "', in turn in 7.7:8 (or 7.7:9), we obtain the formulas of Table 7.7:tl for the evaluation of the integral 7.7:11. The first of these is known as Gregory's formula. The preceding formulas are in terms of forward differences; to obtain formulas in terms of backward differences we start with formula 7.2:7 and proceed along the same lines as above. The details are left to the reader to show that
f~ y dx =
h
!C ~ t) Yo
- [C ~ t) + ~ C~ t)] ~Y-l + [C ~ t) + ~ C~ t) - 1; C~ t)] ~2Y_2 - [C ~ t) + ~ C~ t) - I; C~ t) + 2~ C~ t)] ~aY_a ± .......................................
I·
This expression can be obtained from 7.7:8 by replacing each binomial by (li'), ~iyo by ~iY_i' and alternating the signs in coefficient front of the brackets. Note too the interchange of limits of the integral and that now, t = (x - x_1)/h. If we give t the values 0, -1, -2, "', in turn in 7.7:12, we obtain the formulas also given in Table 7.7:t1. Similar formulas can be found by starting with central difference expressions. However, an alternate method of derivation is noteworthy. Let
m
(7.7:13)
be a particular forward difference formula. Then (7.7:14)
to
Y dx = h[coYo -
C1
"-k
~Y-l + C2 ~2Y_2 -
Ca
~aY_a ± ...]
is a correct formula in terms of backward differences. Raise all subscripts on the y's and their differences by k in the last expression, then (7.7:15)
tk "0
Y dx
=
h[CoYk -
C1
~Yk-l + Cs ~2Yk_2 -
Ca
~aYk_a ± ...]
7.7. NUMERICAL INTEGRATION IN TERMS OF FINITE DIFFERENCES
267
is also a valid formula. Since 7.7:13 and 7.7:15 are formulas for the same definite integral, we obtain by addition and division by 2 (7.7:16)
+ Cs LISYo - 2LIsYk-S + ...] . This is a formula for the definite integral in terms of averages of differences that center about the midpoint between Xo and Xk • Another set of formulas is based on the Euler summation formula 2.5:28. Let Y = fl(Z) and put ~Ik)
= ftlk)(i).
Formula 2.5:28 may then be written as (7.7:17)
(fl(Z) dz
= (tYo + YI + ... + Yn-l + _
~
~
lYn)
Bli (yil/-U _ ylli-U)
(2j)1
n
0
+ R Ik •
Make the substitution Z = (x - xo)/h, where Xo a,nd h are arbitrary constants, h positive, and let Xl' X 2 , ••• , be the values of X corresponding to the values I, 2, ... , respectively, of z. We have fl(Z) = f(x), say, and for arbitrary positive integers k and T,
The summation formula can then be written as (7.7:18)
Ii1 f"''' f(x) dx = (tYo + YI + ... + Yn-l +
lYn)
"'0 k
B
_ ~ ~ (yI2i-U _ yll/-U) hl/-l ~ (2j)1 n 0
268
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
or (7.7:19)
r"f(x} dx
= h(!yo + Yl + ... + Y"-1 + ty,,}
"'0
_
~ B 2J ~
(y(2;-U _ y(2;-U) h2;
(2j}!"
+ R* 2k '
0
where yft) now means dr dxrf(x}
I"'="'k
This form of the Euler summation formula can, of course, be used for the evaluation of the integral but for greater facility in the computations it is better to replace the derivatives on the right by their values given in Table 7.2:t3. We first remark that if
is a formula of'Table 7.2:t3,
is a corresponding formula of Table 7.2:t3. If in the last equality we raise all subscripts on y(r) and the differences by the same integer n, we obtain the formula
Hence (7.7:20)
hr (y"(r) _ y(r)} 0
=
00
~ a ~
i=O
.(Llr+i1J
r.r+a
. _ (-I); Llr+iy )
J,,-(r+a)
Hence, by substitution into 7.7:19, (7.7:21)
r"f(x}dx = h [(iYo "'0
+ Yl + ... + Y"-1 + iy,,)
0 •
269
7.8. NUMERICAL INTEGRATION IN TERMS OF ORDINATES
The coefficients a2 i-1I2j-l+i are the numbers in the (2j - I )st row of Table 7.2:t3. Using these values of B2i from 2.3:21, we find (7.7:22) fnf(x) dx
= h [(lyo + Y1 + ... + Yn-1 + lYn)
"'0
- 112 (..1Yn-1 - ..1Yo) - ;4 (..12Yn_2 _.
7~ (..13Yn _3 -
-
+ ..1%)
..13yo) - 1~ (..1'yn-4
~:~o (..15yn_& -
..15yo) -
+ ..1'10)
2!~~2 (..16Yn _6 + ..16yo)
33953 (..17 ..17) 8183 (..18 - 3628800 Yn-7 Yo - 1036800 Yn-8
+ ..18Yo )
- ... - ...J. EXERCISE 7.7
1. Copy the values of cos x for x = 200• 22 0• 24 0•...• 300 from a five-place table. Compute. by use of 7.7:8 or 7.7:9. and Table 7.7:tl. cos x dx for u = 18 0• 190• 200• 210. ···.31 0.320.
g,
2. Use a five-place table and appropriate formulas to evaluate f: InS x dx for u = I. I.S. 2. 2.S. 4. S. 10. 3. Let functions be defined as in Exercise 7.2. example 3. Find
a. f:.!(x) dx b. f:.as!(x) dx c. f:. 5 !(x) dx d. J;,!(x) dx 4. If (2.3:2S)
for u = 33. 36. 40. 43. 48. for u = S.IO. S.SS. 6.00. 6.4S. 6.90. for u = 6.0. 6.4. 6.8. 7.8. 9.0. for u = 30. 32. 36. 37. 38.
In =
f! (!) dt
and
Hn =
f: (!> dt.
prove Hn
=
~i-o II(n-:+1).
S. Prove that the c's of Table 7.7:t1 satisfy the relationship Ct.1 = Ck-l.i-l + Ck-l.i + Cl.l. Starting with the formula for k = I. CO.I = 0 for every i. Ck.-l = 0 for every k. derive the other formulas of Table 7.7:tl.
7.8. Numerical Integration in Terms of Ordinates. In this section we seek formulas for the numerical evaluation of the definite integral (7.8:1)
r
f(x) dx
/J
in terms of the ordinates Yo , Y1' ... , Yn' where (xo, Yo), (Xl' Y1)' ... , (Xn ,Yn) are n + 1 points on the graph of Y = f(x) spaced h units apart.
270
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
The most primitive evaluation is found in any calculus text and depends on the very definition of the definite integral. If the x-axis from x = a to x = b is divided into n equal intervals by n 1 points whose abscissas are Xo = a. Xl' X 2 • •••• X n - l • Xn = b. then h r.~:oIYi and h r.~=IYi' where h = xHI - Xi. are crude approximations to the definite integral 7.8:1. The relation of these sums interpreted as sums of areas of rectangles to the definite integral interpreted as an area is well known and need not be elaborated here. The arithmetic average of the sums. namely. h[i(Yo + Yn) + r.~.:;.lYi]' usually gives a better approximation to the definite integral; the last expression is recognized as the sum of the areas of trapezoids and is also too well known for further mention here. More refined formulas can be obtained in several ways. The method of undetermined coefficients explained in Section 7.4 is also applicable here. As in the case of numerical differentiation. we use the basic set of polynomials
+
(7.8:2)
Y
=
I. Y
=
x. Y
=
xS, ... ,y
and the ordinates evaluated at the abscissas a formula of the type (7.8:3)
r o
y dx
=
boyo + blYI
X
=
x",
= O. 1. . ..• n. to obtain
+ ... + bnY" .
As before. the particular formula derived will be exact for all polynomials of max-degree n for ordinates at these abscissas. We obtain exact formulas for arbitrarily but equally spaced ordinates by multiplying the formulas found for abscissas O. 1•...• n by h. instead of by l/h as formerly. As an example. take k = 1 in formula 7.8:3. We must then determine the coefficients in (7.8:4)
(Y dx = boYo + blYI
+ ... + bnY"
so that this equation is exact for the polynomials of 7.8:2. Using the values O. I •...• n for x. we are led to the system of simultaneous linear equations bo + bl + bs + ... + b" = I, bl + 2b s + ... + nb" = 1, bl + 22b s + ... + n2b" = t, (7.8:5) bl
I + 2"b2 + ... + n"b,.. = -. n+1
7.8. NUMERICAL INTEGRATION IN TERMS OF ORDINATES
271
Note that these equations differ in form from Eqs. 7.4:1 only in the column of constants. Thus, for n = 3, we have bo + b1 b1
+ bz + + 2bz +
ba
=
3ba =
1,
l,
+ 4hz + 9ba = -1, b1 + 8b z + 27ba = i, b1
whence bo = 9/24, b1 = 19/24, b2 = -5/24, b3 we obtain the formula
= 1/24. Consequently,
which is exact for all polynomials of max-degree 3 for any four equally spaced points. Thus, from y = 2x3 - 8x, we find y = -6, -21/4, 0, 45/4, respectively, for x = 1, 2, i; and therefore
-t,
Ii (2x3 1
8x) dx
t [9(-6) + 19 (- -21) - 5(0) + -45] = - -95 = -24 4 4 32 .
The answer, of course, can be verified by direct computation. The formula is not exact for polynomials of degree 4. Another method of obtaining formulas of type 7.8:3 is by direct use of the formulas of Table 7.3:tl. For example, we have for n = 4,
= -25yo + 48Yl - 36yz + 16Ya - 3Y4 , 12hYl' = -3yo - 10YI + 18yz - 6Y3 + Y4' 12hyo'
12hyz' = 12hYa' =
Yo - 8Yl -Yo + 6Yl - 18yz
+ +
8Ya - Y4' 1OY3 + 3Y4 .
We eliminate y, from these equations to obtain 12h(yo' 12h(Yl' 12h(yo'
+ Ya') = + Y2') = + 3Yl') =
-26yo + 54Yl - 54Y2 + 26Ya, -2yo - 18Yl + 18yz + 2Ya, -34yo + 18Yl + 18yz - 2Ya'
We next eliminate Y3: 12h(yo' - 13Yl' - 13yz' + Ya') = 288Yl - 288yz , 12h(yo' + 4Yl' + yz') = -36yo . + 36Y2'
272
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
Finally, we eliminate Y2:
Hence
But J:~y' dx
= Yl - YO' and therefore,
which becomes the formula previously derived if we drop all the primes indicating differentiation. Note that since we used formulas from Table 7.3:tl that are exact when Y is a polynomial of max-degree 4 in deriving the last formula containing the primes, it is exact when the integrand is a polynomial of max-degree 3. However, the most expeditious method of obtaining numerical integral formulas of the required type is by substitution in the finite difference formulas. We use formula 3.7:13, namely,
±(-ly-i nYi+k'
.:1 rYk =
(7.8:6)
i=O
'
to replace the finite differences in 7.7:8. We obtain
(7.8:7)
J.., Y dx = h \/Ho (t)I Yo "0
+ [Ho G) + HI G)] (-Yo + Yl) + [Ho G) + HI G) + H2 G)] (Yo -
2Yl
+ Y2)
+ ........................... I, h±Hi ( _!+ 1)±(-ly-i(~)Yi' i=O
'
J
where the H's are given by 7.7:7.
i=O
'
273
7.8. NUMERICAL INTEGRATION IN TERMS OF ORDINATES
If we replace the finite differences in the formulas of Table 7.7:tl by their values in terms of the ordinates, we obtain the formulas of Table 7.8:tl. We have tabulated there the range of integration and the max-degrees of the polynomials for which the formulas are exact as well as the multipliers of h and the coefficients of the ordinates. Thus, if y = f(x), the tenth formula states
f
"'B
3h Y dx = 80 (9yo
+ 34Yl + 24Y2 + 14Ya -
Y4)·
"0
The right-hand member is, of course, only an approximation to the integral unless y is a polynomial of max-degree 4. Formulas 5, 14, 23, 30, 36, and 13,22,29, 35 of Table 7.8:tl are known as the Newton-Cotes formulas; the first group consists of the closed-type formulas, so-called because the range of integration coincides with the range of the ordinates involved; the second group consists of the open-type formulas, so-called because the range of integration is greater than the range of the ordinates involved. Several of these formulas have special names; formula 0 is known as the trapezoidal rule, formula 5 is Simpsons's one-third rule, formula 9 is Simpsons's three-eights rule. Some of these formulas can be simplified with little sacrifice in the margin of error or in the number of ordinates involved. Thus, if y = f(x) is a polynomial of max-degree 5, .1 6yo = Yo - 6Yl
+ 15Y2 -
20ya + 15Y4 - 6y5
+ Y6 = o.
Multiply this expression by 3/10 and add to the right-hand member of formula 22 of Table 7.8:tl ; we obtain a simpler formula exact for polynomials of max-degree 5, (7.8:8)
known as Weddle's formula. A formula of Table 7.8:tl can be combined with itself or with other formulas of the table to yield formulas for integration over longer intervals. For example, since
f "'2m Y dx = f"'2 Y dx + f"" :1'0
%0
Y dx
+ ... + f"'·m
%2
Y dx,
a"2m-1
and since, by formula 5 (Simpson's rule),
f
"'~/ %:U-2
h
Y dx = "3 (Y2/-1
+ 4Y2i-l + Y2i),
i
=
1,2, ... , m,
.... .... ...
TABLE 7.8:tl VALUES OF COEFFICIENTS FOR NUMERICAL INTEGRATION
ft
(f)x dx
=
Kh
=
Kh
Zo
I'"O
f(x) dx
z_k
Exact for Fonnula polynomials no. of max-degree
0
K
~ Ct.iYi '-0
~ Ct.iY-i 1-0
2
3
4
5
6
7
8
c
I
:I m
2
2 2
3
3
4
4
5
12 I 24
720
10 :""'I Z
-
0
9
'" n >
5
8
-I
9
19
-5
251
646
-264
106
-19
475
1427
-798
482
-173
r
Q
I
I
.." .."
m m
'"
Z
-I
;; -I
- - - - -_._----5
2,3
6
4
1440 I 3
0
27
Z
._--------
2
--------
>
Z 0
4
Z
7
5
90 I 90
2
29
2
28
124 129
24
4
14
-6
-I
-I
m
Cl
'"-I> 0 Z
'oj
8
2
9
3
10
4
11
5
12
6
13
3
14
4,5
15
6
16
3
17
4
18
5
19
6
20
7
3 4 3 8 3 80 3 160 2240 4 3 2 45 2 945 5 24 5 144 5 288 5 12096 5 24192
0
3
CD
3
z
c 3
3
3
~
m
3
9
34
24
14
-1
3
17
73
38
38
-7
3
685
3240
1161
2176
-729
4
0
2
'"n> ,...
Z
-I m
C'I
216
-29
'"~
(5
z
-1
Z
2
-I m
4
7
32
12
32
7
4
143
696
192
752
87
'"
~
en
0
24
-4
.."
0
'"cZ
5
-11
55
-65
45
5
19
-10
120
-70
85
51
19
75
50
50
75
19
51
743
3480
1275
3200
2325
1128
-55
5\
1431
7345
1395
8325
2725
3411
-495
~
m en
.... 'oj
VI
..... ~
TABLE 7.8:tl (continued) VALUES OF COEFFICIENTS FOR NUMERICAL INTEGRATION
IZkj(X) dx
=
Kh ~ Ck ••Y. i-o-
2'0
I'"" j(x) dx
=
Kh ~ Ck .•Y_i
X_.t
Exact for Formula polynomials no. of max-degree 21
4
22
5
23
6,7
24
5
25
6
26
7
27
8
i-O
......
0
K
2
3
4
5
6
7
8
9
10
z
c
~
m
3 IO 3 10 1 140 7 1440 7 8640 7 17280 7 518400
'" n > 2
6
11
-44
96
-84
41
6
0
11
-14
26
-14
II
6
41
216
27
272
27
216
7
-611
4277
-9618
12782
-8603
3213
7
751
-840
8547
-11648
14637
-7224
4417
7
751
3577
1323
2989
2989
1323
3577
751
21361 116662
6958
155134
7840
105154
74578
31882
7
r-
"T1 "T1
m m
41
'"Z
55
-I
~
(5
z z> 0
Z -I m
C)
-1169
'"> -I
(5
z
.....
28
6
29
7
30
8,9
31
7
32
8
33
9
34
10
35 36
9 10,11
8 945 9 945 4 14175 9 4480 9 44800 9 89600 9 1971200 5 4536
8
460 -2760
8706
-13904
13641
-7464
a. z c
2266
~
m
8
0
460
-954
2196
-2459
2196
-954
460
8
989
5888
-928
10496
-4540
10496
-928
5888
105039 -126801
98361
-45069
11493
""n
.-)-
Z
989
-I m
Cl
9 -1787
16083 - 52839
""-I )-
(5
9
2857 -4986
51966 -110322
182880 -177102
129666 - 50886
z
20727
Z 9
2857
15741
1080
19344
5778
19344
1080
15741
781056 -119382
335160
229527
5778
-I m
2857
"" ~
III
9
60259 372252 -93015
736968 -417834
88804 -2595
0
.."
0
10
29:376 10
0
4045 -11690
33340
-55070
67822
-55070
33340 -11690
""0
4045
Z
16067 106300 -48525
272400 - 260550
427368 -260550
272400 -48525 106300
16067
)-
-I m
III
.... :::I
278
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
we obtain, by adding up the m integrals for i
= I, 2, ... , m,
(7.8:9)
f
"1lm
Y dx
h
= "3 (Yo + 4Yl + 2Y2 + 4Y3 + ... + 2Y2m-2 + 4Y2m-l + Y2"')·
"0
Also, since
we have
which, if it is desirable to have small coefficients, can be rewritten as
The two formulas just derived are exact for polynomials of max-degree 3. EXERCISE 7.8 1. Do by the methods ofthis section examples 1-3 of Exercise 7.7.
2. Choose appropriate values for x o , h, and an appropriate formula to evaluate the following integrals, correct to the indicated number of decimal places.
a.I:~dx; b.
I: VI + I
HU
c. d.
e. f.
I.
I: I: I:
for u
Xl
sin -
1-u
2xa dx,
2 dp
dx,
4
cos Xl dx, riel dt,
for x =
e lill dt,
for x
tan Xl •/
dx,
f"ovl+x·
=
2 dp
1,2,3,4;
= 0, i, i, t, 1;
2 dp
i, I, !, 2;
3 dp
J-, 2, f' 3, 4;
3 dp
for u
for u =
=
t, I, 2, 3, 4;
for u
= 0.5,0.7, I,
3 dp 1.2, 1.24;
3 dp
7.9. MAGNITUDE OF THE ERROR IN NUMERICAL INTEGRATION
279
3. Derive by the method of undetermined coefficients or otherwise a formula of the indicated type, exact for polynomials of the stated max-degrees.
n
=
3.
n = 3.
n
= 2.
n = 6.
7.9. Magnitude of the Error in Numerical Integration. In this section we consider the magnitude of the error when a definite integral is approximated by a formula of the preceding sections. The discussion will parallel the discussion given in Section 5 of this chapter. As there, let
(7.9:1) where Pn(x) is the polynomial through the points (xo , Yo), ... , (xu, Yn), h = xHI - x" t = (x - xo)Jh, and X is a value of x between the largest and smallest of Xo , Xl' .•• , Xn , x. Hence
(7.9:2)
t ) dx, f ba f(x) dx = fba Pn(x) dx + hn+1 fba pn+1I(X) (n+1
t f(x) dx by t Pn(x) dx is
and the error committed in approximating
(7.9:3)
E(x)
= fb f(x) dx - fb Pn(x) dx = a
a
hn+1
a
a
fb pn+1I(X) ( a
t ) dx. n+1
If we again assume as in Section 5 that pn+lI(X) is constant within the interval of integration, and if we substitute h dt for its equal dx, then
(7.9:4)
E(x)
=
hn+~Cn+1I(X)
In particular, if we put a
(7.9:5)
=
Xo
f
and b
Cb-ZO' III
t
(
)
+1
dt.
Ca-zol/ll
n
=
the error becomes
Xk,
280
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
which in view of 7.5:5 can be rewritten as
(7.9:6) The integral on the right has been discussed on several previous occasions. Its value is the coefficient of LlnHyo in the row for Xo - Xk in Table 7.7:tl. The arbitrary condition that pn+l)(x) be constant within the interval of integration can be removed by the following artifice. Let
(7.9:7) be a typical formula for which we wish to estimate the error. If f f(x) dx = F(x) so that F'(x), then
But
hence
(7.9:8) The error inherent in the last expression can be determined by the long method of Section 7.5, and therefore, since 7.9:7 and 7.9:8 are equivalent statements, the error in the former can be determined. For example, Simpson's formula is
which is equivalent to F(X2) - F(xo)
=
i
(F'(x o) + 4F'(x1 )
+ F'(x2»·
Since Simpson's formula is exact if f(x) is a polynomial of max-degree 3, the last statement is exact if F(x) is a polynomial of max-degree 4. If
281
7.10. GAUSS' FORMULAS; ORTHOGONAL POLYNOMIALS
we then put n = 4 in 7.5:10 and proceed as in that section, we find the error in the last expression to be E(x)
=
f" R(s)F(5)(s) ds, "0
where R(s)
=
(X2 - S)4 24
U(s I Xo , x2) -
2
3
9 h(Xl - s) U(s I Xo , Xl)
- ;8 (X2 -
S)3 U(s I Xo , x 2)·
It is not difficult to prove that R(s) :::;;; 0 for all values of s, hence E(x)
= F(SI(X)
f" R(s) ds. "0
We find by direct integration
f"'. R(s) ds = -
hS . 90
"'0
Therefore E(x)
= -
hSF(SI(X) 90
= -
h5j'(41(X) 90
.
The result is the same as the one obtained by assuming .f'4I(x) constant in the interval from Xo to X 2 • EXERCISE 7.9
1. Determine the errors in the formulas of Table 7.8:tl. 2. Determine the errors in the formulas of Exercise 7.8. example 3.
7.10. Gauss' Formulas; Orthogonal Polynomials. In Section 8 of this chapter we developed a number of formulas of the type
for the approximation of the definite integral, where h = Xi+l - Xi . In general, these formulas yielded exact values whenever f(x) was a polynomial of max-degree n. It is reasonable to expect that if the restric-
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
282
tion that the x's be equally spaced be removed, it might be possible to obtain a formula of the type (7.10: I)
r
f(x) dx
a
=
aof(xo)
+ ad(xI) + ... + aJ(xn),
where the a/s are constants and the x/s are abscissas to be determined, which is exact for polynomials of higher max-degrees. Indeed, it is reasonable to expect that since 2n + 2 constants, a o , a l , ••• , an , Xo , Xl , ... , xn , are at our disposal, it may be possible to obtain a formula which is exact for polynomials of max-degree 2n + 1. We consider this problem in this section. It turns out that it is convenient to make the transformation x' = (x - a)/(b - a), so that 7.10:1 becomes (7.10:2)
(f(X) dx
=
Aof(xo) + Ad(xl )
+ ... + AJ(xn),
where we have dropped the primes on the x's for the sake of simplicity and where Ai = ai/(b - a). A formula of this type is known as a Gauss formula for numerical integration. We use the method of undetermined coefficients and endeavor to determine the 2n + 2 constants so that 7.10:2 is exact for each of the polynomials y
(7.10:3)
=
I, y
=
x, y
=
X2, "',y
=
x2n+1.
If we succeed in finding a formula which is exact for these polynomials, it will follow at once from the linearity properties of the integral that 1. it will be exact for any polynomial of max-degree 2n If we use Eqs. 7.10:3 in turn in 7.10:2, we obtain the following system of equations to be solved for the A's and the x's:
+
Ao AoXo
+ Al + A2 + .. , + An = I + A1x1 + A 2x 2 + ... + Anxn = i _.1.
(7.10:4)
-3
A x2n+1 o
0
+ A I x2nI +1 + A :"-2 _x2n+1 + '" + A x2n+1 = n 11.
2n
I
+2
Since these equations are linear in the A's but not in the x's, their solution presents a far from simple problem. To solve this problem we turn to some apparently foreign but nevertheless closely related investigations.
7.10. GAUSS' FORMULAS; ORTHOGONAL POLYNOMIALS
283
First of all, we solve the system of linear equations
!+ Ul
+
U2
!+
+
U2
1
2
2
Ul
3
3 4
Un 0 + ... +--= I+n
+"'+~=O 2+n
(7.10:5)
!+~+~+ .. ·+~-o n+1 n+2 n+n- ,
n
for U 1 , U 2 , ... , Un' If we add the fractions on the left-hand side of the kth equation, we get
rk + n]
[k
+ n]
[k
+ n]
In + 1 n + U 1 n + 1 n-l + ... + Un n + 1 0 [k + n] n+1
in the notation of Section 7.1. In virtue of Eqs. 7.10:5, the left-hand side of this identity must vanish for k = I, 2, ... , n; since the denominator on the right is positive for k = I, 2, ... , n, the numerator must vanish for each of these values. But the numerator is a polynomial in k if max-degree n, hence (7.10:6)
[k + n] n + 1n
+ U1 [k + n] + ... + Un n + 1 n-l
[k + n] n + 10
=
M(k _ I)(k _
2) ... (k -
n),
where M is a constant. Put k = 0; every term on the left-hand side drops out except the first which becomes n!; the right-hand side becomes (--I)nn!M. Hence M = (-I)n. Now put k = -i, i = I, 2, ... , n. The equality 7.10:6 reduces to Ui
[n - i]
n+l
n- i
=
(-I)n(-i _ I)(-i - 2)'" (-i - n)
284
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
or u;(-I)ii!(n - i)!
= (n
+ i)(n + i-I) ... (i + 1).
Hence
.=
u,
(-I)i (n
+ i)(n + i-I)'"
(i
i!(n _ i)!
+ 1)
or i=I,2,"·,n.
(7.10:7)
Secondly, we consider the polynomial of degree n defined by
or (7.10:8)
This polynomial is known as the Legendre polynomial of order n (but see the remark a little further on) and has some important properties which we state and prove below. We also list in Table 7.1O:tl the first ten Legendre polynomials for ready reference. TABLE 7.10:tl LEGENDRE Pn(X)
=
POLYNOMIALS
±
(-1)j
j-O
I: x
X2
XS
x·
Pn(X) dx
X·
Pn(X)
C) r ; i)
xj
n ;;;. 1
= 0, X6
X7
XS
x·
x lO
Po
PI P2
Ps
p. p. P6 P7 Ps
p. P IO
-2 -6 6 -12 -20 30 -20 -140 70 90 -30 210 -560 -252 630 -42 420 -1680 -2772 3150 924 -3432 -56 756 -4200 11550 -16632 12012 -72 1260 -9240 34650 -72072 -51480 12870 84084 -90 1980 -18480 90090 -252252 420420 -411840 218790 -48620 -110 2970 -34320 210210 -756756 1681680 -2333760 1969110 -923780 18475 6
7.10. GAUSS' FORMULAS; ORTHOGONAL POLYNOMIALS
Property a. If p(x) is any polynomial of max-degree n (7.10:9)
( p(x) Pn(x) dx
285
I, then
= O.
In particular, we have; Property b. (7.10:10)
r o
Pn(x) P",(x)
if n =F m.
=0
Property c. (7.10:11) Property d. The roots of (7.'10:12)
are all real, distinct, and between 0 and I. If two functions f(x) and g(x) have the property indicated in 7.10:9, or more generally, if the two functions are so related that
r
f(x) g(x) dx
a
=
0,
the functions f(x) and g(x) are said to be orthogonal on the interval from a to h. Any two distinct Legendre polynomials are then orthogonal on the interval from 0 to 1. It should be remarked, however, that Legendre polynomials are usually so defined that they are orthogonal on the interval from -I to I (it is convenient for our purposes to define them as we did). A suitable linear transformation can be used to send one set of polynomials into the other. Orthogonal polynomials are of great importance in mathematics and its applications and there is an extensive literature concerning them. We now prove that the Legendre polynomials have the four properties stated above. Consider first k
= 0, I, "', n - l.
286
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
We have
=
± +,+ i=O
k
(-.I)i
(~)
I,
(n ~, i) .
But the last sum is precisely the left-hand member of the (k equation of 7.10:5 and is therefore equal to zero. Hence k
(7.10:13)
= 0, I, ... , n -
+ l)st
l.
Property a follows at once since f[Cjl(X) + C2.Mx)] dx = C1fjl(X) dx + C2fj2(X) dx, where C 1 and C 2 are arbitrary constants. Property b is an immediate corollary of the first property. To prove property c, we note that fl P,.2(X) dx reduces to o
which equals ( -I)" (2n) ~ ( -I )i . (~) (n ~ n ~n+I+" ,
i) .
Put k = n + I in the identity immediately following the set of equations 7.10:5 and use 7.10:6, 7.10:7, and 7.1:19; we obtain ~
~n
(-I)i (n) (n + i) = + I +iii
(-I)"(n!)2 (2n I)! .
+
Hence
= _1_ I P"x2( ) dx = (-I)" (2n)n (-I)"(n!)2 (2n + I)! 2n + I ' l
o
as we wished to prove. We now prove the last property. It follows from the definition of the Legendre polynomial, 7.10:8, that Pn(O) = 1, hence P,,(x) is certainly
287
7.10. GAUSS' FORMULAS; ORTHOGONAL POLYNOMIALS
positive in some portion of the interval from 0 to 1. On the other hand, if we put p(X) = 1 in 7.10:9, we get
s:
P,,(x) dx = 0,
and if we recall that the definite integral can be interpreted as an area above the x-axis minus an area below the x-axis, we learn that P",(x) must be negative in some portion of the interval. It follows that the equation P",(x) = 0 must have at least one root between 0 and 1 of odd multiplicity. Let r1 , r2 , ... , rg be the distinct (real) roots of P",(x) = 0 that are between 0 and 1 and are of odd multiplicity. Then rex) = (x - r1 )(x - r2 ) ... (x - rg) is a polynomial of degree g ~ n. Hence, by property a,
f:
rex) P,,(x) dx
= 0,
unless g = n. But the polynomial r(x)p",(x) is not identically zero and does not change sign between 0 and 1 so that fl r(x)p",(x) dx cannot be equal to zero. It follows that g = n, which rri'eans that the roots of P",(x) = 0 are distinct and between 0 and 1 as we wished to prove. Incidentally, we have already seen that P ",(0) = 1 and it can be shown that P"'( 1) = (-1)"', hence neither 0 nor 1 are roots. We are now ready to solve Eqs. 7.10:4. Multiply the first equation by ("'~1)("'~1), the second by _("'11)("'12), the third by ("'~1)("'~3), and so on to the (n + 2)nd equation which is multiplied by (-1 )"'+l(:me::12 ); then add the n + 2 results. We obtain
= ~ (-I)i _.1_ (n ~ I) i=O
'
+I,
(n + ~ + i) ,
+
where P"+l(x) is the Legendre polynomial of order n 1. Now multiply the second equation by ("'~1)("'~1), the third by -("'11)("'12), the fourth 3)rd by (-I)"'+l(:m(~:{) and add the by ("'~1)("'~3), ... , the (n results. We obtain
+
AoXoP,,+1(xo) + A1x1Pn+l(X1) +
... + A"x"P"+1(x,,) =
s:
XP"+1(x) dx.
288
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
+
We repeat this process for each set of n 2 consecutive equations of the system 7.10:4. We thus obtain the system of n 1 homogeneous equations:
(7.10:14)
A"p"+1(xo) + A 1P"+1(Xl) AoX"p"+1(xo) + A 1x1P,,+1(Xl) AoXo2P"+1(xo) + A 1x 12P"+1(X1 )
+
+ ... + A"P"+1(x,,) = 0 + ... + A"x"P"+1(x,,) = 0 + ... + A"X,,2P"+1(X,,) = 0
The right-hand members of these equations all vanish in view of the orthogonal property of the Legendre polynomials. Equations 7.10:14 will clearly be satisfied no matter what the A's are if we choose the roots of Pn+l(x) = 0 for X O ' Xl , •.• , X" • If we so choose 1 equations of the x's and then substitute their values in the first n 7.10:4, we obtain a set of n + 1 equations linear in the A's. The determinant of the coefficients (of the A's) is the Cauchy-Vandermonde determinant previously discussed (page 72) which does not vanish since the x's are distinct. Consequently, the A's can be uniquely determined. It remains to prove that the A's and x's so determined will satisfy the remaining equations of 7.10:4. But this prooffollows readily enough. We have already seen that the first equation of 7.10:14 was obtained by multiplying each of the first n + 2 equations of 7.10:4 by certain constants and adding the results. We note, first, that the constant multiplying the last equation is (-1 )n+l(~+'i2) which is not zero and, second, that since the x/s were chosen as the roots of Pn+l(x) = 0, the coefficient of each Ai in 7.10:14 is identically equal to zero. These remarks imply that the (n + 2)nd equation of 7.10:4 is linearly dependent on the first n 1 equations and hence any solution of the first n I equations is necessarily a solution of the (n 2)nd. Precisely the same line of reasoning applies to the remaining equations of 7.10:4. That is, the A's and x's that were found to satisfy the first n 1 equations of 7.10:4 will satisfy all the equations of the system. Table 7 .1O:t2 gives the values of the roots of the Legendre polynomials and the corresponding A's (the Gaussian coefficients) up to n = 10, and two illustrative examples are worked out below. Note that since most of the x's are irrational, the greater precision afforded by the use of Gauss's formulas may be more than offset by the greater difficulty in computing the corresponding f(x),s, unless a computing machine is used.
+
+
+
+
+
7.10. GAUSS' FORMULAS; ORTHOGONAL POLYNOMIALS
289
TABLE 7.10:t2
n
2
3
Degree of polynomial for which Eq. 7.10:2 is exact
3
5
Roots of Legendre polynomials
x. = 0;5
A.
= I
x. = 0.2113248654 0.78867 51346
A.
=
Xl =
Al =
x. = 0.1127016654 0.5 X. = 0.8872983346
Al =
Xl =
4
5
7
9
X.
II
A.
=
Al
= 0.3260725774
XI
AI =
Xa
0.0694318442 0.33000 94782 = 0.6699905218 = 0.9305681558
X.
=
0.04691 00770 0.23076 53449 XI = 0.5 Xa = 0.7692346551 x, = 0.95308 99230
X.
=
X.
=
Xa =
x, = Xi =
13
X.
0.1184634425 0.23931 43352 AI = 0.28444 44444 Aa = 0.2393143352 A, = 0.1184634425 =
Al =
A.
=
Al = AI = Aa =
A,
=
Ai =
A.
0.08566 22462 0.1803807865 0.23395 69673 0.23395 69673 0.1803807865 0.08566 22462
= = =
=
A.
=
0.05061 42681
Xl =
Al
x, = X. = x, =
X.
0.02544 60438 0.1292344072 0.29707 74243 0.5 0.70292 25757 0.8707655928 0.97455 39562
A.
0.3260725774 0.1739274226
A, A. A,
XI = Xa =
15
0.0337652429 0.1693953068 0.3806904070 0.6193095930 0.8306046932 0.96623 47571
Aa =
0.17392 74226
0.0647424831 0.1398526957 0.19091 50253 0.2089795918 0.1909150253 0.13985 26957 0.0647424831
=
Xl =
8
AI
0.2777777778 (5/18) 0.44444 44444 (4/9) = 0.27777 77778 (5/18) =
=
Xl =
7
A.
0.5 (1/2) 0.5 (1/2)
Xl =
Xl =
6
Gaussian coefficients
0.0198550718 0.1016667613 XI = 0.23723 37950 Xa = 0.40828 26788 x, = 0.59171 73212 Xi = 0.76276 62050 x. = 0.8983332387 X7 = 0.9801449282
=
Al =
A.
=
Aa =
AI
= 0.1111905172 = 0.1568533229
Aa =
A, A. A. A7
= = = =
0.1813418917 0.1813418917 0.1568533229 0.1111905172 0.0506142681
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
290
TABLE 7.IO:t2 (continued)
Degree of polynomial for which Eq. 7.10:2 is exact
n 9
10
Roots of Legendre polynomials
= = = = = Xi = x, = X7 = X. = Xo Xl X8 X. X.
17
0.01591 98802 0.0819844463 0.19331 42836 0.33787 32883 0.5 0.6621267117 0.8066857164 0.91801 55537 0.9840801198
Xo = 0.01304 67357 Xl = 0.0674683167 X. = 0.1602952159 X. = 0.28330 23029 X. = 0.42556 28305 Xi = 0.57443 71695 x, = 0.7166976971 X7 = 0.8397047841 X. = 0.93253 16833 x. = 0.9869532643
19
Gaussian coefficients
A, A7 A.
= = = = = = = = =
Ao A1
= 0.03333 56722 = 0.07472 56746
Ao A1 As
A. A. Ai
0.0406371942 0.09032 40803 0.1303053482 0.15617 35385 0.16511 96775 0.1561735385 0.1303053482 0.0903240803 0.0406371942
As = 0.1095431813
A. A. AI
A, A7 A. A,
= = = = = = =
0.1346333597 0.1477621124 0.1477621124 0.1346333597 0.1095431813 0.07472 56746 0.03333 56722
The Legendre polynomials can be used to extend some of the results of Section 3.1. We were then looking for a polynomial Pn(x) = ao + a1x + a2x 2 + ... + anxn which would minimize the integral Is
=
t
[f(x) - Pn(x)]2 dx,
II
where f(x) was a given function of x. It is more convenient to express Pn(x) not as a polynomial in x but as a polynomial of the form (7.10:15)
where the b's are constants and the P's are the Legendre polynomials. (It is a well-known theorem of algebra that any polynomial written in powers of x can be written in the form 7.10: 15; as a matter of fact, the theorem referred to is true if in the form 7.10:15 Pi(x) is any polynomial of degree i. The converse of this theorem is obviously true.) We drop the subscript S on Is and again suppose that a suitable transformation has been made so that the limits of integration become 0 and 1.
7.10. GAUSS' FORMULAS; ORTHOGONAL POLYNOMIALS
Our problem is then to determine the coefficients bo , bl 7.10: 15 so that
r
291 ,
bn in
(7.10:16) 1= [f(x) - Pn(x)]2 dx o IS a minimum. Necessary conditions for a minimum to exist are that i
(7.10:17)
=
0, 1, ... , n,
assuming that the partial derivatives are continuous. We have -2
Ibi =
= =
-2
-2
r o
Pi(x) [f(x) - Pn(x)] dx
[t
o
[f:
Pi(x)f(x) dx -
t
Pi(x)Pn(x) dX]
0
Pi(x)f(x) dx -
2i
~
1] .
The last reduction follows from properties band c of the Legendre polynomials. Hence the condition 7.10: 17 will hold if (7.10:18)
bi = (2i
+
1)
r
Pi(x)f(x) dx,
o
Furthermore, 2
01 = ob.Ob. ,
,
Ib;bj
=
! 2i
i = 0, 1, ... , n.
if i =1= j,
20
+1
if i =j.
It follows from theorems of advanced calculus that the values of the b/s given by 7.10:18 will make I given by 7.10.16 a minimum and not a maximum. The desired polynomial 7.10: 15 is thus given by (7.10:19)
Pn(x)
=
i
i-O
(2i
+
1) Pi(x)
t
Pi(x)f(x) dx.
0
We illustrate an application of the preceding discussion by reworking example 2 of Section 3.1, page 69. We make the transformation X = X/TT. The function f(x) then becomes sin TT X and we have
292
7. NUMERICAL DIFFERENTIATION AND INTEGRATION
We evaluate these integrals and find ho The required polynomial is then
~+ TT
= 2/TT, hi = 0, h2 = IO/TT -120/TT3 •
(10 _ 120) (1 _
6X
1TS
1T
+ 6X2)
which becomes after simplification and a return to the original variable x,
the same result as the one previously found. We do two additional examples as illustrations of the direct use of formula 7.10:2 and Table 7.IO:t2. EXAMPLE 2. Find the value of formula 7.10:2 for three points. We find (Table 7.IO:t2) X
o = 0.11270,
A o = 5/18,
Xl
flo sin x dx (exactly),
= 0.5
Al = 4/9,
by use of the Gaussian
X2
A2
= 0.88730, = 5/18.
Hence the integral is approximately equal to 158 sin 0.11270 + ; sin 0.5
+ 158 sin 0.88730 = 0.45970.
The answer is correct to five significant figures and can be readily checked by direct integration. EXAMPLE 3. Find the value of f~l eX dx by use of the Gaussian formula for four points. In order to use Table 7.IO:t2, we first make the transformation Z = (x + 1)/3 so that the required integral becomes 3fl e3Z - 1 dz. From o the table, Zo = 0.06943, A o = 0.17393,
= 0.33001, Z2 = 0.66999, Zs = 0.93057,
Zl
= 0.32607, A2 = 0.32607, As = 0.17393. Al
Consequently, the required integral is approximately equal to 3(0.17393e"·06943 + 0.32607eo.33001
+ 0.32607e"·66999 + 0.17393e"·93067) = 7.0212.
7.10. GAUSS' FORMULAS; ORTHOGONAL POLYNOMIALS
293
The answer is correct as far as it is written and it too can be readily checked by direct integration. EXERCISE 7.10
1. Rework Exercise 7.8. example 3. by the methods of this section making suitable choices for the number of points. 2. Evaluate J~3 ~ I + lOx' dx by Gauss' method using 6 points in the interval [ - 3. 9]; by using 3 points in each of the intervals [ - 3. 3]. [3. 9]. 3. Use the Legendre polynomials to find polynomials of the indicated max-degrees that will minimize the integrals
.. I: [Vx -
p,(X)]8 dx.
b.
(1
c.
[e" - p,(x)]' dx.
I:
[cos x - P.(x)]' dx.
4. If u, is given by 7.10:7. prove
~_u_/_ -t:k+i
(n: I) . k (k+n)
= (-I)"
n+1 5. If F(x) = (x - x o) (x - Xl) ••. (x - x ..). where the x/s are the zeros of the Legendre polynomial Pn+1(x). prove that the A's satisfying 7.10:4 are given by I A, = - - F'(Xi)
Xi
II 0
F(x) ----dx
x - x,
•
i
=
O. I ..... n.
6. If xo. Xl ..... xn are the zeros of the Legendre polynomial P n+1(x). prove that + x .._/ = 1.
7. If Ao. AI ..... An are the coefficients in 7.10:2 determined as in the text. prove Ai = A .._,.
Chapter B
The Numerical Solution of Ordinary Differential Equations
8.1. Statement of the Problem. It is well known that the mathematical formulation of a natural phenomenon frequently leads to an ordinary differential equation, that is, to an equation whose general form is (8.1:1)
F(x,y;y',y", "',y(n)
= 0,
where x and y are the variables and y', y", ... , y(n) are, respectively, the first, second, ... , nth derivatives of y with respect to x. The formulation of a natural law involving three or more causally related entities frequently leads to a partial differential equation, that is, to an equation involving the dependent variable y, two or more independent variables Xl , X z , •.• , and one or more of the partial derivatives of y with respect to one or several of the independent variables. We discuss only ordinary differential equations in this text. It is often more convenient and sometimes highly desirable to write the law expressed by 8.1: 1 in the form (8.1:2)
f(x,y)
= 0;
a form in which only the variables x and y and none of the derivatives are involved. This equation is said to be a solution of the ordinary differential equation 8.1: 1 if 8.1: 1 reduces to an identity when y', y", ... , y(n) are replaced by their values derived from 8.1 :2. This implies that if (xo , Yo) is any point whose coordinates satisfy 8.1:2 and if Yo', y~', ... , y~n) are the values of the successive derivatives evaluated (from 8.1:2) at this point, then xo , Yo , Yo', ... , y~n) will satisfy Eq. 8.1:1. A differential equation usually has infinitely many solutions; indeed, if the differential equation contains a derivative of the nth order but none of higher order, a solution will normally contain n arbitrary constants or parameters, say Cl , Cz , ... , Cn . A solution of the differential equation is usually then written in the more suggestive manner (8.1:3)
f(x,y;
Cl , Cz, ••• ,
294
cn)
= O.
295
8.1. STATEMENT OF THE PROBLEM
It is customary to call a solution in this form a general solution; a general solution of a differential equation thus represents not a single curve but an n-fold infinity of curves. If particular values are assigned to the parameters c1 , C2 , ••• , Cn , the resulting solution is called a particular solution. Thus, if C1 and C 2 are arbitrary constants, (8.1:4)
is a general solution of (8.1:5)
(x
+ l)y" + xy' -
y = 0,
and (8.1:6)
y = x,
y
= 2x - 3e-"',
are particular solutions. If the general solution 8.1:3 of a differential equation involves n arbitrary constants and particular values are assigned to m of them, where 0 < m < n, or if m parameters are replaced by combinations of the others, the resulting equation represents a particular (n - m)-fold family of solutions of the general solution. Thus, (8.1:7)
y
= 2x + c2e-"',
are particular one-parameter families of the general solution 8.1 :4. Particular solutions or particular families of solutions are usually determined by the imposition of so-called initial or boundary conditions. For example, if the condition is imposed that the solution have slope 0 when x = 0, the one-parameter family y = c1(x + e-X ) is determined in the above illustration. If the additional condition is imposed that x = 0, y = 2 satisfy the solution, the particular solution y = 2(x + e-X ) is determined. The methods of obtaining solutions, either general or particular, of differential equations are treated in the texts on that subject. Unfortunately, it is quickly apparent that the standard methods can be used to solve only a relatively small number of types of differential equations. As a consequence, if a given differential equation does not belong to one of these solvable types, the scientific worker must be satisfied with an approximate solution. These approximate solutions can be obtained in two ways. In the first place, we can modify the differential equation in such a manner that the new form is amenable to solution. For example, the equation (8.1:8)
d 28
.
I dt 2 = -g sm 8,
296
8. NUMERICAL SOLUTION ':>F ORDINARY DIFFERENTIAL EQUATIONS
where I and g are constants, is not easy to solve as it stands; if, however, the angle 8 is small, 8 and sin 8 are almost numerically equal and hence it seems reasonable to suppose that if this equation is replaced by tJ28 I dt Z
(8.1:9)
=
-g8,
a solution of the latter would not differ materially from a solution of the first. This equation has a general solution (8.1: 10)
8
=
C1
sin
~f t + Cz cos ~f t
which is readily obtained by standard procedures. (Incidentally, it folCows at once from this solution that the time of the complete swing of the pendulum is given by the familiar formula T = 2TTvl/g. This formula, of course, is subject to the error due to the replacement of 8.1:8 by 8.1:9.) This method of obtaining a solution is frequently employed but it is open to a most obvious objection. Even though we replace a factor or term in the given differential equation by another almost numerically equal, how can we be assured that the error in the solution will be small? Undoubtedly, one ought to know the magnitude of the error in the solution due to the modification of the differential equation. But this is, as a rule, not an easy matter to determine. Ordinarily, if a solution is obtained in this manner and if the results agree with experimental data, the solution is kept, right or wrong. It is, indeed, a useful and powerful method, but we shall not discuss it further for the subject properly belongs in the study of differential equations. The second general method of obtaining an approximate solution employs the given differential equation without modification. This time, we do not attempt to approximate a general solution (although some procedures do yield it), but we are content with approximating a particular solution. Ordinarily, the general solution is particularized in advance by specifying certain initial or boundary conditions. The examples will illustrate various methods of doing this. The second general method is itself subdivided into two submethods. In the first of these we seek a function (8.1:11)
a(x,y)
=0
which is an approximation to the particular solution; in the second, we desire not a function at all but merely the numerical values of (8.1:12)
Yl' Y2' Y3'···'
297
8.1. STATEMENT OF THE PROBLEM
corresponding to given numerical values (8.1:13)
such that the pairs (8.1:14)
satisfy (approximately) a preassigned particular solution. A solution of this type will be called a pointwise solution and will be referred to as such henceforth. The remainder of this chapter is devoted to the development and discussion of these approximation methods as they apply to a limited number of simple cases. Before we plunge into these arithmetic approximation methods, it might be well to consider briefly a graphic method which, although rough, is sometimes quite helpful and informative for differential equations of the form dy dx
(8.1:15)
= F(x,y).
If very good approximations are not necessary, the graph is frequently adequate and has the advantage of speed; if great precision is necessary, the graph can be used advantageously in conjunction with the later methods to throw light on the nature or behavior of the solution. The graphic methods utilizes the so-called lineal-element diagram. Let h be a small positive quantity; the points (8.1:16)
(ih,jh),
i,j
=
0,
± 1, ± 2, ± 3, "',
form a square lattice that covers the plane. The differential equation 8.1: 15 determines a slope at each lattice point for which F( ih, jh) exists. At each lattice point a small line segment, called a lineal element, of length approximately h and centered on the lattice point, is drawn with the determined slope. The totality of lineal elements is the lineal-element diagram. A curve whose equation is a solution of 8.1: 15 is tangent to the lineal elements of the lattice points whose coordinates satisfy the equation. Hence, if we start at any point and follow the slope lines, we can sketch a curve whose equation is a particular solution of the differential equation 8.1: 15. Figure 8.1:fl shows that portion of a lineal-element diagram within a 4 by 4 square centered on the origin with h = 0.2 determined by the
298
8. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
differential equation y' = x + y2. The particular curves passing through (0, I), (0, 0), (0, -I) are shown. The method is rough; but with care and experience, the graph of a solution can be drawn which, although inadequate by itself, does throw much light on the behavior of the required solution. y
""//~//IIII
_/
/////11
'"
/////111 ///1/1111 ///1111111 ///1111111 I I I I I I I , I I
11111111" '/1/111111 " I I I I I " I
FIG. 8.1 :fl.
The number of lineal elements that need be drawn can be greatly reduced if we want one or just a few particular solutions. For example, suppose we wanted only that particular solution of y' = x + y2 which passes through the origin. We calculate y" from the differential equation and find y" = I + 2xy + 2y 3. At the origin, y' = 0, y" = I. Hence the curve representing the sought solution is tangent to the x-axis at the origin and is there concave upward. We draw the lineal elements for x = 0.2 andy = 0, 0.1, 0.2; then for x = 0.4 andy = 0.1, 0.2, 0.3; and then sketch the portion of the curve from x = 0 to x = 0.4. With an eye on the part of the curve already drawn, and with an occasional assist from the second derivative, we draw lineal elements for x = 0.6, 0.8 and appropriate values of y. We continue to sketch the curve and draw additional lineal elements until we have as much of the curve as we want.
8.2. PICARD'S METHOD OF SUCCESSIVE APPROXIMATIONS
299
EXERCISE 8.1 1. Draw lineal-element diagrams for each of the differential equations in the neighborhood of the given point and sketch several of the particular solutions . •. y'=3x,
c. y' = e. y'
Xl -
y,
e-Z
= --, yl - 1
(-1,-1).
b.y'=x+y,
(0, 0).
d. y'
=
_x_ , y -1
(0,0). (0, 1).
(0,0).
2. Draw only as many lineal elements as needed to sketch the particular solutions determined by the given points. Where helpful, make use of the second derivative . •. y' = x + e- z ; (0,0), (5,0), (-5,0). b. y' = xy; (-1,0), (0,0), (1,0). c. y' = (sin x)/y; (0, I), (0,0.5), (0,0.1). 3. Superimpose on each of the five lineal-element diagrams of example 1 new linealelement diagrams such that the old and new lineal elements of a lattice point are perpendicular. Sketch, for each of the five parts, several curves determined by the new linealelement diagrams.
8.2. Picard's Method of Successive Approximations. The first method of getting an approximation to a particular solution of a differential equation that we consider is due to Emile Picard. We give it mainly for historic reasons since it is usually cumbersome and difficult of application in practice and is therefore infrequently used for computational purposes. However, its basic feature is the underlying concept in several of the methods to be discussed later. As the name implies, the method is an iterative one and is similar in spirit and application to the procedure described in Section 5.3 for the numerical solution of ordinary equations. Let
(8.2: 1)
7x = F(x,y)
be the differential equation to be solved. If F(x, y) is independent of y, the solution is y = fF(x) dx and the problem is trivial, at least from the point of view of differential equations. If the integral is not easy to compute, we always have recourse to the methods of the preceding chapter on numerical integration. We assume henceforth that y is present in F(x, y). Let the desired solution of the differential equation 8.2: 1 be of the form
(8.2:2)
y =f(x).
The differential equation can then be rewritten as
(8.2:3)
d~~) =
F(x,J(x»,
300
8. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
whence (8.2:4)
I F(x,J(x» dx.
y = f(x) =
This equation, of course, does not solve the problem since the unknown f(x) appears in the integrand j it is merely another form of 8.2: I, a form
which is more vulnerable to our present line of attack. (As an aside, we remark that Eq. 8.2:4 is a particular example of what is known as an integral equation j the study of integral equations is a separate and distinct branch of mathematics.) Rather than solve Eq. 8.2:4 in its generality, we will attempt to find a particular solution. Since the general solution will contain one arbitrary parameter, we are free to impose one condition if we wish to particularize the solution. A usual method of imposing a condition is to require that the curve representing the particular solution pass through a given point (xo , Yo). The condition implies that Yo = f(x o). Now, one simple way of writing this condition into the general equation 8.2:4 is to rewrite the latter as (8.2:5)
y
= Yo +
r
F(x,f(x» dx,
"'0
or (8.2:6)
y
= Yo +
r
F(x,y)dx.
"'0
It should be made quite clear that so far we have done nothing but toss the problem around. We now consider an iterative process which generates a sequence of functions
(8.2:7) which, under conditions to be stated later, will converge to the desired solution 8.2:6. We start with the approximation
and substitute this value for y in the right-hand member of 8.2:6 to obtain Yl = ft(x) = Yo
+
r...
F(x, Yo) dx .
8.2. PICARD'S METHOD OF SUCCESSIVE APPROXIMATIONS
301
Since the integrand is now a function of x only, the integration can be carried out, at least theoretically. We substitute Yl for Y in the righthand member of 8.2:6 to obtain Y2 = !2(X) = Yo
+
r r
F(x, Yl) dx.
"'0
We substitute Y2 for Y in the right-hand member of 8.2:6 to obtain Ya
= !a(x) = Yo
+
F(x, Y2) dx,
"'0
and so on. In general, the (n + I )st approximating function is obtained from the nth by the recursive formula
(8.2:8)
Yn
= !n(x) = Yo +
r
F(x, Yn-l) dx.
"'0
The iterative process yields in this manner a sequence of functions
8.2:7. It can be proved that if, the function F(x, y) is bounded in some suitable region about the point (xo , Yo), that is, if there exists a positive number L such that
IF(.'t,y) I