Professional Documents
Culture Documents
Introductory Methods of Numerical Analysis by S.S. Sastry 5th
Introductory Methods of Numerical Analysis by S.S. Sastry 5th
Introductory Methods of
Numerical Analysis
Fifth Edition
S.S. SASTRY
Formerly, Scientist/ Engineer SF
Vikram Sarabhai Space Centre
Trivandrum
New Delhi-110001
2012
INTRODUCTORY METHODS OF NUMERICAL ANALYSIS, Fifth Edition
S.S. Sastry
© 2012 by PHI Learning Private Limited, New Delhi. All rights reserved. No part
of this book may be reproduced in any form, by mimeograph or any other
means, without permission in writing from the publisher.
ISBN-978-81-203-4592-8
The export rights of this book are vested solely with the publisher.
Preface xiii
3. Interpolation 73125
3.1 Introduction 73
3.2 Errors in Polynomial Interpolation 74
3.3 Finite Differences 75
3.3.1 Forward Differences 75
3.3.2 Backward Differences 77
3.3.3 Central Differences 78
3.3.4 Symbolic Relations and Separation of Symbols 79
3.4 Detection of Errors by Use of Difference Tables 82
3.5 Differences of a Polynomial 83
3.6 Newtons Formulae for Interpolation 84
3.7 Central Difference Interpolation Formulae 90
3.7.1 Gauss Central Difference Formulae 90
3.7.2 Stirlings Formula 94
3.7.3 Bessels Formula 94
3.7.4 Everetts Formula 96
3.7.5 Relation between Bessels and Everetts Formulae 96
3.8 Practical Interpolation 97
3.9 Interpolation with Unevenly Spaced Points 101
3.9.1 Lagranges Interpolation Formula 101
3.9.2 Error in Lagranges Interpolation Formula 107
3.9.3 Hermites Interpolation Formula 108
3.10 Divided Differences and Their Properties 111
3.10.1 Newtons General Interpolation Formula 113
3.10.2 Interpolation by Iteration 115
3.11 Inverse Interpolation 116
3.12 Double Interpolation 118
Exercises 119
Answers to Exercises 125
xiii
xiv Preface
All the essential features of the previous editions like the over-all easy-
to-understand presentation and organization of the material and the choice
of suitable illustrative examples are retained in this edition.
Although our primary objective has been to provide the student with an
introduction to the methods of numerical analysis, we have also strived to
make this book as student-friendly as possible. It is hoped that this edition
will serve this purpose and meet the requirements of students and teachers
in numerical analysis.
The author is indebted to Sri Asoke K. Ghosh, Chairman and Managing
Director, PHI Learning, for his courteous cooperation in bringing out this
new edition.
Any information concerning corrections or errors in this book will be
gratefully received.
S.S. SASTRY
Chapter
1.1 INTRODUCTION
where the set of data values (xi, yi), i = 0, 1,
, n is given, but the
explicit nature of y(x) is not known. For example, if the data consist
of the angle q (in radians) of a rotating rod for values of time t (in
seconds), then its angular velocity and angular acceleration at any
time can be computed by numerical differentiation formulae.
(e) Matrices and linear systems: The problem of solving systems of
linear algebraic equations and the determination of eigenvalues and
eigenvectors of matrices are major problems of disciplines such as
differential equations, fluid mechanics, theory of structures, etc.
(f) Ordinary and partial differential equations: Engineering problems
are often formulated in terms of an ordinary or a partial differential
equation. For example, the mathematical formulation of a falling
body involves an ordinary differential equation and the problem of
determining the steady-state distribution of temperature on a heated
plate is formulated in terms of a partial differential equation. In most
cases, exact solutions are not possible and a numerical method has
to be adopted. In addition to the finite difference methods, this book
also presents a brief introduction to the cubic spline method for
solving certain partial differential equations.
(g) Integral equations: An equation in which the unknown function
appears under the integral sign is known as an integral equation.
Equations of this type occur in several areas of higher mathematics
such as aerodynamics, elasticity, electrostatics, etc. A short account
of some well-known methods is given.
In the numerical solution of problems, we usually start with some
initial data and then compute, after some intermediate steps, the
final results. The given numerical data are only approximate because
they may be true to two, three or more figures. In addition, the
SECTION 1.1: Introduction 3
others depends on the problem and its requirements. We list below some
important problem-solving languages, which are currently in use:
(a) FORTRAN: Standing for FORmula TRANslation, FORTRAN was
introduced by IBM in 1957. Since then, it has undergone many
changes and the present version, called FORTRAN 90, is favoured
by most scientists and engineers. It is readily available on almost all
computers and one of its important features is that it allows a
programmer to express the mathematical algorithm more precisely. It
has special features like extended double precision, special mathematical
functions and complex variables. Besides, FORTRAN is the language
used in numerically oriented subprograms developed by many software
libraries. For example, (IMSL) (International Mathematical and
Statistical Library, Inc.) consists of FORTRAN subroutines and
functions in applied mathematics, statistics and special functions.
FORTRAN programs are also available in the book, Numerical Recipes,
published by the Cambridge University Press, for most of the standard
numerical methods.
(b) C: This is a high-level programming language developed by Bell
Telephone Laboratories in 1972. Presently, it is being taught at
several engineering colleges as the first computer language and is
therefore used by a large number of engineers and scientists. Computer
programs in C for standard numerical methods are available in the
book, Numerical Recipes in C, published by the Cambridge University
Press.
(c) BASIC: Originally developed by John Kemeny and Thomas Kurtz in
1960, BASIC was used in the first few years only for instruction
purposes. Over the years, it has grown tremendously and the present
version is called Visual Basic. One of its important applications is
in the development of software on personal computers. It is easy
to use.
y = f (x)
y=k
f (b)
f (a)
0 x
a ξ b
( x − a)2 ( x − a ) n −1 ( n −1)
f ( x ) = f ( a ) + ( x − a ) f ′( a ) + f ′′( a ) + " + f (a ) + Rn ( x ),
2! ( n − 1)!
1 ⎡ ∂2 f ∂2 f ∂2 f ⎤
+ ⎢ 2 (' x1)2 + 2 ' x1 ' x2 + 2 (' x2)2 ⎥ + "
2 ⎢ ∂x1 ∂x1∂x2 ∂x 2 ⎥
⎣ ⎦
∂f ∂f ∂f
= f ( x1, x2 ,…, xn ) + ' x1 + ' x2 + " + ' xn
∂x1 ∂x2 ∂ xn
1 ⎡ ∂2 f ∂2 f ∂2 f
+ ⎢ 2 (' x1)2 +"+ 2 (' xn )2 + 2 ' x1 ' x2 +"
2 ⎢ ∂x1 ∂x n ∂x1 ∂x2
⎣
∂2 f ⎤
+2 ' xn −1 ' xn⎥ +"
∂xn −1∂xn ⎥⎦
SECTION 1.3: Errors and Their Computations 7
There are two kinds of numbers, exact and approximate numbers. Examples
of exact numbers are 1, 2, 3,
, 1/2, 3/2,
, 2, Q , e, etc., written in this
manner. Approximate numbers are those that represent the numbers to a
certain degree of accuracy. Thus, an approximate value of p is 3.1416, or
if we desire a better approximation, it is 3.14159265. But we cannot write
the exact value of p.
The digits that are used to express a number are called significant digits
or significant figures. Thus, the numbers 3.1416, 0.66667 and 4.0687 contain
five significant digits each. The number 0.00023 has, however, only two
significant digits, viz., 2 and 3, since the zeros serve only to fix the position
of the decimal point. Similarly, the numbers 0.00145, 0.000145 and 0.0000145 all
have three significant digits. In case of ambiguity, the scientific notation should
be used. For example, in the number 25,600, the number of significant figures
is uncertain, whereas the numbers 2.56 × 104, 2.560 × 104 and 2.5600 × 104
have three, four and five significant digits, respectively.
In numerical computations, we come across numbers which have large
number of digits and it will be necessary to cut them to a usuable number of
figures. This process is called rounding off. It is usual to round-off numbers
according to the following rule:
To round-off a number to n significant digits, discard all digits to the
right of the nth digit, and if this discarded number is
(a) less than half a unit in the nth place, leave the nth digit unaltered;
(b) greater than half a unit in the nth place, increase the nth digit by
unity;
(c) exactly half a unit in the nth place, increase the nth digit by unity
if it is odd; otherwise, leave it unchanged.
The number thus rounded-off is said to be correct to n significant
figures.
Example 1.1 The numbers given below are rounded-off to four significant
figures:
1.6583 to 1.658
30.0567 to 30.06
0.859378 to 0.8594
3.14159 to 3.142
In hand computations, the round-off error can be reduced by carrying
out the computations to more significant figures at each step of the
computation. A useful rule is: at each step of the computation, retain at least
one more significant figure than that given in the data, perform the last
operation and then round-off. However, most computers allow more number
8 CHAPTER 1: Errors in Numerical Calculations
| E 1A | + | E A2 | + " + | E An | .
SECTION 1.3: Errors and Their Computations 9
EA = aE 2A + bE 1A + E 1A E A2
= bE 1A + aE A2 , approximately (1.6)
a + E 1A 1
a bE A − aE A
2
− =
b + E A2 b b (b + E A2 )
bE 1A − aE A2
=
b 2(1 + E A2 /b)
bE 1A − aE A2
= 2
, assuming that E A2 /b is small in comparison with 1
b
a ⎛⎜ E A E A ⎞⎟
1 2
= − . (1.7)
b⎜ a b ⎟
⎝ ⎠
and
− 0.0012645
ER = = −0.000402.
3.1415926
Example 1.4 Three approximate values of the number 1/3 are given as
0.30, 0.33 and 0.34. Which of these three values is the best approximation?
We have
1 1
− 0.30 = .
3 30
1 0.01 1
− 0.33 = = .
3 3 300
1 0.02 1
− 0.34 = = .
3 3 150
It follows that 0.33 is the best approximation for 1/3.
Example 1.5 Find the relative error of the number 8.6 if both of its digits
are correct.
Here
EA = 0.05
Hence
0.05
ER = = 0.0058.
8.6
Here we have two numbers which have the greatest absolute error. These
are 305.1 and 143.3, and the absolute error in both these numbers is 0.05.
Hence, we round-off all the other numbers to two decimal digits. These are:
0.15, 15.45, 0.00, 8.12, 0.02, 0.64 and 0.17.
The sum S is given by
S = 305.1 + 143.3 + 0.15 + 15.45 + 0.00 + 8.12 + 0.02 + 0.64 + 0.17
= 472.95
= 473
To determine the absolute error, we note that the first-two numbers have
each an absolute error of 0.05 and the remaining seven numbers have an
absolute error of 0.005 each. Thus, the absolute error in all the 9 numbers is
EA = 2(0.05) + 7 (0.005)
= 0.1 + 0.035
= 0.135
= 0.14
In addition to the above absolute error, we have to take into account the
rounding error in the above and this is 0.01. Hence the total absolute error
is S = 0.14 + 0.01 = 0.15. Thus,
S = 472.95 ± 0.15.
Example 1.8 Find the difference
6.37 − 6.36
to three significant figures.
We have
6.37 = 2.523885893
and
6.36 = 2.521904043
Therefore, 6.37 − 6.36 = 0.001981850
= 0.00198, correct to three significant figures.
Alternatively, we have
6.37 6.36
6.37 6.36
6.37 6.36
0.01
2.524 2.522
0.198 t 10 2 , which is the same result as obtained before.
Example 1.9 Two numbers are given as 2.5 and 48.289, both of which
being correct to the significant figures given. Find their product.
12 CHAPTER 1: Errors in Numerical Calculations
Here the number 2.5 is the one with the greatest absolute error. Hence,
we round-off the second number to three significant digits, i.e., 48.3. The
required product is given by
P = 48.3 × 2.5
= 1.2 × 102
In the product, we retained only two significant digits, since one of the
given numbers, viz. 2.5, contained only two significant digits.
a2 b
s= ,
c3
where a = 6.54 ± 0.01, b = 48.64 ± 0.02, and c = 13.5 ± 0.03.
Also, find the relative error in the result.
We have
a2 = 42.7716, b = 6.9742 and c3 = 2460.375
SECTION 1.4: A General Error Formula 13
Therefore,
42.7716 × 6.9742
s= = 0.12124…
2460.375
= 0.121
Also,
1
log s = 2log a + log b 3log c
2
= 0.009931
5 xy 2
u= ,
z3
find the relative error at x = y = z = 1 when the errors in each of x, y, z is
0.001.
We have
∂u 5 y 2 ∂u 10 xy ∂u 15 xy 2
= 3 , = 3 and =− 4
∂x z ∂y z ∂z z
Then
5 y2 10 xy 15 xy 2
'u 'x 'y 'z.
z3 z3 z4
5 y2 10 xy 15 xy 2
( 'u ) max 'x 'y 'z
z3 z3 z4
( 'u ) max
( ER )max
u
0.03
0.006.
5
14 CHAPTER 1: Errors in Numerical Calculations
( xi +1 − xi ) n ( n )
f ( xi +1 ) = f ( xi ) + ( xi +1 − xi ) f ′( xi ) +" + f ( xi ) + Rn +1 ( xi +1 ), (1.13)
n!
where
( xi +1 − xi ) n +1 ( n +1)
Rn +1 ( xi +1 ) = f (Y ), xi < Y < xi +1 (1.14)
( n + 1)!
h2 hn (n)
f ( xi +1 ) = f ( xi ) + hf ′( xi ) + f ′′( xi ) + " + f ( xi ) + O( h n +1 ), (1.16)
2! n!
where O(hn+1) means that the truncation error is of the order of hn+1, i.e.,
it is proportional to hn+1. The meaning of this statement will be made clearer
now.
Let the series be truncated after the first term. This gives the zero-order
approximation:
f ( xi +1 ) = f ( xi ) + O( h ), (1.17)
which means that halving the interval length h will also halve the error in the
approximate solution. Similarly, the first-order Taylor series approximation is
given by
f ( xi +1 ) = f ( xi ) + hf ′( xi ) + O(h 2 ), (1.18)
which means that halving the interval length, h will quarter the error in
the approximation. In such a case we say that approximation has a
SECTION 1.5: Error in a Series Approximation 15
f ( x ) = x3 − 3 x 2 + 5 x − 10.
It is easily seen that f (1) = 7 but it will be instructive to see how the
Taylor series approximations of orders 0 to 3 improve the accuracy of f (1)
gradually.
Let h = 1, xi = 0 and xi +1 = 1. We then require f ( xi +1 ). The derivatives
of f (x) are given by
f ′( x) = 3 x 2 − 6 x + 5, f ′′( x ) = 6 x − 6, f ′′′( x) = 6,
f iv ( x) and higher derivatives being all zero. Hence
f ′( xi ) = f ′(0) = 5, f ′′( xi ) = f ′′(0) = −6, f ′′′(0) = 6.
Also,
f ( xi ) = f (0) = −10.
Hence, Taylors series gives
h2 h3 (i)
f ( xi +1 ) = f ( xi ) + hf ′( xi ) +
f ′′( xi ) + f ′′′( xi ).
2 6
From Eq. (i), the zero-order approximation is given by
f ( xi +1 ) = f ( xi ) + O( h ), (ii)
and, therefore,
f (1) = f (0) + O( h) ≈ −10,
h2 h3 (v)
f ( xi +1 ) = f ( xi ) + hf ′( xi ) + f ′′( xi ) + f ′′′( xi ),
2 6
and, therefore,
h2 h3
f (1) = f (0) + hf ′( x0 ) + f ′′( x0 ) + f ′′′( x0 )
2 6
1 1
≈ −10 + 5 + ( −6) + (6)
2 6
= −7,
which is the exact value of f (1).
This example demonstrates that if the given function is a polynomial of
third degree, then its third-order Taylor series approximation gives exact
results.
Example 1.13 Given f ( x) = sin x, construct the Taylor series approximations
of orders 0 to 7 at x = Q /3 and state their absolute errors.
Let xi +1 = Q /3 and xi = Q /6 so that h = Q /3 − Q /6 = Q /6. We then have
h5 v ¦ Q µ h6 vi ¦ Q µ h7 vii ¦ Q µ 8
f § ¶ f § ¶ f § ¶ O(h ) (i)
120 ¨ 6· 720 ¨ 6· 5040 ¨ 6·
Q 1Q2 3 ⎛ Q ⎞3 1 ⎛ Q ⎞ 4 3 ⎛ Q ⎞5 1 ⎛Q ⎞
6
= 0.5 + 3− − ⎜ ⎟ + ⎜ ⎟ + ⎜ ⎟ − ⎜ ⎟
12 4 36 12 ⎝ 6 ⎠ 48 ⎝ 6 ⎠ 240 ⎝ 6 ⎠ 1440 ⎝ 6 ⎠
7
3 ⎛Q ⎞
− ⎜ ⎟.
10080 ⎝ 6 ⎠
SECTION 1.5: Error in a Series Approximation 17
0 0.5 0.366025403
1 0.953449841 0.087424438
2 0.884910921 0.018885518
3 0.864191613 0.00183379
4 0.865757474 0.000267929
5 0.86604149 0.000016087
6 0.86602718 0.000001777
7 0.866025326 0.000000077
We next demonstrate the effect of halving the interval length on any approximate
value. For this, we consider the first-order approximation in the form:
f ( x + h) = f ( x) + hf ′( x) + E (h), (ii)
where E(h) is the absolute error of the first-order approximation with interval
h. Taking f ( x ) = sin x and x = Q /6, we obtain
⎛π ⎞ π π (iii)
sin ⎜ + h ⎟ = sin + h cos + E ( h).
⎝6 ⎠ 6 6
Putting h = Q /6 in (iii), we get
Q Q 3
sin = 0.5 + + E (h) = 0.953449841 + E ( h).
3 12
Since sin (Q /3) = 0.866025403, the above equation gives
E ( h) = −0.087424438.
18 CHAPTER 1: Errors in Numerical Calculations
Now, let the interval be halved so that we now take h = Q /12. Then, (iii) gives:
⎛Q Q ⎞ Q 3 ⎛h⎞ (iv)
sin ⎜ + ⎟ = 0.5 + + E ⎜ ⎟,
⎝ 6 12 ⎠ 12 2 ⎝2⎠
where E (h /2) is the absolute error with interval length h/2. Since
⎛Q Q ⎞ Q 1
sin ⎜ + ⎟ = sin =
⎝ 6 12 ⎠ 4 2
Equation (iv) gives
¦ hµ 1 Q 3
E§ ¶ 0.5 0.019618139,
¨ 2· 2 24
and then
E (h)
= 4.45630633.
E ( h /2)
In a similar way, we obtain the values
E (h /2)
= 4.263856931
E (h /4)
and
E (h /4)
= 4.141353027.
E ( h /8)
The h2-order of convergence is quite revealing in the above results.
Example 1.14 The Maclaurin expansion for ex is given by
x 2 x3 x n −1 xn Y
ex = 1+ x + + +" + + e , 0 < Y < x.
2! 3! ( n − 1)! n!
We shall find n, the number of terms, such that their sum yields the value
of ex correct to 8 decimal places at x = 1.
Clearly, the error term (i.e. the remainder term) is ( x n /n!) eY , so that
at x = x, this gives the maximum absolute error, and hence the maximum
relative error is x n /n! For an 8 decimal accuracy at x = 1, we must have
1 1 −8
< (10 )
n! 2
which gives n = 12. Thus, we need to take 12 terms of the exponential
series in order that its sum is correct to 8 decimal places.
Example 1.15 Derive the series
1 x ¦ x3 x5 µ
loge 2§ x "¶
1 x ¨ 3 5 ·
EXERCISES 19
and use it to compute the value of loge(1.2), correct to seven decimal places.
If, instead, the series for loge(1 + x) is used, how many terms must be taken
to obtain the same accuracy for loge(1.2)?
We have
x 2 x3 x 4 x5 … (i)
log e (1 + x) = x − + − + −
2 3 4 5
and
x x2 x3 x4 x5 |
2 3 4 5
loge (1 x) (ii)
Therefore,
1+ x ⎛ x 3 x 5 …⎞
log e =2⎜x+ + + ⎟ (iii)
1− x ⎜ 3 5 ⎟
⎝ ⎠
1
Putting x = in Eq. (iii), we obtain
11
© 1 1 1 ¸
loge 1.2 2 ª "¹
«ª 11 3(11)3 5(11)5 º¹
© 1 1 1 ¸ 1
2ª ¹ , since 7.33 t 109.
«ª 11 3(11)3 5(11)5 º¹ 7(11) 7
Hence we obtain
log e 1.2 = 2 [0.09090909 + 0.00025044 + 0.00000124]
= 0.1823216
On the other hand, if we use series (i), we have
xn
< 2 × 10−7
n
(1.2) n
Þ 2 t 10 7
n
Þ n 9.
Thus, 9 terms of the series (i) have to be taken in order to obtain a seven
decimal accuracy.
EXERCISES
1.1 Explain the term round-off error and round-off the following numbers
to two decimal places:
48.21416, 2.3742, 52.275, 2.375, 2.385, 81.255
20 CHAPTER 1: Errors in Numerical Calculations
1.3 Calculate the value of 102 − 101 correct to four significant figures.
1.4 If p = 3c6 6c2, find the percentage error in p at c = 1, if the error
in c is 0.05.
1.5 Find the absolute error in the sum of the numbers 105.6, 27.28, 5.63,
0.1467, 0.000523, 208.5, 0.0235, 0.432 and 0.0467, where each number
is correct to the digits given.
1
1.6 If z = xy3, find the percentage error in z when x = 3.14 ± 0.0016 and
8
y = 4.5 ± 0.05.
1.7 Find the absolute error in the product uv if u = 56.54 ± 0.005 and
v = 12.4 ± 0.05.
1.8 Prove that the relative error in a product of three nonzero numbers
does not exceed the sum of the relative errors of the given numbers.
1.9 Find the relative error in the quotient 4.536/1.32, the numbers being
correct to the digits given.
1.10 The exponential series is given by
x 2 x3 x 4
ex 1 x "
2! 3! 4!
Find the number of terms of the above series such that their sum gives
the value of e correct to five decimal places.
1.11 Compute the value of ln 3 correct to five decimal places.
Q
1.12 Write down the Taylors series expansion of f (x) = cos x at x = in
3
Q
terms of f (x), and its derivatives at x = . Compute the approximations
4
from the zeroth order to the fifth order and also state the absolute error
in each case.
1.13 The Maclaurin expansion of sin x is given by
x3 x5 x 7 …
sin x = x − + − +
3! 5! 7!
where x is in radians. Use the series to compute the value of sin 25°
to an accuracy of 0.001.
EXERCISES 21
Answers to Exercises
2.1 INTRODUCTION
are called polynomials and we discuss some special methods for determining
their roots. A non-algebraic function is called a transcendental function,
e.g., f (x) = ln x3 0.7 f (x) = e0.5x 5x, y (x) = sin2x x2 2, etc. The roots
of Eq. (2.1) may be either real or complex. We discuss methods of finding a
real root of algebraic or transcendental equations and also methods of
determining all real and complex roots of polynomials. Solution of systems of
nonlinear equations will be considered at the end of the chapter.
22
SECTION 2.2: Bisection Method 23
If f (x) is a polynomial of the form Eq. (2.2), the following results, from
the theory of equations would be useful in locating its roots.
(i) Every polynomial equation of the nth degree has n and only n roots.
(ii) If n is odd, the polynomial equation has atleast one real root whose
sign is opposite to that of the last term.
(iii) If n is even and the constant term is negative, then the equation has
atleast one positive root and atleast one negative root.
(iv) If the polynomial equation has (a) real coefficients, then imaginary
roots occur in pairs and (b) rational coefficients, then irrational roots
occur in pairs.
(v) Descartes Rule of Signs
(a) A polynomial equation f (x) = 0 cannot have more number of
positive real roots than the number of changes of sign in the
coefficients of f (x).
(b) In (a) above, f (x) = 0 cannot have more number of negative
real roots than the number of changes of sign in the coefficients
of f (x).
This method is based on Theorem 1.1 which states that if a function f (x) is
continuous between a and b, and f (a) and f (b) are of opposite signs, then there
exists at least one root between a and b. For definiteness, let f (a) be negative
and f (b) be positive. Then the root lies between a and b and let its approximate
value be given by x0 = (a + b)/2. If f (x0) = 0, we conclude that x0 is a root of
the equation f (x) = 0. Otherwise, the root lies either between x0 and b, or
between x0 and a depending on whether f (x0) is negative or positive. We
designate this new interval as [a1, b1] whose length is |b a|/2. As before, this
is bisected at x1 and the new interval will be exactly half the length of the
previous one. We repeat this process until the latest interval (which contains
the root) is as small as desired, say e. It is clear that the interval width is
reduced by a factor of one-half at each step and at the end of the nth step, the
new interval will be [an, bn] of length |b a|/2n. We then have
|b −a|
≤ F,
2n
which gives on simplification
log e (| b − a |/F )
n≥ (2.3)
log e 2
Equation (2.3) gives the number of iterations required to achieve an accuracy
e. For example, if | b a | = 1 and e = 0.001, then it can be seen that
n ³ 10 (2.4)
24 CHAPTER 2: Solution of Algebraic and Transcendental Equations
x2 x0 a
x1 x
0 b
[a, f (a)]
−2 − 2.5
x2 = = − 2.25
2
Now f (x2) = 1.5781, and, therefore, the root lies between 2 and 2.25.
It follows that
– 4.25
x3 – 2.125
2
Successive approximations are given by
x4 = 2.0625, x5 = 2.0938, x6 = 2.1094,
x7 = 2.1016, x8 = 2.1055, x9 = 2.1035,
x10 = 2.1045, x11 = 2.1050,
The difference between x10 and x11 is 0.0005. Hence, we conclude that the root
is given by x = 2.105, correct to three decimal places.
Example 2.4 Find the positive root, between 0 and 1, of the equation
x = ex to a tolerance of 0.05%.
Let
f (x) = xex 1 = 0
We have, f (0) = 1 and f (1) = e 1, which is positive. Hence, a root exists
between 0 and 1, and
0 +1
x1 = = 0.5
2
Because, f (x1) = 0.1756, the root lies between 0.5 and 1.0.
Then
0.5 + 1.0
x2 = = 0.75
2
SECTION 2.2: Bisection Method 27
x2 x1
F1 t 100
x2
0.25
t 100 33.33%
0.75
since f (x2) = 0.5878, the root lies between 0.5 and 0.75.
Therefore,
0.5 0.75
x3 0.625
2
also,
0.625 – 0.75
F2 t 100 20%.
0.625
Proceeding in this way, successive approximations and tolerances are obtained:
x4 = 0.5625, e3 = 11.11%; x5 = 0.5938, e4 = 5.26%;
x6 = 0.5781, e5 = 2.71%; x7 = 0.5703, e6 = 1.37%;
x8 = 0.5664, e7 = 0.69%; x9 = 0.5684, e8 = 0.35%;
x10 = 0.5674, e9 = 0.18%; x11 = 0.5669, e10 = 0.09%;
x12 = 0.5671, e11 = 0.035%
Since e11 = 0.035% < 0.05%, the required root is 0.567, correct to three
decimal places.
Example 2.5 Find a root, correct to three decimal places and lying between
0 and 0.5, of the equation
4ex sin x 1 = 0
Let
f (x) = 4ex sin x 1
We have f (0) = 1 and f (0.5) = 0.163145
Therefore,
x1 = 0.25
Since f (0.25) = 0.22929, it follows that the root lies between 0.25 and 0.5.
Therefore,
0.75
x2 = = 0.375
2
The successive approximations are given by
x3 = 0.3125, x4 = 0.3438, x5 = 0.3594,
x6 = 0.3672, x7 = 0.3711, x8 = 0.3692,
x9 = 0.3702, x10 = 0.3706, x11 = 0.3704
x12 = 0.3705,
Hence the required root is 0.371, correct to three decimal places.
28 CHAPTER 2: Solution of Algebraic and Transcendental Equations
This is the oldest method for finding the real root of a nonlinear equation
f (x) = 0 and closely resembles the bisection method. In this method, also
known as regulafalsi or the method of chords, we choose two points a and
b such that f (a) and f (b) are of opposite signs. Hence, a root must lie in
between these points. Now, the equation of the chord joining the two points
[a, f (a)] and [b, f (b)] is given by
y − f (a) f (b) − f (a )
= . (2.6)
x−a b−a
The method consists in replacing the part of the curve between the points
[a, f (a)] and [b, f (b)] by means of the chord joining these points, and taking
the point of intersection of the chord with the x-axis as an approximation to
the root. The point of intersection in the present case is obtained by putting
y = 0 in Eq. (2.6). Thus, we obtain
f (a) af (b) − bf (a)
x1 = a − (b − a ) = , (2.7)
f (b) − f (a) f (b) − f ( a)
which is the first approximation to the root of f (x) = 0. If now f (x1) and
f (a) are of opposite signs, then the root lies between a and x1, and we
replace b by x1 in Eq. (2.7), and obtain the next approximation. Otherwise, we
replace a by x1 and generate the next approximation. The procedure is repeated
till the root is obtained to the desired accuracy. Figure 2.2 gives
a graphical representation of the method. The error criterion Eq. (2.5) can be
used in this case also.
Y
y = f (x)
* B [b, f (b)]
O x1 Y
x2 X
*
A [a, f (a)]
Figure 2.2 Method of false position.
f (x) = x3 2x 5 = 0.
2(16) − 3(−1) 35
x1 = = = 2.058823529.
16 − (−1) 17
Now, f (x1) = 0.390799917 and hence the root lies between 2.058823529 and
3.0. Using formula (2.7), we obtain
2.058823529(16) − 3(−0.390799917)
x2 = = 2.08126366.
16.390799917
Since f (x2) = 0.147204057, it follows that the root lies between 2.08126366
and 3.0. Hence, we have
2.08126366(16) − 3(−0.147204057)
x3 = = 2.089639211.
16.147204057
Proceeding in this way, we obtain successively:
x4 = 2.092739575, x5 = 2.09388371,
x6 = 2.094305452, x7 = 2.094460846,
The correct value is 2.0945
, so that x7 is correct to five significant figures.
Example 2.7 Given that the equation x2.2 = 69 has a root between 5 and 8.
Use the method of regulafalsi to determine it.
Let f (x) = x2.2 69. We find
Now, f (x1) = 4.275625415 and therefore, the root lies between 6.655990062
and 8.0. We obtain
x2 = 6.83400179, x3 = 6.850669653.
The correct root is 6.8523651
, so that x3 is correct to three significant
figures.
Example 2.8 The equation 2x = log10 x + 7 has a root between 3 and 4. Find
this root, correct to three decimal places, by regulafalsi method.
Let
f (x) = 2x log10 x 7, a = 3 and b = 4.
Then we find
f (3) = 1.4771 and f (4) = 0.3979.
30 CHAPTER 2: Solution of Algebraic and Transcendental Equations
Hence
af (b) − bf (a)
x1 =
f (b) − f (a)
3(0.3979) − 4(−1.4771)
=
0.3979 + 1.4771
7.1021
= = 3.7878.
1.8750
Therefore, the root lies between 3 and 3.7878. Now, we take a = 3 and b = 3.7878
Then,
f (b) = 2(3.7878) log10 3.7878 7 = 0.002787
Hence,
3( 0.002787) 3.7878(–1.4771)
x2
– 0.002787 1.4771
3.7893,
and
f ( x2 ) = 2(3.7893) − log10 (3.7893) − 7
= 0.000041,
which shows that x = 3.789 is the root correct to three decimal places.
Hence
0(0.038919) 0.39636( 1)
x3
1.038919
0.381512,
and
f (x3) = 0.016934
Taking a = 0 and b = 0.381512, we obtain
0(0.016934) − 0.381512(–1)
x4 =
1.016934
= 0.375159,
and
f (x4) = 0.0071873
Proceeding as above, we obtain
x5 = 0.37248, x6 = 0.37136,
x7 = 0.37089, x8 = 0.370697
It follows that the required root is 0.371, correct to three decimal places.
The preceding sequence may not converge to a definite number. But if the
sequence converges to a definite number x, then x will be a root of the equation
x = f (x). To show this, let
xn+1 = f (xn) (2.9)
be the relation between the nth and (n + 1)th approximations. As n increases,
xn+1 ® x and if f (x) is a continuous function, then f (xn) ® f (x). Hence, in
the limit, we obtain
x = f (x), (2.10)
which shows that x is a root of the equation x = f (x).
To establish the condition of convergence of Eq. (2.8), we proceed in the
following way:
From Eq. (2.9), we have
x1 = f (x0) (2.11)
From Eqs. (2.10) and (2.11), we get
Y x1 G (Y ) G ( x0 )
(2.12)
(Y x0 ) G b(Y0 ), x0 Y0 Y ,
on using Theorem 1.5. Similarly, we obtain
x x2 = (x x1) f ¢(x1), x1 < x1 < x (2.13)
x x3 = (x x2) f ¢(x2), x2 < x2 < x (2.14)
M M M
x xn+1 = (x xn) f ¢(xn), xn < xn < x (2.15)
If we assume
|f ¢ (xi)| £ k (for all i), (2.16)
then Eqs. (2.12) to (2.15) give
|x x1| £ k |x x0|
1442443
|x x2| £ k |x x1|
|x x3| £ k |x x2| (2.17)
M M
|x xn+1| £ k |x xn|
Multiplying the corresponding sides of the above equations, we obtain
|x xn+1| £ kn+1 |x x0| (2.18)
If k < 1, i.e., if |f ¢(xi)| < 1, then the right side of Eq. (2.18) tends to zero
and the sequence of approximations x0, x1, x2,
converges to the root x. Thus,
when we express the equation f (x) = 0 in the form x = f (x), then f (x) must
be such that
| f ¢(x) | < 1
in an immediate neighbourhood of the root. It follows that if the initial
approximation x0 is chosen in an interval containing the root x, then the
sequence of approximations converges to the root x.
SECTION 2.4: Iteration Method 33
Now, we show that the root so obtained is unique. To prove this, let x1 and
x2 be two roots of the equation x = f (x). Then, we must have
x1 = f (x1) and x2 = f (x2).
Therefore,
| Y1 − Y 2 | = | G (Y1 ) − G (Y 2 ) |
= | Y1 − Y 2 | G ′(I ), I ∈ (Y1, Y 2 )
Hence,
|x1 x2| [1 f¢(h)] = 0 (2.19)
Since |f¢(h)| < 1, it follows that x1 = x2, which proves that the root obtained
is unique.
Finally, we shall find the error in the root obtained. We have
| Y xn | c k | Y xn 1 |
k | Y xn xn xn 1 |
c k <| Y xn | | xn xn 1 |>
k k
Þ | Y xn | c | xn xn 1 | k n 1 | x1 x0 |
1 k 1 k
kn
c
| x1 x0 |, (2.20)
1 k
which shows that the convergence would be faster for smaller values of k.
Now, let e be the specified accuracy so that
| x xn | £ e
Then, Eq. (2.20) gives
1− k
| xn − xn −1 | ≤
F, (2.21)
k
which can be used to find the difference between two successive approxima-
tions (or iterations) to achieve a prescribed accuracy.
Example 2.10 Find a real root of the equation x3 = 1 x2 on the interval [0, 1]
with an accuracy of 104.
We rewrite the equation as
1
x= (i)
x +1
Here
1
G ( x) ( x 1) 1/ 2
x 1
Therefore,
1 1
G ′( x) = − ( x + 1)−3/ 2 = − < 1in [0, 1].
2 2 ( x + 1)3
Also,
1 1
max | G ′( x) | = = = k < 0.2
2 8 4 2
34 CHAPTER 2: Solution of Algebraic and Transcendental Equations
Example 2.11 Find a real root, correct to three decimal places, of the equation
2x 3 = cos x
©3 Q¸
lying in the interval ª2
, .
« 2 ¹º
We rewrite the given equation as
1
x = (cos x + 3)
2
Here
1 ©3 Q ¸
|G b ( x)|
|sin x | 1, in ª , ¹ .
2 «2 2 º
Choosing x0 = 1.5, we obtain successively:
1
x1 (cos 1.5 3) 1.5354,
2
1
x2 (cos 1.5354 3) 1.5177,
2
1
x3 (cos 1.5177 3) 1.5265,
2
1
x4 (cos 1.5265 3) 1.5221,
2
1
x5 (cos 1.5221 3) 1.5243,
2
SECTION 2.4: Iteration Method 35
1
x6 (cos 1.5243 3) 1.5232,
2
1
x7 (cos 1.5232 3) 1.5238.
2
Now, | x7 x6 | = 0.0006 < 0.001. Hence, the root, correct to three decimal
places is 1.524.
Example 2.12 Use the method of iteration to find a positive root of the
equation xex = 1, given that a root lies between 0 and 1.
Writing the equation in the form
x = ex,
we find that
1
G b ( x) e x for x 1
e
Therefore,
| f¢(x) | < 1.
Choosing x0 = 0.5, we find
x1 = e0.5 = 0.60653, x2 = 0.54524,
x3 = 0.57970, x4 = 0.56007,
x5 = 0.57117, x6 = 0.56486,
x7 = 0.56844, x8 = 0.56641,
x9 = 0.56756, x10 = 0.56691,
x11 = 0.56728, x12 = 0.56706,
x13 = 0.56719, x14 = 0.56712,
x15 = 0.56716, x16 = 0.56713,
x17 = 0.56715, x18 = 0.56714,
x19 = 0.56714.
It follows that the root, correct to four decimal places, is 0.5671.
Example 2.13 Use the iterative method to find a real root of the equation
sin x = 10(x 1). Give your answer correct to three decimal places.
Let
f (x) = sin x 10x + 10
We find, from graph, that a root lies between 1 and p (The student is
advised to draw the graphs). Rewriting the equation as
sin x
x =1+ ,
10
we have
sin x
G ( x) = 1 + ,
10
and
cos x
|G b( x)| 1in 1 c x c Q .
10
36 CHAPTER 2: Solution of Algebraic and Transcendental Equations
( xi +1 − xi )2 (2.22)
Y = xi +1 − .
xi +1 − 2 xi + xi −1
If we now define Dxi and D2xi by the relations
( 'xi )2 (2.23)
Y = xi +1 − 2
.
' xi −1
2
which explains the term D -process.
In any numerical application, the values of the following underlined
quantities must be obtained.
xi –1
%xi –1
xi % 2 xi –1
%xi
xi 1
( −0.017)2
x4 = 1.518 − = 1.524,
−0.052
which corresponds to six normal iterations.
This method is generally used to improve the result obtained by one of the
previous methods. Let x0 be an approximate root of f (x) = 0 and let
x1 = x0 + h be the correct root so that f (x1) = 0. Expanding f (x0 + h) by
Taylors series, we obtain
h2
f ( x0 ) + hf ′( x0 ) + f ′′( x0 ) + " = 0.
2!
38 CHAPTER 2: Solution of Algebraic and Transcendental Equations
P (x0, y0)
x
0 x1 x0
Example 2.15 Use the NewtonRaphson method to find a root of the equation
x3 2x 5 = 0.
Here f (x) = x3 2x 5 and f ¢(x) = 3x2 2. Hence Eq. (2.24b) gives:
x n3 − 2 xn − 5
xn +1 = xn − (i)
3x n2 − 2
40 CHAPTER 2: Solution of Algebraic and Transcendental Equations
Example 2.17 Find a real root of the equation x = ex, using the Newton
Raphson method.
We write the equation in the form
f ( x) = xe x − 1 = 0 (i)
Let x0 = 1. Then
e −1 1 ⎛ 1 ⎞
x1 = 1 − = ⎜ 1 + ⎟ = 0.6839397
2e 2 ⎝ e⎠
SECTION 2.5: NewtonRaphson Method 41
Now
f (x1) = 0.3553424, and f ¢(x1) = 3.337012,
so that
0.3553424
x2 = 0.6839397 − = 0.5774545
3.337012
Proceeding in this way, we obtain
x3 = 0.5672297 and x4 = 0.5671433.
Example 2.19 Given the equation 4ex sin x 1 = 0, find the root between
0 and 0.5 correct to three decimal places.
Let f (x) = 4ex sin x 1 and x0 = 0.2.
Then
f (x0) = 0.349373236,
and
f ¢(x0) = 2.559015826.
Therefore,
0.349373236
x1 0.2
2.559015826
0.336526406 0.33653.
42 CHAPTER 2: Solution of Algebraic and Transcendental Equations
Now,
f (x1) = 0.056587
and
f ¢(x1) = 1.753305735
= 1.75330
Therefore,
0.056587
x2 0.33653 0.36880
1.75330
For the next approximation, we find f (x2) = 0.00277514755 and
f ¢(x2) = 1.583028705. This gives
x3 = 0.36880 0.00175 = 0.37055
since f (x3) = 0.00001274, it follows that the required root is given by
x = 0.370.
Generalized Newton’s method
If x is a root of f (x) = 0 with multiplicity p, then the iteration formula
corresponding to Eq. (2.24) is taken as
f ( xn ) (2.31)
xn +1 = xn − p ,
f ′( xn )
which means that (1/p) f ¢(xn) is the slope of the straight line passing through
(xn, yn) and intersecting the x-axis at the point (xn+1, 0).
Equation (2.31) is called the generalized Newtons formula and reduces
to Eq. (2.24) for p = 1. Since x is a root of f (x) = 0 with multiplicity p,
it follows that x is also a root of f ¢(x) = 0 with multiplicity (p 1), of
f ¢¢(x) = 0 with multiplicity (p 2), and so on. Hence the expressions
f ( x0 ) f ′( x0 ) f ′′( x0 )
x0 − p , x0 − ( p − 1) , x0 − ( p − 2)
f ′( x0 ) f ′′( x0 ) f ′′′( x0 )
must have the same value if there is a root with multiplicity p, provided that
the initial approximation x0 is chosen sufficiently close to the root.
Example 2.20 Find a double root of the equation f (x) = x3 x2 x + 1 = 0.
Choosing x0 = 0.8, we have
f ¢(x) = 3x3 2x 1, and f ¢¢(x) = 6x 2.
With x0 = 0.8, we obtain
f ( x0 ) 0.072
x0 − 2 = 0.8 − 2 = 1.012,
f ′( x0 ) −(0.68)
and
f ′( x0 ) (−0.68)
x0 − = 0.8 − = 1.043.
f ′′( x0 ) 2.8
SECTION 2.6: Ramanujans Method 43
The closeness of these values indicates that there is a double root near to
unity. For the next approximation, we choose x1 = 1.01 and obtain
f ( x1 )
x1 − 2 = 1.01 − 0.0099 = 1.0001,
f ′( x1 )
and
f ′( x1 )
x1 − = 1.01 − 0.0099 = 1.0001.
f ′′( x1 )
We conclude, therefore, that there is a double root at x = 1.0001 which is
sufficiently close to the actual root unity.
On the other hand, if we apply NewtonRaphson method with x0 = 0.8,
we obtain
x1 = 0.8 + 0.106 » 0.91, and x2 = 0.91 + 0.046 » 0.96.
It is clear that the generalized Newtons method converges more rapidly than
the NewtonRaphson procedure.
1 1 1 1
will have roots and such that > .
x1 x2 | x1 | | x2 |
Now,
1
1 ¦ a1 a µ
1
§
x 2 x2 ¶
G ( x) ¨ a0 a0 ·
can be written as
−1
⎛ a1 a ⎞ k1 k2
⎜1 + x + 2 x2 ⎟ = +
⎝ a0 a0 ⎠ 1 1
x− x−
x1 x2
− k1 x1 −k2 x2
= +
1 − xx1 1 − xx2
= − k1 x1 (1 − xx1 ) −1 − k2 x2 (1 − xx2 ) −1
e
¥ ¥ k x
2
bi xi , where bi i 1
r r
i 0 r 1
Then,
i
k1 ¦ x1 µ
1
bi 1 k1 x1i i
k 2 x2 k 2 §¨ x2 ¶· 1
bi k1 x1i 1 k2 x2i 1 k1 ¦ x1 µ
i 1 x2
1
k 2 §¨ x2 ¶·
x1
Since < 1, it follows that
x2
bi − 1 1
lim = ,
i →∞ bi x2
which is the smallest root. This is the basis of Ramanujans method
which is outlined below.
To find the smallest root of f (x) = 0, we consider f (x) in the form
f (x) = 1 (a1x + a2x2 + a3x3 + L),
and then write
1
©1
«
( a1 x a2 x 2 a3 x 3 ") ¸
º
b1 b2 x b3 x
2
" (2.33)
b2 = a1 = a1b1, since b1 = 1
b3 = a2 + a12 = a2b1 + a1b2, since b2 = a1
(2.35)
M M M M
bk = a1bk1 + a2bk + L + ak1b1
= ak1b1 + ak2b2 + L + a1bk1
SECTION 2.6: Ramanujans Method 45
bi 1
The ratios , called the convergents, approach, in the limit, the smallest
bi
root of f (x) = 0. The method is demonstrated in the following examples.
⎛ 3⎞ 1
= 1.0833 (0.7986) + ⎜ − ⎟ (1.0833) + (1)
⎝ 8⎠ 24
= 0.5007
Therefore,
b3
= 1.595
b4
b5 a1b4 a2b3 a3b2
¦ 3µ 1
1.0833(0.5007) § ¶ (0.7986) (1.0833)
¨ 8· 24
0.2880
46 CHAPTER 2: Solution of Algebraic and Transcendental Equations
Therefore,
b4 0.5007
= = 1.7382.
b5 0.2880
b6 = a1b5 + a2 b4 + a3b3
= 0.1575
Therefore,
b5
= 1.8286.
b6
b7 = 0.0835
Therefore,
b6
= 1.8862.
b7
b8 = 0.0434
Therefore,
b7
= 1.9240.
b8
b9 = 0.0223
Therefore,
b8
= 1.9462.
b9
The roots of the given equation are 2, 3 and 4 and it can be seen that the
successive convergents approach the value 2.
Example 2.23 Find the smallest root, correct to 4 decimal places, of the
equation
f (x) = 3x cos x 1 = 0.
We have
f (x) = 1 − 3x + cos x
x2 x4 x6
= 1 − 3x + 1 − + − +"
2! 4! 6!
x2 x4 x6
2 3x "
2! 4! 6!
⎡ 3 x2 x4 x6 x8 ⎤
= 2 ⎢1 − x − + − + − "⎥
⎣⎢ 2 4 48 1440 80640 ⎦⎥
Now, let
1
¦3 x2 x4 x6 x8 µ
2
1 § x ¶ b1 b2 x b3 x "
¨2 4 48 1440 80640 ·
Here
3 1 1
a1 = , a2 = , a3 = 0, a4 = − ,
2 4 48
1 1
a5 0, a6 , a7 0, a8 ,!
1440 80640
48 CHAPTER 2: Solution of Algebraic and Transcendental Equations
we then obtain,
b1 = 1, b2 = 1.5,
b3 = 2.5, b4 = 4.125,
b5 = 6.79167, b6 = 11.18750,
b7 = 18.42778, b8 = 30.35365
The successive convergents are
b1 b2
= 0.66667; = 0.60000,
b2 b3
b3 b4
= 0.60606; = 0.60736,
b4 b5
b5 b6
= 0.60708; = 0.60710,
b6 b7
b7
0.607102
b8
Hence the required root, correct to four decimal places, is 0.6071.
Example 2.24 Using Ramanujans method, find a real root of the equation
x2 x3 x4
1− x + − + −" = 0
(2!) 2 (3!) 2 (4!) 2
Let
⎡ x2 x3 x4 ⎤
1 − ⎢x − + − + "⎥=0 (i)
⎢⎣ (2!)2 (3!) 2 (4!) 2 ⎥⎦
we have
1 1
a1 = 1, a2 , a3 ,
(2!) 2 (3!)2
1 1 1
a4 = − , a5 = , a6 ,!
(4!) 2 (5!) 2 (6!)2
Then we obtain
b1 = 1; b2 = a1 = 1;
1 3
b3 = a1b2 + a2b1 = 1 − = ;2
(2!) 4
b4 = a1b3 + a2b2 + a3b1
3 1 1 19
= − + = ;
4 4 36 36
211
b5 ,!
576
SECTION 2.7: Secant Method 49
b4
= 1.4408,
b5
where the last result is correct to three significant figures.
2 (16) − 3(−1) 35
x1 = = = 2.058823529.
17 17
50 CHAPTER 2: Solution of Algebraic and Transcendental Equations
Also,
f (x1) = f1 = 0.390799923.
Putting i = 1 in Eq. (2.37), we obtain
x0 f1 − x1 f0 3(−0.390799923) − 2.058823529(16)
x2 = = = 2.08126366.
f1 − f0 −16.390799923
Again
f (x2) = f2 = 0.147204057.
Hence
x3 f 4 – x4 f3
x5 = = 0.56653.
f 4 – f3
and
f5 = 0.00169
Therefore,
x4 f5 – x5 f 4
x6 0.56714.
f5 f 4
We also find
f (x6) = 0.0001196.
It follows that the required root is 0.5671, correct to four decimal places.
( x – xi –2 )( x – xi –1 )
+ yi (2.38)
( xi – xi –2 )( xi – xi –1 )
Let
hi = xi xi1, hi1 = xi1 xi2 (2.39)
Then
x xi1 = x xi + xi xi1 = (x xi) + hi,
1442443
( x – xi + hi + hi –1 )( x – xi + hi )
+ yi (2.41)
hi ( hi –1 + hi )
52 CHAPTER 2: Solution of Algebraic and Transcendental Equations
1442443
1 ¦ 'i 'i –1 µ
A –
(hi –1 hi ) §¨ hi hi –1 ¶· (2.42)
'
and B i Ahi
hi
With these values of A and B, the quadratic Eq. (2.38) gives the next
approximation xi+1
– B q B 2 – 4 Ayi
xi 1 xi (2.43)
2A
Since Eq. (2.43) leads to inaccurate results, we take the equivalent form
2 yi
xi +1 = xi –
(2.44)
B ± B 2 − 4 Ayi
In Eq. (2.44), the sign in the denominator should be chosen so that the
denominator will be largest in magnitude. With this choice, Eq. (2.44) gives
the next approximation to the root.
Example 2.27 Using Mullers method, find the root of the equation
f (x) = x3 x 1 = 0,
with the initial approximations
xi2 = 0, xi1 = 1, xi = 2.
We have
yi2 = 1, yi1 = 1, yi = 5.
Also,
hi = 1, hi1 = 1,
Di = 6, Di1 = 0.
Hence, Eq. (2.42) gives A = 3 and B = 9.
Then
B 2 4 Ayi 21
therefore, Eq. (2.44) gives
2(5)
xi +1 = 2 – , since the sign of B is positive
9 + 21
= 1.26376.
1.26376 – 2
Error in the above result = 100 = 58%.
1.26376
SECTION 2.9: Graeffes Root-Squaring Method 53
A1
14444244443
Y1 + Y 2 + Y 3 = −
A0
A2
Y1Y 2 + Y 2Y3 + Y 3Y1 = (2.46)
A0
A3
and Y1Y 2Y3 = –
A0
Y 2 Y3
Since , are negligible, the above relations give
Y1 Y 2
A A A
Y1 = – 1 , Y 2 = – 2 and Y 3 = – 3 (2.47)
A0 A1 A2
Thus, the magnitudes of the roots will be known when once the roots are
widely separated. Now, we shall show the way, the roots are separated by
considering the cubic equation
p(x) = (x 1)(x 2)(x 3) (2.48)
then
p(x) = (x 1)(x 2)(x 3)
= (1)3(x + 1)(x + 2)(x + 3) (2.49)
therefore,
p(x)p(x) = (1)3(x2 1)(x2 4)(x2 9) (2.50)
letting
q(z) = (z 1)(z 4)(z 9), (2.51)
2
where z = x , we find that the roots of Eq. (2.51) are the squares of the roots
of Eq. (2.48). By transforming Eq. (2.51) in the same way as above, we get
another equation whose roots are the squares of the roots of Eq. (2.51). This
is the principle underlying this method and due to this reason, this method
is called root-squaring method.
Now, let the given cubic be
f (x) = a0x3 + a1x2 + a2x + a3 = 0 (2.52)
with roots a1, a2 and a3 such that
|a1| > |a2| > |a3|.
Suppose that Eq. (2.52) is transformed m times by the root-squaring process
described above, and that the transformed equation is
ui B im , i 1, 2, 3. (2.54)
SECTION 2.9: Graeffes Root-Squaring Method 55
But ui are given by the coefficients in Eq. (2.53). Hence we have the following
formulae for the roots of Eq. (2.52)
1/ m
¦ ai µ
B i § ¶
, i 1, 2, 3. (2.55)
¨ ai –1 ·
Example 2.28 Using Graeffes method, find the real roots of the equation
x3 6x2 + 11x 6 = 0
Let
f (x) = x3 6x2 + 11x 6 = 0 (i)
then
f (x) = x3 6x2 11x 6 = 0
therefore,
f (x) f (x) = (1)3 (x6 14x4 + 49x2 36)
let
f (x) = z3 14z2 + 49z 36, where z = x2.
Hence, roots of f (x) = 0 are given by
36 49
= 0.857, = 1.871 and 14 = 3.742
49 14
Now,
f (z) = z3 14z2 49z 36
Therefore,
f (z) f (z) = (1)3(z6 98z4 + 1393z2 1296)
Setting f (u) = u3 98u2 + 1393u 1296, we obtain the next approximation
to the roots of f (x) = 0 as
1/ 4 1/ 4
⎛ 1296 ⎞ ⎛ 1393 ⎞ 1/ 4
⎜ ⎟ = 0.9822, ⎜ ⎟ = 1.942 and (98) = 3.147.
⎝ 1393 ⎠ ⎝ 98 ⎠
It is seen that the approximations are converging to the actual roots 1, 2
and 3, respectively.
56 CHAPTER 2: Solution of Algebraic and Transcendental Equations
b2 = a2 rb3,
(2.58)
b1 = a1 rb2 sb3,
b0 = a0 sb2
From Eq. (2.58), we see that the bi are functions of both r and s. If the
factor x2 + rx + s is exact, i.e., if x2 + rx + s divides exactly the function f (x),
then we must have
b0 = b1 = 0
i.e.,
b0(r, s) = 0 and b1(r, s) = 0 (2.59)
Now, by Taylors theorem,
vb0 vb
b0 (r , s ) b0 ( r0 , s0 ) 'r0 0 's0 0 (2.60)
vr vs
and
vb1 vb
b1 (r , s ) b1 (r0 , s0 ) 'r0 1 's0 0, (2.61)
vr vs
where the higher order partial derivatives are neglected and the first order
partial derivatives are calculated at the point (r0, s0).
If the initial approximation (r 0, s 0) is assumed, then a correction
(Dr0, Ds0) can be computed from Eqs. (2.60) and (2.61), so that we have the
next approximation as
SECTION 2.10: LinBairstows Method 57
123
(2.62)
and s1 = s0 + Ds0
For the next approximation, we take r0 = r1 and s0 = s1, and proceed as
above.
Example 2.29 Find a quadratic factor of the polynomial
f (x) = x3 x 1.
We have
a3 = 1, a2 = 0, a1 = 1, a0 = 1
Let
r0 = s0 = 1.0.
Then,
b3 = a3,
b2 = a2 rb3 = a2 ra3,
b1 = a1 rb2 sb3 = a1 r(a2 ra3) sa3
= a1 ra2 + r2a3 sa3
b0 = a0 sb2 = a0 s(a2 ra3)
= a0 sa2 + sra3
Therefore,
∂b0 ∂b0
= sa3 , = − a2 + ra3
∂r ∂s
∂b1 ∂b
= – a2 + 2ra3 , 1 = – a3 .
∂r ∂s
Then, Eqs. (2.60) and (2.61) give
Dr0 + Ds0 = 0
and
2Dr0 Ds0 = 1.
Hence,
1
Dr0 = = 0.3333
3
and
1
Ds0 = = 0.3333.
3
It follows that
1
r1 = r0 + Dr0 = 1 + = 1.3333,
3
and
1
s1 = s0 + Ds0 = 1 = 0.6667.
3
58 CHAPTER 2: Solution of Algebraic and Transcendental Equations
¥
3
kr (2.65)
bi
r 1 xri 1
SECTION 2.11: QuotientDifference Method 59
D0 Q1 D1 Q2 D2 Q3 D3
(1)
Q1 0 0
(1) (0)
0 D1 D2 0
(2) (1) (0)
Q1 Q2 Q3
(2) (1)
0 D1 D2 0
(3) (2) (1)
Q1 Q2 Q3
When the first two rows are known, the other rows can be constructed by
using Eqs. (2.69) and (2.70) alternately. The quantities Q1(i ) , Q2(i ) and Q3(i )
tend to the reciprocals of the roots of f (x) = 0. Hence, instead of Eq. (2.63),
if we consider the transformed equation
a3x3 + a2x2 + a1x + a0 = 0 (2.71)
60 CHAPTER 2: Solution of Algebraic and Transcendental Equations
and proceed as above, we obtain directly the roots of Eq. (2.63). This procedure
is illustrated in the following example.
Example 2.30 Using the QD method, find the roots of the cubic equation
f (x) = x3 9x2 + 26x 24 = 0.
To compute the roots directly, we consider the transformed equation
24x3 + 26x2 9x + 1 = 0.
We then have
( 24x3 + 26x2 9x + 1)(b0 + b1x + b2x2 + b3x3 + L) = 1.
Comparing the coefficients of like powers of x on both sides of the above
equation, we obtain
b0 = 1; 9b0 + b1 = 0;
b2 9b1 + 26b0 = 0;
b3 9b2 + 26b1 24b0 = 0
The above relations give
b0 = 1, b1 = 9, b2 = 55 and b3 = 285,
so that
b1
9 Q1(1)
b0
b2 55
= = 6.1111 = Q1(2)
b1 9
and
b3 285
5.1818 Q1(3) .
b2 55
We obtain the differences
D1(1) = Q1(2) − Q1(1) = – 2.8889,
and
D1(2) Q1(3) Q1(2) – 0.9293.
We have thus computed all the elements in the first two rows of Table 2.1.
This enables us to use Eqs. (2.69) and (2.70) alternately to generate the
quotients and differences row by row.
To compute D1(2) , we use the elements
D1(1)
Q1(2) Q2(1)
D1(2)
where
D1(2) Q1(2) D1(1) Q2(1)
Hence
– 0.9293 t 2.4616
D1(2) – 0.4415.
5.1818
Similarly,
(0.9231)2
D2(1) – – 0.4355.
1.9658
Next row is a row of quotients. We have Q1(3) = 5.1818.
Also,
Q2(2) = 1.9658 − 0.4335 + 0.9293
= 2.4616,
and
Q3(1) = 0.9231 − 0.4335
= 1.3566.
Proceeding in this way, the following table of quotients and differences
is formed (Table 2.2).
Table 2.2 Solution of Example 2.30
D0 Q1 D1 Q2 D2 Q3 D3
9 0 0
0 –2.8889 –0.9231
6.1111 1.9658 0.9231
0 –0.9293 –0.4335 0
5.1818 2.4616 1.3566
0 –0.4415 –0.2389 0
4.7403 2.6642 1.5955
0 –0.2481 –0.1431 0
4.4922 2.7692 1.7386
0 –0.1529 –0.0898 0
4.3393 2.8323 1.8284
–0.0998 –0.0580 0
4.2395 2.8741 1.8864
62 CHAPTER 2: Solution of Algebraic and Transcendental Equations
It can be seen that Q1, Q2 and Q3 are converging to the actual values 4, 3 and
2, respectively.
123
(2.72)
and g(x, y) = 0
As in the case of a single equation, we assume that Eq. (2.72) may be written
in the form
x = F(x, y), y = G(x, y), (2.73)
where the functions F and G satisfy the following conditions in a closed
neighbourhood R of the root (a, b):
(i) F and G and their first partial derivatives are continuous in R, and
vF vF vG vG
(ii) 1 and 1, (2.74)
vx vy vx vy
for all (x, y) in R.
If (x0, y0) is an initial approximation to the root (a, b ), then Eq. (2.73) give
the sequence
1442443
1 ∂G ∂G 2 y
G ( x, y ) = ( y 2 + 4), = 0, = .
5 ∂x ∂y 5
Let (0.5, 0.5) be an approximate root. Then
vF vF 6 xy 3x 2
vx vy 10 (0.5, 0.5) 10
(0.5, 0.5)
0.15 0.075 1
and
vG vG 2y
0.2 1.
vx vy 5 0.5
Hence the conditions for convergence are satisfied and the approximations
are given by
1 ⎡ 1
xn +1 = 3 yn xn2 + 7 ⎤ and yn +1 = ⎡ yn2 + 4 ⎤ .
10 ⎣ ⎦ 5⎣ ⎦
We obtain successively with x0 = 0.5 and y0 = 0.5
1 ⎡3 ⎤ 1 ©1 ¸
x1 = ⎢ + 7 ⎥ = 0.7375; y1 4¹ 0.85
10 ⎣ 8 ⎦ 5 ª« 4 º
1© 1
x2 3(0.85)(0.7375)2 7¸ y2 = ⎡ (0.85) 2 + 4 ⎤ = 0.9445
10 « º 5⎣ ⎦
0.8387;
1 © 1
x3 3(0.8387)2 (0.9445) 7¸º y3 = ⎡ (0.9445) 2 + 4 ⎤ = 0.9784.
10 « 5⎣ ⎦
0.8993;
x5 = 0.9613, y5 = 0.9966
x6 = 0.9763, y6 = 0.9986
x7 = 0.9855, y7 = 0.9994.
Convergence to the root (1, 1) is obvious.
2.12.2 Newton–Raphson Method
Let (x 0, y0) be an initial approximation to the root of Eq. (2.72). If
(x0 + h, y0 + k) is the root of the system, then we must have
f (x0 + h, y0 + k) = 0, g(x0 + h, y0 + k) = 0 (2.77)
Assuming that f and g are sufficiently differentiable, we expand both the
functions in Eq. (2.77) by Taylors series to obtain
∂f ∂f
1442443
f0 + h +k +" = 0
∂x0 ∂y0
(2.78)
vg vg
g0 h k " 0,
vx0 v y0
where
∂f ⎡ ∂f ⎤
= , f 0 = f ( x0 , y0 ), etc.
∂x0 ⎢⎣ ∂x ⎥⎦ x = x0
Neglecting the second and higher-order derivative terms, we obtain the following
system of linear equations:
∂f ∂f
1442443
h +k = – f0
∂x0 ∂y0
(2.79)
∂g ∂g
and h +k = – g0
∂x0 ∂y0
Equation (2.79) possesses a unique solution if
∂f ∂f
∂x0 ∂y0
D= ≠ 0. (2.80)
∂g ∂g
∂x0 ∂y0
By Cramers rule, the solution of Eq. (2.79) is given by
∂f ∂f
– f0 – f0
1 ∂y0 1 ∂x0
h= and k = (2.81)
D ∂g D ∂g
– g0 – g0
∂y0 ∂x0
SECTION 2.12: Solution to Systems of Nonlinear Equations 65
Therefore,
–5.3988 2.0074
D= = 16.8712.
0 –3.125
Hence,
1 – 0.7019 2.0074
h 0.1528,
16.8712 – 0.1914 –3.125
and
1 –5.3918 – 0.7019
k 0.0612.
16.8712 0 – 0.1914
It follows that
x2 = 0.8180 + 0.1528 = 0.9708
and
y2 = 0.9375 + 0.0612 = 0.9987
It follows, therefore,
x1 = 0.7071 + 0.0858 = 0.7858,
and
y1 = 0.7071 0.0858 = 0.6213.
The process can be repeated to obtain a better approximation.
Eliminating x between the two given equations, we obtain the quadratic
for y
y2 + y 1 = 0,
which gives y = 0.6180 for the first quadrant solution.
Then x = 0.7861. These values may be compared with the solution
(x1, y1) obtained above.
EXERCISES
2.1 Explain the bisection method for finding a real root of the equation
f (x) = 0 and write an algorithm for its implementation with a test for
relative accuracy of the approximation.
Obtain a root, correct to three decimal places, of each of the following
equations using the bisection method (Problems 2.22.5):
2.2 x3 4x 9 = 0
2.3 x3 + x2 1 = 0
2.4 5x log10 x 6 = 0
2.5 x2 + x cos x = 0
2.6 Give the sequence of steps in the regulafalsi method for determining
a real root of the equation f (x) = 0.
Use the method of false position to find a real root, correct to three decimal
places, of the following equations (Problems 2.72.10):
2.7 x3 + x2 + x + 7 = 0
2.8 x3 x 4 = 0
2.9 x = 3ex
2.10 x tan x + 1 = 0
2.11 Find the real root, which lies between 2 and 3, of the equation
x log10 x 1.2 = 0
using the methods of bisection and falseposition to a tolerance of
0.5%.
2.12 Explain briefly the method of iteration to compute a real root of the
equation f (x) = 0, stating the condition of convergence of the sequence
of approximations. Give a graphical representation of the method.
Use the method of iteration to find, correct to four significant figures, a real
root of each of the following equations (Problems 2.132.16):
2.13 ex = 3x
1
2.14 x =
( x + 1)2
2.15 1 + x2 = x3
1
2.16 x sin x =
2
2.17 Establish an iteration formula to find the reciprocal of a positive number
N by NewtonRaphson method. Hence find the reciprocal of 154 to
four significant figures.
EXERCISES 69
Find the real roots of the following equations using Graeffes root-squaring
method (Problems 2.352.36):
2.35 x3 4x2 + 5x 2 = 0
2.36 x3 2x2 5x + 6 = 0
2.37 Find a quadratic factor of the polynomial
f (x) = x3 2x2 + x 2
by Bairstows method with two approximations starting with r0 = 0.5
and s0 = 1.
2.38 Determine a quadratic factor, nearer to x2 1.5x + 1.5, of the polynomial
f (x) = x4 8x3 + 39x2 62x + 50
by Bairstows method. Give the computational steps of this method.
2.39 Using the Q-D method, find the real roots of the equation
f (x) = x3 6x2 + 11x 6 = 0
2.40 In the notation of Section 2.11, prove the following results:
b 1
i(a) lim i =
i →∞ bi −1 x1
1
Q1(i )
x1 1 k2 ¦ x µ
i(b) lim 1 1¶
i ne ¦ x1 µ
i §
x1 k1 ¨ x2 ·
§¨ x ¶·
2
1
Q1(i 1)
x1 1 k2 ¦ x µ
(c) lim § 1 1¶.
i ne ¦ x1 µ
i x2 k1 ¨ x2 ·
§¨ x ¶·
2
f ′( x) f ′′( x) f ( x) f ′′( x)
(a) <1 (b) <1
[ f ( x) ]
2
[ f ′( x)]2
f ( x) f ′( x)
(c) <1 (d) None of these.
[ f ′′( x)]2
2.47 Which one of the following is not correct?
(a) NewtonRaphson method has quadratic convergence.
(b) The bisection method converges slowly.
(c) To solve f (x) = 0 by iteration method, the given equation is written in
the form x = f (x) where | f ¢(x)| < 1 in an interval containing the root.
(d) The method of regulafalsi converges faster than the secant method.
2.48 Which one of the following is correct?
(a) The bisection method has quadratic convergence.
(b) The iteration method is a self-correction method.
(c) The equation x3 2x 5 = 0 has two positive roots.
(d) The equation x = cos x can be solved by Graeffes method.
Answers to Exercises
2.21 0.3574
2.22 With x0 = 0.5, x1 = 0.6470, x2 = 0.65656,
2.23 With x0 = 0.5, x1 = 0.5180, x2 = 0.5180,
2.24 x0 = 1.047, x1 = 0.6224, x2 = 0.6071, x3 = 0.6071.
2.25 2.798
2.27 1.8437; 1.8438
b1 b2
2.28 = 0.54546, = 0.77647,
b2 b3
b3
b4
= 0.88696,
b4
b5
0.94237, |
Smallest root is 1.
2.29 Convergents are:
1.0, 0.5, 0.66666, 0.75, 0.66666, 0.66666, 0.69231, 0.68421,
2.30 Convergents are:
0.5, 0.5, 0.51064, 0.51087, 0.51097,
Required root is 0.5110.
2.31 Root = 6.85236.
2.32 Fifth iteration value = 0.567143
2.33 Regulafalsi: 2.0945 in 7 iterations.
Secant method: 2.0946.
2.34 (a) 2.09462409 (b) 0.51752
2.35 Third approximation to the roots: 0.9168, 1.0897, 2.0019
2.36 Third approximation: 3.014443, 1.991425, 0.999494.
2.37 x2 0.0165x + 0.9394 (Exact factor is x2 + 1).
2.38 x2 1.9485x + 1.942982 (Exact factor is x2 2x + 2).
2.39 Q1 » 3.13145, Q2 » 1.898, Q3 » 0.9706.
2.42 x1 = 0.8261, y1 = 0.5636.
2.43 x0 = 3, y0 = 2, x1 = 3.1667, y1 = 2.5
2.44 x = 3.584, y = 1.848
2.45 (b)
2.46 (b)
2.47 (d)
2.48 (a)
Chapter
Interpolation
3.1 INTRODUCTION
The statement
y = f (x), x0 £ x £ xn
means: corresponding to every value of x in the range x0 £ x £ xn, there
exists one or more values of y. Assuming that f (x) is single-valued and
continuous and that it is known explicitly, then the values of f (x) corresponding
to certain given values of x, say x0, x1,
, xn can easily be computed and
tabulated. The central problem of numerical analysis is the converse one:
Given the set of tabular values (x0, y0), (x1, y1), (x2, y2),
, (xn, yn) satisfying
the relation y = f (x) where the explicit nature of f (x) is not known, it is
required to find a simpler function, say f (x), such that f (x) and f (x) agree
at the set of tabulated points. Such a process is called interpolation. If f (x)
is a polynomial, then the process is called polynomial interpolation and
f (x) is called the interpolating polynomial. Similarly, different types of
interpolation arise depending on whether f (x) is a finite trigonometric series,
series of Bessel functions, etc. In this chapter, we shall be concerned with
polynomial interpolation only. As a justification for the approximation of an
unknown function by means of a polynomial, we state here, without proof,
a famous theorem due to Weierstrass (1885): if f (x) is continuous in
x0 £ x £ xn, then given any e > 0, there exists a polynomial P (x) such that
73
74 CHAPTER 3: Interpolation
This means that it is possible to find a polynomial P (x) whose graph remains
within the region bounded by y = f (x) e and y = f (x) + e for all x between
x0 and xn, however small e may be.
When approximating a given function f (x) by means of polynomial f (x),
one may be tempted to ask: (i) How should the closeness of the approximation
be measured? and (ii) What is the criterion to decide the best polynomial
approximation to the function? Answers to these questions, important though
they are for the practical problem of interpolation, are outside the scope of
this book and will not be attempted here. We will, however, derive in the
next section a formula for finding the error associated with the approximation
of a tabulated function by means of a polynomial.
and L is to be determined such that Eq. (3.2) holds for any intermediate
value of x, say x = x¢, x0 < x¢ < xn. Clearly,
y ( x b ) Gn ( x b ) (3.4)
L .
3n1 ( x b )
We construct a function F(x) such that
F(x) = y(x) fn(x) LPn+1(x), (3.5)
where L is given by Eq. (3.4) above,
It is clear that
F(x0) = F(x1) = L = F(xn) = F(x¢) = 0,
that is, F (x) vanishes (n + 2) times in the interval x0 £ x £ xn; consequently,
by the repeated application of Rolles theorem (see Theorem 1.3, Section 1.2),
F¢(x) must vanish (n + 1) times, F¢¢(x) must vanish n times, etc., in the
interval x0 £ x £ xn. In particular, F ( n +1) ( x) must vanish once in the interval.
SECTION 3.3: Finite Differences 75
Let this point be given by x = x, x0 < x < xn. On differentiating Eq. (3.5)
(n + 1) times with respect to x and putting x = x, we obtain
0 = y(n+1)(x) L(n + 1)!
so that
y ( n +1) (Y ) (3.6)
L= .
(n + 1)!
Comparison of Eqs. (3.4) and (3.6) yields the results
y (n1) (Y )
y ( x b ) Gn ( x b ) 3n1 ( x b ).
(n 1)!
Dropping the prime on x′, we obtain
3 n 1 ( x) ( n 1)
y ( x ) Gn ( x) y (Y ), x0 < Y < xn , (3.7)
( n 1)!
which is the required expression for the error. Since y (x) is, generally,
unknown and hence we do not have any information concerning y(n+1)(x),
formula (3.7) is almost useless in practical computations. On the other hand,
it is extremely useful in theoretical work in different branches of numerical
analysis. In particular, we will use it to determine errors in Newtons interpolating
formulae which will be discussed in Section 3.6.
Thus,
x y0 D D2 D3 D4 D5 D6
x0 y0
Dy0
x1 y1 D2y0
Dy1 D3y0
x2 y2 D2y1 D4y0
3
Dy2 D y1 D5y0
x3 y3 D2y2 D4y1 D6y0
3 5
Dy3 D y2 D y1
x4 y4 D2y3 D4y2
Dy4 D3y3
x5 y5 D2y4
Dy5
x6 y6
x y D D2 D3 D4 D5 D6
x0 DEL(0, 0)
DEL(1, 0)
x1 DEL(0, 1) DEL(2, 0)
DEL(1, 1) DEL(3, 0)
x2 DEL(0, 2) DEL(2, 1) DEL(4, 0)
DEL(1, 2) DEL(3, 1) DEL(5, 0)
x3 DEL(0, 3) DEL(2, 2) DEL(4, 1) DEL(6, 0)
DEL(1, 3) DEL(3, 2) DEL(5, 1)
x4 DEL(0, 4) DEL(2, 3) DEL(4, 2)
DEL(1, 4) DEL(3, 3)
x5 DEL(0, 5) DEL(2, 4)
DEL(1, 5)
x6 DEL(0, 6)
In Table 3.2
DEL(4, 0) = DEL(3, 1) DEL(3, 0)
= DEL(2, 2) DEL(2, 1) [DEL(2, 1) DEL(2, 0)]
= DEL(1, 3) DEL(1, 2) 2[DEL(1, 2) DEL(1, 1)]
+ DEL(1, 1) DEL(1, 0)
= DEL(0, 4) DEL(0, 3) 3[DEL(0, 3) DEL(0, 2)]
+3[DEL(0, 2) DEL(0, 1)] [DEL(0, 1) DEL(0, 0)]
= DEL(0, 4) 4DEL(0, 3) + 6DEL(0, 2) 4DEL(0, 1) + DEL(0, 0)
= y4 4y3 + 6y2 4y1 + y0
The forward difference table can now be formed by the simple statements:
Do i = 1(1)n
Do j = 0(1)n i
DEL(i, j) = DEL(i 1, j + 1) DEL(i 1, j)
Next j
Next i
End
Thus, we obtain
Ñ2y2 = Ñy2 Ñy1
= y2 y1 (y1 y0) = y2 2y1 + y0,
Ñ y3 = Ñ2y3 Ñ2y2
3
x y ∇ ∇2 ∇3 ∇4 ∇5 ∇6
x0 y0
x1 y1 ∇y 1
x2 y2 ∇y 2 ∇2y 2
x3 y3 ∇y 3 ∇2y 3 ∇3y 3
2
x4 y4 ∇y 4 ∇ y4 ∇3y 4 ∇4y 4
x5 y5 ∇y 5 ∇2y 5 ∇3y 5 ∇ 4y 5 ∇ 5y 5
x6 y6 ∇y 6 ∇2y 6 ∇3y 6 ∇ 4y 6 ∇ 5y 6 ∇ 6y 6
x y δ δ2 δ3 δ4 δ5 δ6
x0 y0
δ y 1/2
x1 y1 δ 2y1
δ y 3/2 δ 3y 3/2
x2 y2 δ 2y 2 δ 4y 2
δ y 5/2 3
δ y 5/2 δ 5y 5/2
2 4
x3 y3 δ y3 δ y3 δ 6y 3
δ y 7/2 3
δ y 7/2 5
δ y 7/2
x4 y4 δ 2y 4 δ 4y 4
δ y 9/2 δ 3y 9/2
2
x5 y5 δ y5
δ y 11/2
x6 y6
SECTION 3.3: Finite Differences 79
It is clear from all the four tables that in a definite numerical case, the
same numbers occur in the same positions whether we use forward, backward
or central differences. Thus, we obtain
'y0 = ∇y1 = E y1/2 , '3 y2 3 y5 E 3 y7/2 , !
'3 y0 = ( E − 1)3 y0 = ( E 3 − 3E 2 + 3E − 1) y0 = y3 − 3 y2 + 3 y1 − y0 .
From the definitions, the following relations can easily be established:
∇ = 1 − E −1, ⎫
⎪
1/2
E =E −E −1/2
, ⎪
⎪ (3.8b)
−1/2
⎬
N = (1/2) ( E + E ), N = 1 + (1/4) E ⎪
1/2 2 2
⎪
' = ∇E = E E1/2 . ⎪
⎭
*The student should note that Eq. (3.8a) does not mean that the operators E
and D have any existence as separate entities; it merely implies that the effect of
the operator E on y0 is the same as that of the operator (1 + D) on y0.
80 CHAPTER 3: Interpolation
Using the relation (3.8a), a number of useful identities can be derived. This
relation is used to separate the effect of E into that of the powers of D and
this method of separation is called the method of separation of symbols. The
following examples demonstrate the use of this method.
Example 3.1 Using the method of separation of symbols, show that
n (n − 1)
' n u x − n = u x − nu x −1 + u x − 2 + " + (−1) n u x − n .
2
To prove this result, we start with the right-hand side. Thus,
n (n − 1)
u x − nu x −1 + u x − 2 + " + (−1)n u x − n
2
n ( n − 1) −2
= u x − nE −1u x + E u x + " + ( −1) n E − n u x
2
⎡ n ( n − 1) −2 ⎤
= ⎢1 − nE −1 + E + " + ( −1) n E − n ⎥ u x
⎣ 2 ⎦
= (1 − E −1 ) n u x
n
⎛ 1⎞
= ⎜1 − ⎟ u x
⎝ E⎠
n
⎛ E −1⎞
=⎜ ⎟ ux
⎝ E ⎠
'n
= ux
En
= ' n E −nux
= ' nu x−n ,
⎛ x2 E 2 ⎞
= ⎜1 + xE + + " ⎟ u0
⎜ 2! ⎟
⎝ ⎠
x2
= u0 + xu1 + u2 + " ,
2!
which is the required result.
Difference tables can be used to check errors in tabular values. Suppose that
there is an error of +1 unit in a certain tabular value. As higher differences
are formed, the error spreads out fanwise, and is at the same time, considerably
magnified, as shown in Table 3.5.
y Δ Δ2 Δ3 Δ4 Δ5
0
0
0 0
0 0
0 0 0
0 0 1
0 0 1
0 1 –5
0 1 –4
1 –3 10
1 –2 6
–1 3 –10
0 1 –4
0 –1 5
0 0 –1
0 0 –1
0 0 0
0 0
0 0
0
0
The term 271 in the fourth difference column has fluctuations of 449
and 452 on either side of it. Comparison with Table 3.5 suggests that there
is an error of 45 in the entry for x = 4. The correct value of y is therefore
4105 + 45 = 4150, which shows that the last-two digits have been transposed,
a very common form of error. The reader is advised to form a new difference
table with this correction, and to check that the third differences are now
practically constant.
If an error is present in a given data, the differences of some order will
become alternating in sign. Hence, higher-order differences should be formed
till the error is revealed as in the above example. If there are errors in several
tabular values, then it is not easy to detect the errors by differencing.
Thus the nth difference is a0n!hn, which is a constant. Hence, the (n + 1)th,
and higher differences of a polynomial of nth degree will be zero. Conversely,
if the nth differences of a tabulated function are constant and the (n + 1)th,
(n + 2)th,
, differences all vanish, then the tabulated function represents a
polynomial of degree n. It should be noted that these results hold good only
if the values of x are equally spaced. The converse is important in numerical
analysis since it enables us to approximate a function by a polynomial if its
differences of some order become nearly constant.
Given the set of (n + 1) values, viz., (x0, y0), (x1, y1), (x2, y2),
, (xn, yn),
of x and y, it is required to find yn(x), a polynomial of the nth degree such
that y and yn(x) agree at the tabulated points. Let the values of x be equidistant,
i.e. let
xi = x0 + ih, i = 0, 1, 2, ! , n.
Since yn(x) is a polynomial of the nth degree, it may be written as
yn ( x) = a0 + a1 ( x − x0 ) + a2 ( x − x0 ) ( x − x1 ) ⎫
⎪⎪
+ a3 ( x − x0 ) ( x − x1 ) ( x − x2 ) + " ⎬ (3.9)
⎪
+ an ( x − x0 ) ( x − x1 ) ( x − x2 )! ( x − xn −1 ). ⎪⎭
Imposing now the condition that y and yn(x) should agree at the set of
tabulated points, we obtain
y1 y0 'y0 '2 y '3 y 'n y
a0 y0 ; a1 ; a2 2 0 ; a3 3 0 ; "; an n 0 ;
x1 x0 h h 2! h 3! h n!
Setting x = x0 + ph and substituting for a0, a1,
, an, Eq. (3.9) gives
p ( p − 1) 2 p ( p − 1) ( p − 2) 3
yn ( x) = y0 + p 'y0 + ' y0 + ' y0 + "
2! 3!
p ( p − 1) ( p − 2) ! ( p − n + 1) n
+ ' y0 , (3.10)
n!
which is Newtons forward difference interpolation formula and is useful for
interpolation near the beginning of a set of tabular values.
To find the error committed in replacing the function y (x) by means of
the polynomial yn(x), we use Eq. (3.7) to obtain
( x − x0 ) ( x − x1 )! ( x − xn ) ( n +1)
y ( x) − yn ( x) = y (Y ), x0 Y xn (3.11)
(n + 1)!
As remarked earlier we do not have any information concerning y(n+1)(x), and
therefore, formula given in Eq. (3.11) is useless in practice. Nevertheless,
SECTION 3.6: Newtons Formulae for Interpolation 85
if y(n+1)(x) does not vary too rapidly in the interval, a useful estimate of the
derivative can be obtained in the following way. Expanding y(x + h) by
Taylors series (see Theorem 1.4), we obtain
h2
y ( x + h) = y ( x) + hy ′( x) +
y ′′( x ) + "
2!
Neglecting the terms containing h2 and higher powers of h, this gives
1 1
y ′( x) ≈
[ y ( x + h) − y ( x )] = 'y ( x).
h h
Writing y¢(x) as Dy(x) where D º d/dx, the differentiation operator, the above
equation gives the operator relation
1 n +1 1
D ≡ ' and so D ≡ n+1 ' n +1.
h h
We thus obtain
1
y ( n+1) ( x) ≈ n +1
' n+1 y ( x). (3.12)
h
Equation (3.11) can, therefore, be written as
p ( p − 1) ( p − 2)! ( p − n) n +1
y ( x ) − yn ( x ) = ' y (Y ) (3.13)
(n + 1)!
in which form it is suitable for computation.
Instead of assuming yn(x) as in Eq. (3.9), if we choose it in the form
yn ( x) = a0 + a1 ( x − xn ) + a2 ( x − xn ) ( x − xn −1 )
+ a3 ( x − xn ) ( x − xn −1 ) ( x − xn− 2 ) + "
+ an ( x − xn ) ( x − xn −1 ) …( x − x1 ).
and then impose the condition that y and yn(x) should agree at the tabulated
points xn, xn1,
, x2, x1, x0, we obtain (after some simplification)
p ( p + 1) 2 p ( p + 1) … ( p + n −1) n
yn ( x) = yn + p∇yn + ∇ yn + " + ∇ yn , (3.14)
2! n!
where p = (x xn)/h.
This is Newtons backward difference interpolation formula and it uses
tabular values to the left of yn. This formula is therefore useful for interpolation
near the end of the tabular values.
It can be shown that the error in this formula may be written as
p ( p + 1) ( p + 2)! ( p + n) n +1
y ( x ) − yn ( x ) = ∇ y (Y ), (3.15)
(n + 1)!
where x0 < x < xn and x = xn + ph.
86 CHAPTER 3: Interpolation
⎛ x −1 ⎞⎛ x −1 ⎞ ⎛ x −1 ⎞ ⎛ x −1 ⎞⎛ x −1 ⎞
⎜ ⎟⎜ − 1⎟ ⎜ ⎟⎜ −1⎟⎜ − 2⎟
x −1
(96) + ⎝
2 ⎠⎝ 2 ⎠ (120) + ⎝ 2 ⎠ ⎝ 2 ⎠⎝ 2 ⎠ (48)
y ( x) = 24 +
2 2 6
= x3 + 6 x 2 + 11x + 6.
Sn = 13 + 23 + 33 + " + n3.
We have
Sn +1 = 13 + 23 + 33 + " + n3 + ( n + 1)3
Hence
Sn +1 − Sn = (n + 1)3 ,
SECTION 3.6: Newtons Formulae for Interpolation 87
or
'Sn = (n + 1)3 . (i)
It follows that
(n − 1) (n − 2) ( n − 1) (n − 2) (n − 3)
Sn = 1 + (n − 1) (8) + (19) + (18)
2 6
(n − 1) (n − 2) ( n − 3) (n − 4)
+ (6)
24
1 4 1 3 1 2
= n + n + n
4 2 4
2
⎡ n (n + 1) ⎤
=⎢ ⎥ .
⎣ 2 ⎦
Example 3.6 Values of x (in degrees) and sin x are given in the following
table:
x (in degrees) sin x
15 0.2588190
20 0.3420201
25 0.4226183
30 0.5
35 0.5735764
40 0.6427876
0.4 ( 0.4 1)
y (38) 0.6427876 0.4 (0.0692112) ( 0.0043652)
2
( 0.4) ( 0.4 1) ( 0.4 2)
( 0.0005599)
6
( 0.4) ( 0.4 1) ( 0.4 2) (0.4 3)
(0.0000289)
24
( 0.4) ( 0.4 1) ( 0.4 2) (0.4 3) ( 0.4 4)
(0.0000041)
120
0.6427876 0.02768448 0.00052382 0.00003583 0.00000120
0.6156614.
x y
0 1
1 3
2 9
3 –
4 81
Since four points are given, the given data can be approximated by a
third degree polynomial in x. Hence D4y0 = 0. Substituting D = E 1 and
simplifying, we get
E 4 y0 − 4 E 3 y0 + 6 E 2 y0 − 4 Ey0 + y0 = 0.
Since E r y0 = yr, the above equation becomes
y4 − 4 y3 + 6 y2 − 4 y1 + y0 = 0.
Substituting for y0, y1, y2 and y4 in the above, we obtain
y3 = 31.
x
The tabulated function is 3 and the exact value of y (3) is 27. The error is
due to the fact that the exponential function 3x is approximated by means of
a polynomial in x of degree 3.
Example 3.8 The table below gives the values of tan x for 0.10 £ x £ 0.30:
x y = tan x
0.10 0.1003
0.15 0.1511
0.20 0.2027
0.25 0.2553
0.30 0.3093
Find : (a) tan 0.12 (b) tan 0.26, (c) tan 0.40 and (d) tan 0.50.
The table of difference is
x y Δ Δ2 Δ3 Δ4
0.10 0.1003
0.0508
0.15 0.1511 0.0008
0.0516 0.0002
0.20 0.2027 0.0010 0.0002
0.0526 0.0004
0.25 0.2553 0.0014
0.0540
0.30 0.3093
(a) To find tan (0.12), we have 0.12 = 0.10 + p(0.05), which gives p = 0.4.
Hence, Eq. (3.10) gives
0.4 (0.4 − 1)
tan (0.12) = 0.1003 + 0.4 (0.0508) + (0.0008)
2
0.4(0.4 − 1) (0.4 − 2)
+ (0.0002)
6
0.4(0.4 − 1) (0.4 − 2) (0.4 − 3)
+ (0.0002)
24
= 0.1205.
90 CHAPTER 3: Interpolation
(b) To find tan (0.26), we have 0.26 = 0.30 + p(0.05), which gives
p = 0.8. Hence, Eq. (3.14) gives
0.8 ( 0.8 1)
tan (0.26) 0.3093 0.8 (0.0540) (0.0014)
2
0.8 (0.8 1) (0.8 2)
(0.0004)
6
0.8 (0.8 1) (0.8 2) ( 0.8 3)
(0.0002)
24
0.2662.
Proceeding as in the case (i) above, we obtain
(c) tan (0.40) = 0.4241, and
(d) tan (0.50) = 0.5543.
The actual values, correct to four decimal places, of tan (0.12), tan (0.26),
tan (0.40) and tan (0.50) are respectively 0.1206, 0.2660, 0.4228 and 0.5463.
Comparison of the computed and actual values shows that in the first-two
cases (i.e. of interpolation) the results obtained are fairly accurate whereas
in the last-two cases (i.e. of extrapolation) the errors are quite considerable.
The example therefore demonstrates the important result that if a tabulated
function is other than a polynomial, then extrapolation very far from the table
limits would be dangerousalthough interpolation can be carried out very
accurately.
The differences used in this formula lie on the line shown in Table 3.6.
The formula is, therefore, of the form
where G1, G2,
have to be determined. The yp on the left side can be
expressed in terms of y0, Dy0 and higher-order differences of y0, as follows:
x y Δ Δ2 Δ3 Δ4 Δ5 Δ6
x −3 y −3
Δy −3
x −2 y −2 Δ 2 y −3
Δy −2 Δ 3 y −3
2
x −1 y −1 Δ y −2 Δ 4 y −3
3
Δy −1 Δ y −2 Δ 5 y −3
2 4
x0 y0 Δ y −1 Δ y −2 Δ 6 y −3
Δy 0 3 5
Δ y −1 Δ y −2
x1 y1 Δ2 y 0 Δ4 y −1
Δy1 Δ3 y 0
2
x2 y2 Δ y1
Δy 2
x3 y3
Clearly,
y p = E p y0
p ( p − 1) 2 p ( p − 1) ( p − 2) 3
= y0 + p 'y0 + ' y0 + ' y0 + "
2! 3!
Similarly, the right side of Eq. (3.16) can also be expressed in terms of y0, Dy0
and higher-order differences. We have
= ' 2 (1 + ')−1 y0
= ' 4 (1 + ')−2 y0
p ( p − 1) 2 p ( p − 1) ( p − 2) 3
y0 + p'y0 + ' y0 + ' y0
2! 3!
p ( p − 1) ( p − 2) ( p − 3) 4
+ ' y0 + "
4!
Equating the coefficients of Dy0, D2y0, D3y0, etc., on both sides of Eq. (3.17),
we obtain
G1 = p, ⎫
⎪
p ( p − 1) ⎪
G2 = , ⎪
2! ⎪
⎪
( p + 1) p ( p − 1) ⎬ (3.18)
G3 = , ⎪
3! ⎪
⎪
( p + 1) p ( p − 1) ( p − 2) ⎪
G4 = .⎪
4! ⎭
x y Δ Δ2 Δ3 Δ4 Δ5 Δ6
# #
x −1 y −1
Δy −1 Δ 3 y −2 Δ 5 y −3
x0 y0 Δ2 y −1 Δ 4 y −2 Δ 6 y −3
Δy 0 3 5
Δ y −1 Δ y −2
x1 y1
# #
We have
1.17 = 1.15 + p (0.05),
94 CHAPTER 3: Interpolation
which gives
0.02 1
= .p=
0.05 4
The difference table is given below.
x ex Δ Δ2 Δ3 Δ4
1.00 2.7183
0.1394
1.05 2.8577 0.0071
0.1465 0.0004
1.10 3.0042 0.0075 0
0.1540 0.0004
1.15 3.1582 0.0079 0
0.1619 0.0004
1.20 3.3201 0.0083 0.0001
0.1702 0.0005
1.25 3.4903 0.0088
0.1790
1.30 3.6693
= 3.2221.
p 2 ( p 2 − 1) 4
+ ' y−2 + " (3.21)
4!
Formula given in Eq. (3.21) is called Stirlings formula.
# #
x −1 y −1
# #
x0 y0 Δ2 y −1 Δ 4 y −2 Δ 6 y −3
– – – –
2 4 6
x1 y1 Δ y0 Δ y −1 Δ y −2
yp = E0 y0 + E2 ' 2 y−1 + E4 ' 4 y−2 + " + F0 y1 + F2 ' 2 y0 + F4 ' 4 y−1 + " (3.25)
The coefficients E0 , F0 , E2 , F2 , E4 , F4 , ! can be determined by the same
method as in the preceding cases, and we obtain
E0 = 1 − p = q, F0 = p, ⎫
2 2
⎪
q (q − 1 ) p ( p 2 − 12 ) ⎪
E2 = , F2 = , ⎪
3! 3! ⎪ (3.26)
2 ⎬
q (q 2 − 12 ) (q 2 − 22 ) 2 2 2
p ( p −1 ) ( p − 2 ) ⎪
E4 = , F4 = ,⎪
5! 5!
⎪
# # ⎪⎭
q (q 2 − 12 ) 2 q (q 2 − 12 ) (q 2 − 22 ) 4 ⎫
yp = qy0 + ' y− 1 + ' y−2 + " ⎪
3! 5! ⎪ (3.27)
⎬
2 2 2 2 2 2
p ( p −1 ) 2 p ( p −1 ) ( p − 2 ) 4 ⎪
+ py1 + ' y0 + ' y−1 + "⎪
3! 5! ⎭
where q = 1 p.
x y = ex
0.61 1.840431
0.62 1.858928
0.63 1.877610
0.64 1.896481
0.65 1.915541
0.66 1.934792
0.67 1.954237
0.61 1.840431
0.018497
0.62 1.858928 0.000185
0.018682 0.000004
0.63 1.877610 0.000189 –0.000004
0.018871 0
0.64 1.896481 0.000189 0.000002
0.019060 0.000002
0.65 1.915541 0.000191 0.000001
0.019251 0.000003
0.66 1.934792 0.000194
0.019445
0.67 1.954237
Clearly,
0.644 − 0.64
p= = 0.4.
0.01
The third difference contribution to both Stirlings and Bessels formulae is
negligible, and using Stirlings formula, we obtain
0.018871 + 0.019060 0.16
y (0.644) = 1.896481 + 0.4 + (0.000189)
2 2
= 1.896481 + 0.0075862 + 0.00001512
= 1.904082,
while Bessels formula gives
0.4(0.4 1) 0.000189 0.000191
y (0.644) 1.896481 0.4(0.019060)
2 2
1.896481 0.0076240 0.0000228
1.904082.
SECTION 3.8: Practical Interpolation 99
0.6 (0.36 1)
y (0.644) 0.6 (1.896481) (0.000189)
2
0.4 (0.16 1)
0.4 (1.915541) (0.000191)
2
1.1378886 0.000012096 0.7662164 0.000010696
1.904082.
In all the above cases, the value obtained is correct to six decimal places.
It is known from algebra that the nth degree polynomial which passes
through (n + 1) points is unique. Hence the various interpolation formulae
derived here are actually only different forms of the same polynomial. It,
therefore, follows that all the interpolation formulae should give the same
functional value. This is illustrated in the above example where we found that
the interpolated value of 0.644 is 1.904082 regardless of which formula is used.
Example 3.11 From the table of Example 3.10, find the value of ex when
x = 0.638, using Stirlings and Bessels formulae.
It was mentioned in Section 3.8 that Stirlings formula gives the most
accurate result for 1/4 £ p £ 1/4, and Bessels formula is most efficient for
1/4 £ p £ 3/4. In order to use these formulae, we therefore, have to choose
x0 so that p satisfies the appropriate inequality.
To use Stirlings formula, we choose x0 = 0.64 and xn = 0.638 so that
p = 0.2. Hence,
0.018871 + 0.019060 0.04
y (0.638) = 1.896481 − 0.2 ⋅ + (0.000189)
2 2
= 1.896481 − 0.0037931 + 0.0000038
= 1.892692,
which is correct to the last decimal place.
For Bessels formula, we choose x0 = 0.63, xn = 0.638 so that p = 0.8.
Hence, we obtain
0.8(0.8 − 1)
y (0.638) = 1.877610 + 0.8(0.018871) + (0.000189)
2
= 1.877610 + 0.0150968 − 0.0000151
= 1.892692, as before.
Example 3.12 The values of x and ex are given in the following table. Find
the value of ex when x = 1.7475.
100 CHAPTER 3: Interpolation
x y = e–x Δ Δ2 Δ3 Δ4
1.72 0.1790661479
–17817379
1.73 0.1772844100 177285
–17640094 –1762
1.74 0.1755204006 175523 13
–17464571 –1749
1.75 0.1737739435 173774 22
–17290797 –1727
1.76 0.1720448638 172047 15
–17118750 –1712
1.77 0.1703329888 170335
–16948415
1.78 0.1686381473
It should be noted that in writing the differences in the above table, the
zeros between the decimal point and the first significant digit to its right are
omitted. Thus, in the column of second differences, the number 173774
should be taken as 0.0000173774 in the computations.
To compute y (1.7475), we choose x0 = 1.74 and xp = 1.7475 so that
p = 3/4. We shall obtain the solution by using both Bessels and Everetts
formulae.
(i) If we use Bessels formula, the third differences need to be taken
into account since they exceed 60 units in magnitude. Hence Bessels
formula gives
3
y (1.7475) = 0.1755204006 − (0.0017464571)
4
(3/4)(3/4 − 1) 0.0000175523 + 0.0000173774
+
2 2
= 0.1742089218, as before .
SECTION 3.9: Interpolation with Unevenly Spaced Points 101
This example verifies the result of Section 3.7.5 that Everetts formula
turncated after second differences is equivalent to Bessels formula truncated
after third differences. When the fourth difference contribution becomes
significant (i.e. when they exceed 20 units in magnitude), Everetts formula
will be easier to apply since it uses only the even order differences.
x − x1 x − x0
L1( x) = y0 + y1
x0 − x1 x1 − x0
= l0 ( x) y0 + l1 ( x) y1
1
= ∑ li ( x) yi , (3.29)
i=0
where
x − x1 x − x0
l0 ( x) = and l1 ( x) = . (3.30)
x0 − x1 x1 − x0
102 CHAPTER 3: Interpolation
l0 ( x0 ) = 1, l0 ( x1 ) = 0, l1 ( x0 ) = 0, l1 ( x1 ) = 1.
⎧ 1, if i = j
li ( x j ) = ⎨ (3.31)
⎩ 0, if i ≠ j.
1
x−x x−x
∑ li ( x) = l0 ( x) + l1 ( x) = x0 − x11 + x1 − x00 = 1. (3.32)
i=0
( x − x1 ) ( x − x2 ) ( x − x0 ) ( x − x2 ) ( x − x0 ) ( x − x1 )
= y0 + y1 + y2 ,
( x0 − x1 ) ( x0 − x2 ) ( x1 − x0 ) ( x1 − x2 ) ( x2 − x0 ) ( x2 − x1 )
(3.33)
where the li(x) satisfy the conditions given in Eqs. (3.31) and (3.32).
To derive the general formula, let
Ln ( x) = a0 + a1 x + a2 x 2 + " + an x n (3.34)
be the desired polynomial of the nth degree such that conditions given in
Eq. (3.28) (called the interpolatory conditions) are satisfied. Substituting
these conditions in Eq. (3.34), we obtain the system of equations
y0 = a0 + a1 x0 + a2 x 02 + " + an x 0n ⎫
⎪
2 n ⎪
y1 = a0 + a1 x1 + a2 x 1 + " + an x 1 ⎪
⎪
y2 = a0 + a1 x2 + a2 x 22 + " + an x 2n ⎬ (3.35)
⎪
⎪
# ⎪
yn = a0 + a1 xn + a2 x n2 + " + an x nn . ⎪⎪⎭
SECTION 3.9: Interpolation with Unevenly Spaced Points 103
1 x0 x 02 " x 0n
1 x1 x 12 " x 1n
≠ 0. (3.36)
# # # #
1 xn x n2 " x nn
Ln ( x) 1 x x2 " xn
y0 1 x0 x 02 " x 0n
y1 1 x1 x 12 " x 1n = 0, (3.37)
# # # # #
yn 1 xn x n2 " x nn
which shows that Ln(x) is a linear combination of y0, y1, y2,
, yn. Hence
we write
n
Ln ( x) = ∑ li ( x) yi , (3.38)
i=0
where li(x) are polynomials in x of degree n. Since Ln(xj) = yj for j = 0, 1,
2,
, n, Eq. (3.32) gives
li ( xj ) = 0
i ≠ j ⎫⎪ if
⎬,
l j ( xj ) = 1 for all j ⎪⎭
which are the same as Eq. (3.31). Hence li(x) may be written as
( x − x0 ) ( x − x1 ) ! ( x − xi −1 ) ( x − xi +1 ) ! ( x − xn ) (3.39)
li ( x) = ,
( xi − x0 ) ( xi − x1 ) ! ( xi − xi −1 ) ( xi − xi +1 ) ! ( xi − xn )
which obviously satisfies the conditions (3.31).
If we now set
3 n 1 ( x) ( x x0 ) ( x x1 ) ! ( x xi 1 ) ( x xi ) ( x xi 1 ) ! ( x xn ), (3.40)
then d
3nb 1 ( xi ) [3n1 ( x)]x xi
dx
( xi x0 ) ( xi x1 ) ! ( xi xi 1 ) ( xi xi 1 ) ! ( xi xn ) (3.41)
104 CHAPTER 3: Interpolation
¥ (x 3x ) 3(bx) (x ) y ,
n
n 1 (3.43)
Ln ( x) i
i0 i n 1 i
¥ ( y 3y ) 3(by) ( y ) x ,
n
n1 (3.44)
Ln ( y ) i
i0 i n 1 i
which is useful for inverse interpolation.
It is trivial to show that the Lagrange interpolating polynomial is unique.
To prove this, we assume the contrary. Let Ln ( x) be a polynomial, distinct
from Ln(x), of degree not exceeding n and such that
Ln ( xi ) = yi , i = 0, 1, 2, ! , n.
Then the polynomial defined by M(x), where
M ( x) = Ln ( x) − Ln ( x)
vanishes at the (n + 1) points xi , i = 0, 1, ! , n. Hence we have
M n ( x ) ≡ 0,
which shows that Ln(x) and Ln ( x) are identical.
A major advantage of this formula is that the coefficients in Eq. (3.44)
are easily determined. Further, it is more general in that it is applicable to
either equal or unequal intervals and the abscissae x0 , x1 , …, xn need not be
in order. Using this formula it is, however, inconvenient to pass from one
interpolation polynomial to another of degree one greater.
The following examples illustrate the use of Lagranges formula.
Example 3.13 Certain corresponding values of x and log10 x are
(300, 2.4771), (304, 2.4829), (305, 2.4843) and (307, 2.4871). Find log10301.
From formula given in Eq. (3.43), we obtain
(−3) (−4) (−6) (1) (−4) (−6)
log10 301 = (2.4771) + (2.4829)
(−4) (−5) (−7) (4) (−1) ( −3)
(1) ( −3) ( −6) (1) (−3) (−4)
+ (2.4843) + (2.4871)
(5) (1) (−2) (7) (3) (2)
The actual value is 2.0 since the above values were obtained from the
polynomial y(x) = x2 + 3.
Example 3.15 Find the Lagrange interpolating polynomial of degree 2
approximating the function y = ln x defined by the following table of values.
Hence determine the value of ln 2.7.
x y = ln x
2 0.69315
2.5 0.91629
3.0 1.09861
We have
( x − 2.5) ( x − 3.0)
l0 ( x) = = 2 x 2 − 11x + 15.
(−0.5) (−1.0)
Similarly, we find
| Error | = 0.0008646.
106 CHAPTER 3: Interpolation
8 1
= (0.70711) −
9 9
4.65688
=
9
= 0.51743.
Example 3.17 Using Lagranges interpolation formula, find the form of the
function y (x) from the following table
x y
0 − 12
1 0
3 12
4 24
Since y = 0 when x = 1, it follows that x 1 is a factor. Let y(x) = (x 1) R(x).
Then R(x) = y/(x 1). We now tabulate the values of x and R(x).
x R( x)
0 12
3 6
4 8
( x − 3) ( x − 4) ( x − 0) ( x − 4) ( x − 0) ( x − 3)
R( x) = (12) + (6) + (8)
(−3) (−4) (3 − 0) (3 − 4) (4 − 0) (4 − 3)
= ( x − 3) ( x − 4) − 2 x ( x − 4) + 2 x ( x − 3)
= x 2 − 5 x + 12.
SECTION 3.9: Interpolation with Unevenly Spaced Points 107
which agrees with the actual error in the solution obtained in Example 3.16.
where ui(x) and vi(x) are polynomials in x of degree (2n + 1). Using conditions
(3.49), we obtain
⎧ 1, if i = j ⎫
ui ( xj ) = ⎨ ; vi ( x) = 0, for all i ⎪
⎩ 0, if i ≠ j ⎪ (3.51)
⎬
⎧ 1, if i = j ⎪
ui′ ( x) = 0, for all i; vi′ ( x j ) = ⎨ ⎪
⎩ 0, if i ≠ j. ⎭
Since ui(x) and vi(x) are polynomials in x of degree (2n + 1), we write
where li(x) are given by Eq. (3.42). It is easy to see that Ai(x) and Bi(x) are
both linear functions in x. We therefore write
ai = −2li′( xi ), bi = 1 + 2 xi li′( xi ) ⎫⎪
⎬ (3.55)
ci = 1, di = − xi . ⎪⎭
Hence Eq. (3.53) become
ui ( x ) = [ −2 x li′ ( xi ) + 1 + 2 xi li′ ( xi )] [li ( x )]2
Using the above expressions for ui(x) and vi(x) in Eq. (3.50), we obtain finally
n n
H 2n +1 ( x) = ∑ [1 − 2( x − xi ) li′( xi )] [li ( x)]2 yi + ∑ ( x − xi ) [li ( x)]2 yi′, (3.57)
i=0 i =0
Example 3.20 Find the third-order Hermite polynomial passing through the
points (xi, yi, y¢i), i = 0, 1.
Putting n = 1 in Hermites formula (3.57), we obtain
( x1 − x)2 ( x − x0 ) 2
+ ( x − x0 ) y0′ + ( x − x1 ) y1′ , (ii)
h12 h12
which is the required Hermite formula.
Example 3.21 Determine the Hermite polynomial of degree 5, which fits
the following data and hence find an approximate value of ln 2.7.
x y = ln x y ′ = 1/ x
2.0 0.69315 0.5
2.5 0.91629 0.4000
3.0 1.09861 0.33333
The polynomials li(x) have already been computed in Example 3.15. These are
The Lagrange interpolation formula, derived in Section 3.9.1, has the disadvantage
that if another interpolation point were added, then the interpolation coefficients
li(x) will have to be recomputed. We therefore seek an interpolation polynomial
which has the property that a polynomial of higher degree may be derived
from it by simply adding new terms. Newtons general interpolation formula
is one such formula and it employs what are called divided differences. It is
our principal purpose in this section to define such differences and discuss
certain of their properties to obtain the basic formula due to Newton.
Let ( x0 , y0 ), ( x1 , y1 ), ! , ( xn , yn ) be the given (n + 1) points. Then the
divided differences of order 1, 2,
, n are defined by the relations:
y1 y0 »
[ x0 , x1 ] , ¯
x1 x0
¯
[ x , x ] [ x0 , x1 ] ¯
[ x0 , x1 , x2 ] 1 2 , ¯
x2 x0 ¼ (3.58)
¯
# ¯
[ x1 , x2 , ! , xn ] [ x0 , x1 , ! , xn 1 ] ¯
[ x0 , x1 , ! , xn ] .¯
xn x0 ¯½
Even if the arguments are equal, the divided differences may still have a
meaning. We then set x1 = x0 + e so that
[ x0 , x1 ] = lim [ x0 , x0 + F ]
F →0
y ( x0 + F ) − y ( x0 )
= lim
F →0 F
= y ′( x0 ), if y ( x) is differentiable.
Similarly,
y r ( x0 ) (3.59)
[ x0 , x0 , ! , x0 ] = .
r!
( r +1) arguments
112 CHAPTER 3: Interpolation
1 ⎛ y2 − y1 y1 − y0 ⎞
[ x0 , x1 , x2 ] = ⎜ − ⎟
x2 − x0 ⎝ x2 − x1 x1 − x0 ⎠
1 ⎡ y2 ⎛ 1 1 ⎞ y0 ⎤
= ⎢ − y1 ⎜ + ⎟+ ⎥
x2 − x0 ⎢⎣ x2 − x1 ⎝ x2 − x1 x1 − x0 ⎠ x1 − x0 ⎥⎦
y0 y1
= +
( x0 − x1 ) ( x0 − x2 ) ( x1 − x0 ) ( x1 − x2 )
y2 (3.60)
+ .
( 2 − 0 ) ( x2 − x1 )
x x
300 2.4771
0.00145
304 2.4829 0.00001
0.00140
305 2.4843 0
0.00140
307 2.4871
–1 3
–9
0 –6 6
15 5
3 39 41 1
261 13
6 822 132
789
7 1611
SECTION 3.10: Divided Differences and Their Properties 115
= x 4 − 3x3 + 5 x 2 − 6.
1 ' 012|n 1 ( x) xn 1 x
' 012 ! n ( x) . (3.72)
xn xn 1 ' xn x
012|n 2 n ( x )
300 2.4771
2.47855
304 2.4829 2.47858
2.47854 2.47860
305 2.4843 2.47857
2.47853
307 2.4871
Given a set of values of x and y, the process of finding the value of x for
a certain value of y is called inverse interpolation. When the values of x are
at unequal intervals, the most obvious way of performing this process is by
interchanging x and y in Lagranges or Aitkens methods. Use of Lagranges
formula was already illustrated in Example 3.14. We will now solve the same
example by means of Aitkens and Nevilles schemes.
Aitkens scheme (see Table 3.8) is
y x
4 1
1.750
12 3 1.857
1.600
19 4
SECTION 3.11: Inverse Interpolation 117
Hence both the schemes lead to the same result ultimately. In practice,
however, Nevilles scheme should be preferred for the simple reason that in
this scheme those points which are nearest to xr are used for interpolation
at x = xr . It is, of course, important to remember that inverse interpolation
is, in general, meaningful only if the function is single-valued in the interval.
When the values of x are equally spaced, the method of successive
approximations, described below, should be used.
Method of successive approximations
We start with Newtons forward difference formula [see Eq. (3.10), Section 3.6]
written as
u (u − 1) 2 u (u − 1) (u − 2) 3 (3.73)
yu = y0 + u 'y0 + ' y0 + ' y0 + "
2 6
From this, we obtain
1 ⎡ u (u − 1) 2 u (u − 1) (u − 2) 3 ⎤ (3.74)
u= ⎢ yu − y0 − 2 ' y0 − ' y0 − "⎥ .
'y0 ⎣ 6 ⎦
Neglecting the second and higher differences, we obtain the first approximation
to u and this, we write, as follows
1
u1 = ( yu − y0 ). (3.75)
'y0
Next, we obtain the second approximation to u by including the term containing
the second differences. Thus,
1 ⎡ u (u − 1) 2 ⎤ (3.76)
u2 = ⎢ yu − y0 − 1 1 ' y0 ⎥ ,
'y0 ⎣ 2 ⎦
where we have used the value of u1 for u in the coefficient of D2y0. Similarly,
we obtain
1 ⎡ u2 (u2 − 1) 2 u (u − 1) (u2 − 2) 3 ⎤
u3 = (3.77)
'y0 ⎢ yu − y0 − ' y0 − 2 2 ' y0 ⎥
⎣ 2 6 ⎦
118 CHAPTER 3: Interpolation
and so on. This process should be continued till two successive approximations
to u agree with each other to the required accuracy. The method is illustrated
by means of the following example.
Example 3.25 Tabulate y = x3 for x = 2, 3, 4 and 5, and calculate the cube
root of 10 correct to three decimal places.
x y = x3 Δ Δ2 Δ3
2 8
19
3 27 18
37 6
4 64 24
61
5 125
Example 3.26 The following table gives the values of z for different values
of x and y. Find z when x = 2.5 and y = 1.5.
x
y 0 1 2 3 4
0 0 1 4 9 16
1 2 3 6 11 18
2 6 7 10 15 22
3 12 13 16 21 28
4 18 19 22 27 34
EXERCISES
⎡ f ( x) ⎤
(d) D(tan1x) (e) ' ⎢ ⎥.
⎣ g ( x) ⎦
E2
(a) D = md + (b) D3y2 = Ñ3y5
2
3.10 From the table of cubes given below, find (6.36)3 and (6.61)3.
x 6.1 6.2 6.3 6.4 6.5 6.6 6.7
3
x 226.981 238.328 250.047 262.144 274.625 287.496 300.763
1
3.11 Define the operators D, Ñ, d, E and E and show that
(a) ' r yk = ∇ r yk + r = E r y r (b) '∇yk = ∇'yk = E 2 yk
k+
2
'+∇ ¦ 1 µ
2
(c) mdÿ = (d) 1 + m2d 2 = § 1 E 2 ¶
2 ¨ 2 ·
⎛ 1 ⎞ ' yk
(e) D2 = (1 + D)d 2 (f) ' ⎜ ⎟ = – .
y
⎝ k⎠ y k yk +1
EXERCISES 121
x 0 5 10 15 20 25 30
y 1 3 ? 73 225 ? 1153
3.18 State Gausss backward formula and use it to find the value of 12525,
given that 12500 = 111.8034, 12510 = 111.8481,
12520 = 111.8928, 12530 = 111.9375 and 12540 = 111.9822.
3.19 State Stirlings formula for interpolation at the middle of a table of
values and find e1.91 from the following table:
¥
n
3n 1 ( x)
1,
i0
( x xi )3 nb 1 ( xi )
3.42 Using Hermites interpolation formula, estimate the value of ln 4.2 from
1
the data (values of x, ln x and ):
x
(4.0, 1.38629, 0.25000), (4.5, 1.50408, 0.22222), (5.0, 1.60944, 0.20000).
3.43 Find the Hermite polynomial of the third degree approximating the
function y (x) such that
y(0) = 1, y¢(0) = 0,
y(1) = 3, y¢(1) = 5.
3.44 Values of x and 3 x are given below
(51, 3.708), (55, 3.803), (57, 3.848). Find x when 3 x = 3.780.
3.45 From the table of values of x and ex, viz. (1.4, 4.0552), (1.5, 4.4817),
(1.6, 4.9530), (1.7, 5.4739), find x when ex = 4.7115, using the method
of successive approximations.
3.46 The second degree polynomial which satisfies the set of values (0, 1),
(1, 2) and (2, 1) is
(a) 1 + 2x x 2 (b) 1 2x + x 2 (c) 1 2x x 2 (d) 1 + 2x + x 2
Find the correct alternative in the above.
3.47 If Dy = 1 + 2x + 3x2, which one of the following is not true?
(a) D2y = 6x + 5 (b) D3y = 6
(c) D4y = 0 (d) y = x2 + x3
3.48 Which of the following statements are true?
h
(a) D(tan1x) = tan1 (b) D(cos 2x) = 2 sin x (x + h)
1 + x( x + h)
(c) D2(x 3) = 6x (d) d = ÑE1/2
'+ ∇
(e) D2 = (1 D)d 2 (f) md =
2
EXERCISES 125
¦ '2 µ 3
(g) Dxn = nxn1 (h) § ¶x 6x
¨ E ·
(i) Dnex = ex
3.49 For the function z = f (x, y), the following values are given
f (0, 0) = 0, f (0, 1) = 2, f (0, 2) = 6,
f (1, 0) = 1, f (1, 1) = 3, f (1, 2) = 7,
f (2, 0) = 4, f (2, 1) = 6, f (2, 2) = 10.
Estimate the value of f (0.5, 0.5) by the method of linear interpolation
and compare the result with the actual value obtained from
z = x2 + y2 + y.
3.50 Estimate the value of f (1.5, 1.5) in Problem 3.49 and compare the
value with its actual value.
Answers to Exercises
3.1 239, 371
3.2 (a) 6h2(h + x), (b) cos (x + 2h) 2cos (x + h) + cos x
h
(c) 2x + 4 (d) tan 1
x ( x h)
f ( x + h) g ( x ) − g ( x + h) f ( x )
(e)
g ( x ) g ( x + h)
3.3 5.74
3.4 3.1582 3.6 54
3.7 y(1) = 3, y(10) = 111 3.8 1.6751, 1.7082
3.10 257.259, 288.805 3.13 17,551
3.14 0.00000001 3.15 0.783172
3.17 0.3165 3.18 111.9152
3.19 6.7531 3.20 0.9856
3.21 0.9856 3.22 1.6858
3.23 16.25 3.24 0.1987
3.25 0.9763 3.26 3251
1
3.28 (11x2 3x + 7) 3.29 16
3
1 3 3 2 241 39
3.30 0.0239 3.31 – x x x
15 20 60 10
1 1 1 (a b) ab bc ca
3.34 – 3.36 ,
2( x 1) 2( x 1) x 2 a 2b 2 a 2 b2 c 2
3.37 1454 3.40 | y(x) L2(x) | = 6.415 ´ 108
3.42 1.435081 3.43 1 + x2 + x3
3.44 54 3.45 1.55
3.46 (a) 3.47 (d)
3.48 (a), (d), (f), (h) 3.49 1.5
3.50 Proceed as in Problem 3.49.
Chapter
4.1 INTRODUCTION
Let the set of data points be (xi, yi), i = 1, 2,
, m, and let the curve given
by Y = f (x) be fitted to this data. At x = xi, the given ordinate is yi and the
126
SECTION 4.2: Least Squares Curve Fitting Procedures 127
then the method of least squares consists in minimizing S, i.e., the sum of the
squares of the errors. In the following sections, we shall study the linear and
nonlinear least squares fitting to given data (xi, yi), i = 1, 2,
, m.
¥ ¥y
m m
ma0 a1 xi i (4.6a)
i 1 i 1
and
¥ ¥ ¥ xy
m m m
a0 xi a1 xi2 i i (4.6b)
i 1 i 1 i 1
128 CHAPTER 4: Least Squares and Fourier Transforms
Equations (4.6) are called the normal equations, and can be solved for a0
and a1, since xi and yi are known quantities.
We can obtain easily
¥ x y ¥ x ¥ y
m m m
m i i i i
i 1 i 1 i 1
a1 2
(4.7)
¦ m µ
¥ ¥
m
m xi2 § x¶
i 1
§¨ i 1 i ¶·
and then
a0 = y − a1 x . (4.8)
∂2 S ∂2 S
Since and are both positive at the points a0 and a1, it follows that
∂a02 ∂a12
these values provide a minimum of S. In Eq. (4.8), x and y are the means
of x and y, respectively. From Eq. (4.8), we have
y = a0 + a1 x ,
which shows that the fitted straight line passes through the centroid of the
data points.
Sometimes, a goodness of fit is adopted. The correlation coefficient (cc)
is defined as
Sy S
cc , (4.9)
Sy
where
m
Sy = ∑ ( yi − y )2 (4.10)
i =1
Example 4.1 Find the best values of a 0 and a 1 if the straight line
Y = a0 + a1x is fitted to the data (xi, yi):
(1, 0.6), (2, 2.4), (3, 3.5), (4, 4.8), (5, 5.7)
Find also the correlation coefficient.
From the table of values given below, we find x = 3, y = 3.4, and
5(63.6) − 15(17)
a1 = = 1.26
5(55) − 225
Therefore,
a0 = y − a1 x = – 0.38.
SECTION 4.2: Least Squares Curve Fitting Procedures 129
16.10 − 0.2240
The correlation coefficient = = 0.9930 .
16.10
¥ (z a a x a y )
m
S i 0 1 i 2 i
2
i 1
130 CHAPTER 4: Least Squares and Fourier Transforms
14243
a0 S xi + a1 S xi2 + a2 S xi yi = S zi xi (4.11)
2
a0 S yi + a1 S yixi + a2 S yi = Szi yi
from which a0, a1 and a2 can be determined.
b
(a) y = ax +
x
This can be written as
xy = ax2 + b
Put xy = Y, x2 = X. With these transformations, it becomes a linear
model.
(b) xya = b
Taking logarithms of both sides, we get
log10x + a log10y = log10b.
In this case, we put
log10y = Y, log10x = X,
1 1
log10b = A0 and = A1,
a a
so that
Y = A0 + A1X.
x
(c) y = ab
Taking logarithms of both sides, we obtain
log10y = log10a + x log10b
Þ Y = A0 + A1X,
where
Y = log10y, A0 = log10a,
X = x, and A1 = log10b
(d) y = axb
We have
log10y = log10a + blog10x
Þ Y = A0 + A1X,
where
Y = log10y, A0 = log10a, A1 = b
and
X = log10x.
bx
(e) y = ae
In this case, we write
ln y = ln a + bx
Þ Y = A0 + A1X,
where
Y = ln y, A0 = ln a, A1 = b
and
X = x.
Example 4.4 Using the method of least squares, find constants a and b
such that the function y = aebx fits the following data:
(1.0, 2.473), (3.0, 6.722), (5.0, 18.274), (7.0, 49.673), (9.0, 135.026).
132 CHAPTER 4: Least Squares and Fourier Transforms
We have
y = aebx
Therefore,
ln y = ln a + bx
Þ Y = A0 + A1X,
where
Y = ln y, A0 = ln a, A1 = b and X = x.
The table of values is given below
X Y = ln y X2 XY
1 0.905 1 0.905
3 1.905 9 5.715
5 2.905 25 14.525
7 3.905 49 27.335
9 4.905 81 44.145
25 14.525 165 92.625
We obtain
X 5, Y 2.905
5(92.625) − 25(14.525)
A1 = = 0.5 = b.
5(165) − 625
Then
A0 = Y − A1 X = 2.905 − 0.5(5) = 0.405.
Hence,
a = e A0 = e0.405 = 1.499.
It follows that the required curve is of the form
y = 1.499e0.5x
Example 4.5 Using the method of least squares, fit a curve of the form
x
y = to the following data
a + bx
(3, 7.148), (5, 10.231), (8, 13.509), (12, 16.434).
We have
x
y =
a + bx
1 a + bx a
Þ = =b+
y x x
Þ Y = A0 + A1X,
where
1 1
A0 = b, A1 = a, X = and Y = .
x y
SECTION 4.2: Least Squares Curve Fitting Procedures 133
and A0 = b = Y a X = 0.0331.
Hence the required fit is Y = 0.0331 + 0.324(X), which simplifies to
x
y= .
0.324 + 0.0331( x)
© x ¸
ª Note: The given data is obtained from the relation y ¹
« 0.3162 0.0345 x º
2 n 2
+ ©« y2 (a0 a1 x2 a2 x2 " an x2 ) ¸
º
2 n 2
" © ym (a0 a1 xm a2 xm " an xm ) ¸ (4.13)
« º
Equating to zero the first partial derivatives and simplifying, we obtain the
normal equations:
Example 4.6 Fit a polynomial of the second degree to the data points
(x, y) given by
(0, 1), (1, 6) and (2, 17).
For n = 2, Eq. (4.14) requires 6xi , 6xi2 , 6xi3 , 6xi4 , Syi, Sxi yi and 6xi2 yi .
The table of values is as follows:
x y x2 x3 x4 xy x2y
0 1 0 0 0 0 0
1 6 1 1 1 6 6
2 17 4 8 16 34 68
3 24 5 9 17 40 74
Example 4.7 Fit a second degree parabola y = a0 + a1x + a2x2 to the data
(xi, yi):
(1, 0.63), (3, 2.05), (4, 4.08), (6, 10.78).
The table of values is
x y x2 x3 x4 xy x2y
1 0.63 1 1 1 0.63 0.63
3 2.05 9 27 81 6.15 18.45
4 4.08 16 64 256 16.32 65.28
6 10.78 36 216 1296 64.68 388.08
14 17.54 62 308 1634 87.78 472.44
SECTION 4.2: Least Squares Curve Fitting Procedures 135
d2y dy
2
= a1 + a2 y (4.17)
dx dx
where the constants a1 and a2 have to be determined. Integrating Eq. (4.17),
we obtain
x
y b ( x) – y b ( x0 ) a1 < y ( x) y (0)> a2 ± y ( x) dx, (4.18)
x0
dy
where x0 is the initial value of x and y ′( x) = . Integrating Eq. (4.18), we
dx
get
x
y ( x) – y (0) ( x x0 ) y b ( x0 ) a1 ± y ( x) dx – a1 ( x – x0 ) y ( x0 )
x0
x x
a2 ± ± y ( x) dx dx (4.19)
x0 x0
136 CHAPTER 4: Least Squares and Fourier Transforms
Now,
x x x
∫ ∫ y( x) dx dx = ∫ ( x – t ) y(t ) dt
x0 x0 x0
In Eq. (4.20), y¢(x0) is eliminated in the following way. Let x1 and x2 be two
data points such that
x0 x1 = x2 x0 (4.21)
Then Eq. (4.20) gives
x1
y ( x1 ) – y ( x0 ) ( x1 x0 ) y b ( x0 ) a1 ± y ( x) dx – a1 ( x1 – x0 ) y ( x0 )
x0
x1
a2 ± ( x1 – t ) y (t ) dt (4.22)
x0
and
x2
y ( x2 ) – y ( x0 ) ( x2 x0 ) y b ( x0 ) a1 ± y ( x) dx – a1 ( x2 – x0 ) y ( x0 )
x0
x2
a2 ± ( x2 – t ) y (t ) dt (4.23)
x0
Adding Eqs. (4.22) and (4.23) and using Eq. (4.21), we obtain
⎡ x1 x2 ⎤
⎢ y ( x)dx + y ( x) dx ⎥
y ( x1 ) + y ( x2 ) − 2 y ( x0 ) = a1 ∫
⎢ ∫ ⎥
⎣ x0 x0 ⎦
⎡ x1 x2 ⎤
⎢ ( x1 − t ) y (t ) dt + ( x2 − t ) y (t ) dt ⎥ (4.24)
+ a2
⎢ ∫ ∫ ⎥
⎣ x0 x0 ⎦
Equation (4.24) can now be used to set up a linear system of equations for
a1 and a2, and then we obtain l1 and l2 from the characteristic equation
SECTION 4.2: Least Squares Curve Fitting Procedures 137
l2 = a1l + a2 (4.25)
Finally, A1 and A2 can be obtained by the method of least squares or by the
method of averages.
⎡ 1.2 1.4 ⎤
∫ ∫
+ a2 ⎢ − (1.0 − t ) y (t ) dt + (1.4 – t ) y (t ) dt ⎥
⎢ 1.0 ⎥
⎣ 1.2 ⎦
Evaluating the integrals by Simpsons rule* and simplifying, the above equation
becomes
1.81a1 + 2.180a2 = 2.10 (ii)
Again, choosing x1 = 1.4, x0 = 1.6 and x2 = 1.8, and evaluating the integrals
as before, we obtain the equation
2.88a1 + 3.104a2 = 3.00 (iii)
Solving Eqs. (ii) and (iii), we get
a1 = 0.03204 and a2 = 0.9364.
Equation (4.25) now gives
l2 0.03204l 0.9364 = 0,
from which we obtain
l1 = 0.988 = 0.99,
and
l2 = 0.96.
Using the method of least squares, we finally obtain
A1 = 0.499 and A2 = 0.491.
The above data was actually constructed from the function y = cosh x so
that A1 = A2 = 0.5, l1 = 1.0 and l2 = 1.0.
In the previous section, we have minimized the sum of squares of the errors.
A more general approach is to minimize the weighted sum of the squares of
the errors taken over all data points. If this sum is denoted by S, then instead
of Eq. (4.2), we have
In Eq. (4.26), the Wi are prescribed positive numbers and are called weights.
A weight is prescribed according to the relative accuracy of a data point. If
all the data points are accurate, we set Wi = 1 for all i. We consider again
the linear and nonlinear cases below.
∂S ∂S (4.28)
= = 0,
∂a0 ∂a1
which give
m
∂S
∂a0
= −2 ∑
Wi [ yi − (a0 + a1 xi )] = 0 (4.29)
i =1
and
m
∂S
∂a1
= −2 ∑
Wi [ yi − (a0 + a1 xi )] xi = 0. (4.30)
i =1
which are the normal equations in this case and are solved to obtain a0 and
a1. We consider Example 4.2 again to illustrate the use of weights.
Example 4.9 Suppose that in the data of Example 4.2, the point (5, 12) is
known to be more reliable than the others. Then we prescribe a weight (say,
10) corresponding to this point only and all other weights are taken as unity.
The following table is then obtained.
x y W Wx Wx 2 Wy Wxy
0 –1 1 0 0 –1 0
2 5 1 2 4 5 10
5 12 10 50 250 120 600
7 20 1 7 49 20 140
y = −1.349345 + 2.73799 x.
x y W Wx Wx 2 Wy Wxy
0 –1 1 0 0 –1 0
2 5 1 2 4 5 10
5 12 100 500 2500 1200 6000
7 20 1 7 49 20 140
Let
y ( x) = a0 + a1 x + a2 x 2 + " + an x n (4.37)
be chosen to minimize
b
Let
y = a0 + a1 x + a2 x 2 (i)
be the required quadratic approximation. Then using Eq. (4.41), we obtain
the system
Q /2 Q /2 Q /2 Q /2 ⎫
∫ ∫ ∫ ∫ ⎪
2
a0 dx + a1 x dx + a2 x dx = sin x dx
⎪
0 0 0 0 ⎪
Q /2 Q /2 Q /2 Q /2 ⎪
⎪
∫ ∫ ∫ ∫ (ii)
2 3
a0 x dx + a1 x dx + a2 x dx = x sin x dx ⎬
0 0 0 0 ⎪
⎪
Q /2 Q /2 Q /2 Q /2 ⎪
∫ ∫ ∫ ∫ x 2 sin x dx. ⎪
2 3 4
a0 x dx + a1 x dx + a2 x dx =
⎪
0 0 0 0 ⎪⎭
Q2 Q3 Q4
a0 + a1 + a2 =1
8 24 64
Q3 Q4 Q5 ⎛Q ⎞
a0 + a1 + a2 = 2 ⎜ − 1⎟ ,
24 64 160 ⎝ 2 ⎠
whose solution is
18 ⎫
96 480
a0 = + ⎪ −
Q Q Q ⎪
2 3
The true value of sin (p /4) = 0.707106781, so that the error in the preceding
solution is 0.000939194.
Y ( x ) = a0 f 0 ( x ) + a1 f1 ( x ) + " + an f n ( x ), (4.42)
∂S
b ⎫
∂a0
= 0 = −2 ∫ W ( x) { y ( x) − [ a0 f 0 ( x) + a1 f1 ( x) + " + an f n ( x)]} f 0 ( x) dx ⎪
⎪
a
⎪
b ⎪
∂S
= 0 = −2 ∫ W ( x) { y ( x) − [ a0 f 0 ( x) + a1 f1 ( x) + " + an f n ( x)]} f1 ( x) dx ⎪⎪
∂a1
a ⎬ (4.44)
⎪
# ⎪
b ⎪
∂S ⎪
∂an
= 0 = −2 ∫ W ( x) { y ( x) − [ a0 f 0 ( x) + a1 f1 ( x) + " + an f n ( x)]} f n ( x) dx ⎪
⎪⎭
a
144 CHAPTER 4: Least Squares and Fourier Transforms
144444444444424444444444443
b b b
a0 ± W ( x) f 0 ( x) dx a1 ± W ( x) f0 ( x) f1 ( x) dx " an ± W ( x) f0 ( x) f n ( x) dx
2
a a a
b
± W ( x) y ( x) f0 ( x) dx
a
b b b
f0 ( x) dx a1 ± W ( x) f 1 ( x) dx " an ±
2
a0 ± W ( x) f1 ( x) W ( x) f1 ( x) f n ( x) dx
a a a
b
± W ( x) y ( x) f1 ( x) dx
a
#
b b b
a0 ± W ( x) f n ( x) f 0 ( x) dx a1 ± W ( x) f n ( x) f1 ( x) dx " an ± W ( x) f n2 ( x) dx
a a a
b
± W ( x) y ( x) f n ( x) dx.
a
(4.45)
The above system can be written more simply as
b b
a0 ∫ W ( x) f0 ( x) f j ( x) dx + a1 ∫ W ( x) f1 ( x) f j ( x) dx + "
a a
b b
+ an ∫ W ( x) f n ( x) f j ( x) dx = ∫ W ( x) y( x) f j ( x) dx, j = 0, 1, 2, …, n.
a a
(4.46)
In Eq. (4.45), we find products of the type fp(x) fq(x) in the integrands, and
if we assume that
⎧ 0, p≠q
b ⎪⎪
∫
W ( x) f p ( x) f q ( x) dx = ⎨ b (4.47)
∫
2
a ⎪ W ( x ) f p ( x ) dx , p = q ,
⎪⎩ a
then the system (4.45) reduces to
b b
a0 ∫ W ( x) f 02 ( x) dx = ∫ W ( x) y( x) f0 ( x) dx
a a
#
b b
an ∫ W ( x) f n2 ( x) dx = ∫ W ( x) y( x) f n ( x) dx.
a a
SECTION 4.4: Method of Least Squares for Continuous Functions 145
∫ W ( x) y( x) f j ( x) dx
aj =
a
, j = 0, 1, 2, …, n. (4.48)
b
∫ W ( x) f j ( x) dx
2
a
Substitution of a0, a1,
, an in Eq. (4.42) then yields the required least
squares approximation, but the functions f0(x), f1(x),
, fn(x) are still not
known. The fj (x), which are polynomials in x satisfying the conditions (4.47),
are called orthogonal polynomials and are said to be orthogonal with respect
to the weight function W(x). They play an important role in numerical
analysis and a few of them are listed below in Table 4.1.
Table 4.1 Orthogonal Polynomials*
*For more details concerning orthogonal polynomials, see Abramovitz and Stegun
[1965].
146 CHAPTER 4: Least Squares and Fourier Transforms
we find that the linear polynomial f1(x), with leading term x, can be written as
f1(x) = x + k1,0 f0(x), (4.50)
where k1, 0 is a constant to be determined. Since f1(x) and f0(x) are orthogonal,
we have
b b b
∫ W ( x) f0 ( x) f1 ( x) dx = 0 = ∫ ∫ W ( x) f 0 ( x) dx
2
xW ( x) f0 ( x) dx + k1, 0
a a a
using Eqs. (4.47) and (4.49). From the above, we obtain
b
∫ x W ( x) f 0 ( x) dx
a
k1, 0 = − b (4.51)
∫ W ( x) f 02 ( x) dx
a
and Eq. (4.50) gives
b
∫ x W ( x) f0 ( x) dx
a
f1 ( x) = x − b
.
∫ W ( x) f 02 ( x) dx
a
Now, the polynomial f2(x), of degree 2 in x and with leading term x2, may
be written as
where the constants k2,0 and k2,1 are to be determined by using the orthogonality
conditions in Eq. (4.47). Since f2(x) is orthogonal to f0(x), we have
b
∫ W ( x) f0 ( x)[ x
2
+ k2,0 f0 ( x) + k2,1 f1 ( x)] dx = 0.
a
b b
∫ ∫
2
x W ( x) f 0 ( x) dx x 2W ( x) dx
k2,0 = −
a
=−
a
. (4.53)
b b
∫ W ( x) f 0 ( x) dx ∫ W ( x) dx
2
a a
SECTION 4.4: Method of Least Squares for Continuous Functions 147
∫ W ( x) f1( x) [ x
2
+ k2,0 f0 ( x) + k2,1 f1 ( x)] dx = 0.
a
b
Using the condition that ∫ a W ( x) f0 ( x) f1 ( x) dx = 0, the above yields
b
∫ x 2W ( x) f1 ( x) dx
k2, 1 = −
a
. (4.54)
b
∫ W ( x) f 1 ( x) dx
2
Since k2,0 and k2,1 are known, Eq. (4.52) determines f2(x). Proceeding in this
way, the method can be generalized and we write
∫ x jW ( x) fi ( x) dx
k j, i = −
a
. (4.56)
b
∫ W ( x) f i
2
( x) dx
a
Since the ai and fi(x) in Eq. (4.42) are known, the approximation Y(x) can
now be determined. The following example illustrates the method of procedure.
Example 4.12 Obtain the first-four orthogonal polynomials fn(x) on [1, 1]
with respect to the weight function W ( x) = 1.
Let f0(x) = 1. Then Eq. (4.51) gives
1
∫ x dx
−1
k1, 0 = − 1
= 0.
∫ dx
−1
We then obtain from Eq. (4.50), f1(x) = x. Equations (4.53) and (4.54) give
respectively
1
∫ x 2 dx
1
−1
k2, 0 = − 1
=−
3
∫ dx
−1
148 CHAPTER 4: Least Squares and Fourier Transforms
and
1
∫ x 2 x dx
−1
k2,1 = − 1
= 0.
∫
2
x dx
−1
2
Then Eq. (4.52) yields f2(x) = x 1/3.
In a similar manner, we obtain
1
∫ x3 dx
−1
k3, 0 = − 1
= 0,
∫ dx
−1
∫ x3 x dx
3
−1
k3, 1 = − 1
=− ,
5
∫ x 2 dx
−1
∫ x3 ( x 2 − 1/3) dx
−1
k3, 2 = − 1
= 0.
∫
2 2
( x − 1/3) dx
−1
It is easily verified that
3
f3 ( x) = x3 − x.
5
Thus the required orthogonal polynomials are 1, x, x2 1/3 and x3 (3/5)x.
These polynomials are called Legendre polynomials and are usually denoted
by Pn(x). It is easy to verify that these polynomials satisfy the orthogonal
property given in Eq. (4.47). An important application of Legendre polynomials
occurs in numerical quadrature (see Chapter 6).
table of values has been found to be quite costlier when compared to the use
of efficient function approximations.
Let f1, f2,
, fn be the values of the given function and f1, f2,
, fn
be the corresponding values of the approximating function. Then the error vector
is e, where the components of e are given by ei = fi fi. The approximation
may be chosen in a number of ways. For example, we may find the
approximation such that the quantity √ (e 12 + e 22 + " + e n2 ) is minimum. This
leads us to the least squares approximation which we have already studied.
On the other hand, we may choose the approximation such that the maximum
component of e is minimized. This leads us to the celebrated Chebyshev
polynomials which have found important application in the approximation of
functions in digital computers.
In this section, we shall give a brief outline of Chebyshev polynomials
and their applications in the economization of power series.*
Tn ( x) = T− n ( x). (4.58)
Let cos −1 x = R so that x = cos R and (4.57) gives
Tn ( x) = cos nR .
Hence
T0 ( x) = 1 and T1( x) = x.
Using the trigonometric identity
cos (n − 1)R + cos (n + 1)R = 2cos nR cos R ,
we obtain easily
Tn −1 ( x ) + Tn +1 ( x ) = 2 xTn ( x ),
which is the same as
Tn +1 ( x ) = 2 xTn ( x ) − Tn −1 ( x ). (4.59)
*Refer to Fox and Parker [1968] for further details and other applications of
Chebyshev polynomials.
150 CHAPTER 4: Least Squares and Fourier Transforms
T0 ( x) = 1 ⎫
⎪
T1 ( x) = x ⎪
⎪
T2 ( x) = 2 x 2 − 1 ⎪
⎪
⎪ (4.60)
T3 ( x) = 4 x3 − 3x ⎬
4 2
⎪
T4 ( x) = 8 x − 8 x + 1 ⎪
⎪
T5 ( x) = 16 x5 − 20 x3 + 5 x ⎪
⎪
T6 ( x) = 32 x6 − 48 x 4 + 18 x 2 − 1. ⎪⎭
The graph of the first four Chebyshev polynomials are shown in Fig. 4.1
Tn(x)
T2(x) T3(x) 1
T4(x) )
(x
T1
x
–1 0 1
–1
⎧ 0, m≠n
1
Tm ( x) Tn ( x) dx ⎪⎪
∫ 1 − x2
= ⎨ Q / 2, m = n ≠ 0
⎪
(4.63)
−1
⎪⎩ Q , m=n=0
that is, the polynomials Tn(x) are orthogonal with the function 1/√ (1 − x 2 ). This
property is easily proved since by putting x = cosq, the above integral becomes
Q Q
polynomial 21nTn(x), has the smallest least upper bound for its absolute
value in the range (1, 1). Since |Tn(x)| £ 1, the upper bound referred to
above is 21n. Thus, in Chebyshev approximation, the maximum error is kept
down to a minimum. This is often referred to as minimax principle and the
polynomial in Eq. (4.64) is called the minimax polynomial. By this process
we can obtain the best lower-order approximation, called the minimax
approximation, to a given polynomial. This is illustrated in the following
example.
Example 4.13 Find the best lower-order approximation to the cubic
2 x3 + 3x 2. Using the relations given in Eq. (4.62), we write
2
2 x3 + 3x 2 = [T3 ( x) + 3T1 ( x)] + 3x 2
4
3 1
= 3x 2 + T1 ( x) + T3 ( x)
2 2
3 1
= 3x 2 + x + T3 ( x), since T1 ( x) = x.
2 2
The polynomial 3x2 + (3/2) x is the required lower-order approximation
to the given cubic with a maximum error ±1/2 in the range (1, 1).
A similar application of Chebyshev series in the economization of power
series is discussed next.
Using the relations given in Eq. (4.62), we convert the above series into an
expansion in Chebyshev polynomials. We obtain
x3 x5 x7 .
sin x ≈ x − + −
6 120 5040
SECTION 4.6: Fourier Approximation 153
x3 x5
sin x ≈ x − + (i)
6 120
will produce a change in the fourth decimal place only. We now convert the
powers of x in Eq. (i) into Chebyshev polynomials by using the relations
given in Eq. (4.62). This gives
1 1
sin x ≈ T1 ( x) − [3T1 ( x) + T3 ( x)] + [10T1 ( x) + 5T3 ( x) + T5 ( x)].
24 120 × 16
Simplifying the above, we obtain
169 5 1
sin x ≈ T1 ( x) − T3 ( x) + T5 ( x). (ii)
192 128 1920
Since 1/1920 = 0.00052
, the truncated series, viz.,
169 5
sin x = T1 ( x) − T3 ( x ) (iii)
192 128
will produce a change in the fourth decimal place only. Using the relations
given in Eq. (4.60), the economized series is, therefore, given by
169 5 383 5
sin x ≈ x− (4 x3 − 3 x) = x − x3 .
192 128 384 32
T a0 T T¦ 2Q nt 2Q nt µ a0
±0 f (t ) dt ± 0 dt ± 0 §¨ an cos bn sin ¶ dt T,
2 T T · 2
154 CHAPTER 4: Least Squares and Fourier Transforms
since
T ¦ 2Q nt µ T ¦ 2Q nt µ
±0 cos § ¶ dt ± sin § ¶ dt 0.
¨ T · 0 ¨ T ·
Hence
2 T
a0 f (t ) dt. (4.69)
T ±0
Again, multiplying both the sides of Eq. (4.68) by cos (2pnt/T) and then
integrating from 0 to T, we get
2 T ¦ 2Q nt µ
an ± 0 f (t ) cos §¨ ¶ dt , (4.70)
T T ·
since
T ¦ 2Q nt µ ¦ 2Q nt µ
±0 cos § ¶ sin § ¶ dt 0.
¨ T · ¨ T ·
Finally, multiplying both the sides of Eq. (4.68) by sin (2pnt/T) and then
integrating from 0 to T, we obtain
2 T ¦ 2Q nt µ
bn f (t ) sin § ¶ dt. (4.71)
T ±0 ¨ T ·
Thus the coefficients a0, an and bn in the representation (4.68) are evaluated.
If T = 2p, i.e. if f (t) is of period 2p, Eqs. (4.69)(4.71) become:
1 Q »
a0 ± Q f (t ) dt , ¯
Q
¯
1 Q ¯
an ± Q f (t ) cos nt dt , ¼ (4.72)
Q ¯
1 Q ¯
bn ± Q f (t )sin nt dt. ¯
Q ½
where
1 T/2
Ap f (t ) e 2Q ipt /T dt , p = 0, 1, 2, … (4.77)
T ± T / 2
These formulae directly lead us to the discussion of Fourier transforms but,
before this, we consider an illustrative example on Fourier series.
Example 4.15 Find the Fourier series of the function defined by
f (t )
t
–π 0 π
–1
Figure 4.2
From the graph, it can be seen that f (t) is an odd function. Hence the Fourier
series for f (t) contains only the coefficients bn.
156 CHAPTER 4: Least Squares and Fourier Transforms
where
2 Q
bn ±0 f (t ) sin nt dt
Q
2 Q
±0 sin nt dt , since f (t ) 1
Q
Q
2© 1 ¸
cos nt ¹
Q ª« n º0
2
[1 ( 1) n ]
nQ
4
, n 1, 3, 5, |
nQ
It follows that
e
f (t )
¥ 4
! Q
n
n 1,3,5,
sin nt
4¦
Q §¨
1
3
1
5
µ
sin t sin 3t sin 5t "¶ .
·
and
N 1
fk
1
N
¥ F .e
p0
p
2Q ikp / N
, k = 0, 1, 2,
, N 1 (4.81)
Denoting
WN = e−2Q i / N , (4.82)
¥F
N –1
1
fk p WN– kp ,
k = 0, 1, 2, …, N 1 (4.84)
N p0
The above equations are, respectively, called the discrete Fourier transform
(DFT) and the inverse DFT. The coefficients | Fp | form a periodic sequence
when extended outside of the range p = 0, 1, 2,
, N 1, and we have
F p + N = Fp (4.85)
From Eq. (4.83), it may be seen that to compute each point of the DFT, we
have to perform N complex multiplications and (N 1) complex additions.
Hence the Npoint DFT requires N2 complex multiplications and N(N 1)
complex additions.
Properties of WN
(i) Symmetric property
N
k+
WN 2 = WNk ⋅WNN/2
N
−2Q i
= – WNk , since WNN/2 =e 2N = e−Q i = – 1.
158 CHAPTER 4: Least Squares and Fourier Transforms
|, N 1.
N 1
F ( p) ¥fW
k 0
k
kp
N , p 0,1, 2,
f fW f W
0 1 N
p
2
2p
N " f W N 1
( N 1) p
N , p 0,1, |, N 1.
Putting p = 0, 1, 2,
, N 1, in the above equation, we obtain
# #
FN 1 f0 f1WNN 1 f 2WN2( N 1) " FN 1WN( N 1)( N 1)
SECTION 4.6: Fourier Approximation 159
© F0 ¸ ©1 1 1 " 1 ¸ © f0 ¸
¹ ª ¹
ª
F 1 WN1 WN2 " WNN 1 ª
f ¹
ª 1 ¹ª ¹ ª 1 ¹ (4.88)
ª # ¹ ª# # # # # ¹ ª # ¹
ª ¹ ª ¹ ª ¹
ª« FN 1 ¹º ª1
« WNN 1 WN2( N 1) " WN( N 1)( N 1) ¹º « f N 1 ¹
ª º
or
<F > <WN > < f >
In a similar way, Eq. (4.84) can be expressed as
1 ⎡ *⎤
[f ]= WN [F ], (4.89)
N⎣ ⎦
where WN* is the complex conjugate of WN.
⎡ F0 ⎤ ⎡1 1 1 1 ⎤⎡f ⎤
⎢ F ⎥ ⎢1 W41 W42
⎥ 0
W43 ⎥ ⎢ f1 ⎥
⎢ 1⎥ = ⎢ ⎢ ⎥
⎢ F2 ⎥ ⎢1 W42 W44
⎥
W46 ⎥ ⎢ f 2 ⎥
⎢ ⎥ ⎢ ⎢ ⎥
⎣⎢ F3 ⎦⎥ ⎢⎣1 W43 W46 W49 ⎥⎦ ⎣⎢ f3 ⎦⎥
©1 1 1 1 ¸ ©1¸ © 10 ¸
ª
1 –i –1 i ¹¹ ªª 2¹¹ ª
–2 2i ¹¹
ª ª
ª1 –1 1 –1¹ ª 3¹ ª –2 ¹
ª ¹ª ¹ ª ¹
ª1
« i –1 –i ¹º «ª 4º¹ «ª –2 – 2i º¹
For N = 4,
©1 1 1 1¸
ª
ª
1 –i –1 i ¹¹
<Wn >
ª1 –1 1 –1¹
ª ¹
ª1
« i –1 –i º¹
Therefore,
©1 1 1 1¸
ª
1 i –1 – i ¹¹
©W * ¸ ª
« N º ª1 –1 1 –1¹
ª ¹
«1
ª –i –1 i ¹º
Hence
⎡1 1 1 1⎤ ⎡ 1 ⎤ ⎡ 2⎤
⎢ – i ⎥⎥ ⎢⎢1– i ⎥⎥ 1 ⎢⎢ 4 ⎥⎥
1 ⎢1 i –1
[ ] ⎢
f = =
4 1 –1 1 –1⎥ ⎢ –1 ⎥ 4 ⎢ –2 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢⎣1 –i –1 i ⎥⎦ ⎢⎣1 + i ⎥⎦ ⎢⎣ 0 ⎥⎦
⎡ 0.5 ⎤
⎢ 1.0 ⎥
=⎢ ⎥
⎢ –0.5 ⎥
⎢ ⎥
⎣⎢ 0 ⎦⎥
N −1
=2 ∑ e−2Q ikp/N , since f (k ) = 2 for all k .
k =0
For p = 1, 2, 3,
, N 1,
Fp = 0.
0
For p = 0, Fp is of the form . By LHospitals rule, we obtain
0
1 e2Q ip
F0 2 lim 2N.
p n0 1 e2Q ip/N
Hence
⎧2 N , p=0
Fp = ⎨
⎩0 p = 1, 2, 3, …, N − 1
¥fW
3
Fp k
pk
4 , p 0, 1, 2, 3. (4.90)
k 0
where
W4 = e2pi/4 = i
We split the sum on the right side of Eq. (4.90) into two equal parts of
length 2, one containing the even-indexed values of f (t) and the other, the
odd-indexed values. We, therefore, write
Fp ¥
k 0, 2
f k W4kp ¥
k 1, 3
f k W4kp
(4.91)
¥ ¥f
1 1
(2 r 1) p
Fp f 2 r W42 rp 2 r 1 W4
r0 r0
¥ ¥f
1 1
f 2 r W2rp W4p rp
2 r 1W2 , p 0, 1
r0 r0
It may be seen that the first sum consists of f0 and f2 (even-indexed values)
and the second sum f1 and f3 (odd-indexed values). A convenient notation
is to use the superscripts e and o for the first and second sums, respectively*.
We therefore write
Fp Fpe W4p Fpo , p 0, 1 (4.92)
where
1
144424443
Fpe = ∑ f2rW2rp
r =0
and p = 0, 1 (4.93)
¥f
1
Fpo 2r 1 W2
rp
r 0
since
W42 = − 1.
From Eqs. (4.92) and (4.94), we obtain
F0 = f0 + f2 + f1 + f3
1442443
F1 = f0 f2 i ( f1 f3)
(4.95)
F2 = f0 + f2 ( f1 + f3)
F3 = f0 f2 + i ( f1 f3)
Results of Example 4.16 follow easily from Eqs. (4.95).
The computations involving Eqs. (4.92) and (4.94) of the 4-point
DITFFT are shown in Fig. 4.3 called flow-graph.
e 1
f0 F0
2-point DFT e
F1 –i
f2
o
f1 F0
2-point DFT F1
o –1
f3 i
Fpe = ∑ f 2rW4rp
r =0
and p = 0, 1, 2, 3 (4.97)
3
Fpo = ∑ f 2r +1W4rp
r =0
164 CHAPTER 4: Least Squares and Fourier Transforms
f1 F0
o
W84
f3 F 1o W85
f5 4-point DFT F 2o W86
f7 F 3o W87
1– i 1 i »
W80 1, W81 , W82 – i, W83 – ,
2 2 ¯¯
¼ (4.99)
–1 i 1 i ¯
W84 – 1, W85 , W86 i, W87
2 2 ¯½
In the second stage of decimation, each of the 4-point DFTs in Fig. 4.4 is
split into two 2-point DFTs. We then write
¥f
3
Fpe 2 r W4
pr
r0
¥f ¥f
1 1
4 sW2
sp
W4p 4 s 2W2
sp
s0 s0
where
144424443
1
Fpee = ∑ f4s W2sp
s= 0
1
(4.101)
and Fpeo = ∑ f 4 s + 2 W2sp
s= 0
Similarly, we obtain
Fpo = Fpoe + W4p Fpoo (4.102)
where
144424443
1
Fpoe = ∑ f4l +1 W2lp
l =0
p = 0, 1 (4.103)
1
and Fpoo = ∑ f 4l + 3 W2lp
l =0
eo
F0
f2 W 42
eo
2-point DFT F1
f6 W 43
oe
f1 F0 W 40
oe
2-point DFT F1
f5 W 41
oo
F0
f3 W 42
oo
2-point DFT F1
f7 W 43
¥f
1
Fpee sp
4 s W2 , p 0,1
s 0
f0 f 4 W2p
and
¥f
1
Fpeo sp
4 s 2 W2 , p 0, 1
s0
f 2 f6 W2p , p 0, 1
It follows that at the third stage of decimation, we obtain
Thus, for the 8-point DFT, we start with the input sequence f0, f4, f2, f6,
f1, f5, f3 and f7, and obtain the output in the natural order, i.e., F0, F1, F2,
F3, F4, F5, F6 and F7.
The three stages of computation can be shown in a single flow-graph
(Fig. 4.6).
(ii) The output for the Fourier coefficients Fk is in the natural order.
(iii) Computations are carried out in terms of what is called a butterfly.
A typical butterfly is shown in Fig. 4.7.
Fpe f0 f 2W2p , p 0, 1
14243
(ii)
and Fpo f1 f3W2p , p 0, 1
We, therefore, obtain
F0e f 0 f 2 4, F1e f 0 f 2 – 2
F0o = f1 + f3 = 6, F1o = f1 − f3 = – 2
Equation (i) now gives
F0 4 6 10, F1 2 W41 ( 2) 2 2i
F2 4 6 2, F3 2 W41 ( 2) 2 2i
168 CHAPTER 4: Least Squares and Fourier Transforms
Example 4.20 Use the CooleyTukey algorithm to find the DFT of the
sequence
fk = {1, 2, 3, 4, 4, 3, 2, 1}.
First stage: The key-equations are
Fpee f 0 W2p f 4 , Fpeo f 2 W2p f 6
where,
1– i 1 i
W80 1, W81 , W82 – i, W83 – ,
2 2
1– i 1 i
W84 – 1, W85 – , W86 i, W87 .
2 2
From these equations, we obtain
F0 = F0e + F0o = 20, F1 F1e W81 F1o
1– i
–3–i (–1 – 3i )
2
– 5.828 – i (2.414),
(1 i)
F2 = 0, F3 – 3 i – (–1 3i )
2
– 0.172 – i(0.414),
F4 = 0, F5 – 3 – i – (1 – i) (–1 – 3i)
2
– 0.172 i(0.414)
(1 i )
F6 = 0, F7 – 3 i (–1 3i )
2
– 5.828 i(2.414).
The flow-graph for this computation is given in Fig. 4.9.
¥fW
3
Fp k
pk
4 , p 0, 1, 2, 3
k0
In the method, the above sum is divided in terms of the first two and last
two points as:
Fp ¥
k 0,1
f kW4pk ¥
k 2, 3
f k W4pk
¥fW ¥f
1 1
p ( k 2)
k 4
pk
k 2W4 ; p 0, 1, 2, 3 (4.106)
k 0 k 0
Now,
W4p ( k + 2) = W4pk ⋅ W42 p = W4pk (–1) p ,
since
W42 p W2p (–1) p .
Hence, Eq. (4.106) becomes
¥
1
Fp ©f
« k
(–1) p f k 2 ¸º W4pk , p 0, 1, 2, 3 (4.107)
k0
¥(f
1
14444444244444443
F2r k f k 2 )W42 rk
k 0
¥(f
1
k f k 2 )W2rk
k0
¥(f
1
and F2 r 1 k f k 2 )W4k (2 r 1) (4.108)
k 0
¥(f
1
k – f k 2 )W42 kr W4k
k 0
¥(f
1
k – f k 2 )W2kr W4k , r 0, 1
k 0
SECTION 4.6: Fourier Approximation 171
We define
gk f k f k 2 »¯
¼ (4.109)
and hk ( f k f k 2 )W4k ¯½
Then
¥gW
1
144424443
F2 r k
rk
2 , r 0, 1
k0
(4.110)
¥
1
and F2 r 1 hk W2rk , r 0, 1
k0
It can be seen that the output is in the order F0, F2, F1 and F3. We now
consider the case N = 8. Let
fk = { f0, f1, f2, f3, f4, f5, f6, f7}.
Then
¥fW |, 7.
7
Fp k
pk
8 , p 0, 1,
k0
We split the above sum in terms of the first four and last four points as
Fp ¥
k 0,1, 2, 3
f k W8pk ¥
k 4,5, 6, 7
f k W8pk
¥
k 0,1, 2, 3
f k W8pk ¥
k 0,1, 2, 3
f k 4 W8p ( k 4)
(4.111)
Now,
W8p ( k + 4) = W8pk ⋅W84 p = (–1) p W8pk
¥
3
Fp ©f
« k
(–1) p f k 4 ¸º W8pk , p 0, 1, |, 7. (4.112)
k0
Since the right side of Eq. (4.112) consists of both even and odd Fourier
coefficients, we write
Fp = F2r + F2r+1,
172 CHAPTER 4: Least Squares and Fourier Transforms
where
¥[ f f
3
1444442444443
F2r k k 4 ]W8
2rk
k 0
¥[ f f
3
k
rk
k 4 ] W4 , r 0,1, 2, 3
k 0
(4.113)
¥[ f
3
and F2r 1 k fk 4 ]W8k (2r 1) ,
k 0
¥[ f
3
k f k 4 ] W4rk W8k , r 0,1, 2, 3
k 0
For brevity, let
f k f k 4 g k »¯
¼, k 0, 1, 2, 3 (4.114)
and W8k ( f k f k 4 ) hk ¯½
Then Eq. (4.113) becomes
»
¥gW
3
rk
F2 r ¯ k 4
k0 ¯
¼ , r 0, 1, 2, 3 (4.115)
¥
3
and F2 r 1 ¯
hk W4rk ¯
k0 ½
The flow-graph for the first stage of this algorithm is given in Fig. 4.10.
Clearly, this approach can be repeated at the second stage to split each of
the 4-point DFTs into two 2-point transforms. Flow-graph for this computation
is shown in Fig. 4.11.
SECTION 4.6: Fourier Approximation 173
In the general case, the final result is obtained after log2 N stages. Figure 4.12
shows the flow-graph for the 8-point decimation in frequency FFT.
We observe that the input is in the natural order, whereas the output for the
frequency components is in the bit-reversed order.
|, N 1.
N 1
fk
1
N
¥
p0
FpWN kp , k 0, 1,
Comparison with DFT shows that the factors W Nkp have changed signs, the
input and output have interchanged, and that the final output is divided by
N. Hence the flow-graph for the calculation of DFT can also be adopted for
the computation of inverse DFT after making the above changes.
Example 4.21 Using SandeTukey algorithm, find the DFT of the sequence
fk = {1, 2, 3, 4}.
We have the key-equations
1
144424443
F2r = ∑ gkW2rk
k =0
r = 0, 1
1
and F2r +1 = ∑ hkW2rk
k =0
where
gk = fk + fk+2 and hk = (fk fk+2) W4k
With fk = {1, 2, 3, 4}, we obtain
g0 = f0 + f2 = 4, g1 = f1 + f3 = 6;
h0 = f0 f2 = 2, h1 = (f1 f3) W41 = 2(i) = 2i
Hence
F0 = g0 + g1 = 10, F2 = g0 + g1 W21 = g0 g1 = 2
1
F1 = ∑ hkW20 = h0 + h1 = – 2 + 2i,
k =0
¥hW
1
F3 k 2
k
h0 h1W21 h0 – h1 2 2i.
k0
Hence
Fk {10, – 2 2i, 2, 2 2i} .
SECTION 4.6: Fourier Approximation 175
Example 4.22 Using SandeTukey algorithm, find the DFT of the sequence
fk = {1, 2, 3, 4, 4, 3, 2, 1}
We have
¥f W |, 7
7
Fp k
pk
8 , p 0, 1,
k 0
First stage:
¥ ¥hW
3 3
F2 r g k W4rk , F2 r 1 k
rk
4 , r 0, 1, 2, 3.
k0 k0
g k f k f k 4 , hk ( f k f k 4 ) W8k
Then
g0 = 5, g1 = 5, g2 = 5, g3 = 5,
h0 = 3, h1 = W81 , h2 = W82 , h3 = 3 W83 .
Second stage:
F2r = F4s + F4s+2, F2r+1 = F4t+1 + F4t+3,
1 1
F4 s = ∑ pk ⋅ W2sk , F4 s + 2 = ∑ qk ⋅W2sk , s = 0,1.
k =0 k =0
¥ ¥v
1 1
F4t 1 uk W2sk , F4t 3 k W2sk ,
k 0 k 0
Finally,
F0 = p0 + p1 = 20, F4 = p0 p1 = 0,
F2 = q0 + q1 = 0, F6 = q0 q1 = 0,
F1 = 3 i 2 2 i 2 = 5.828 i(2.414)
F5 = 3 i + 2 2 + i 2 = 0.172 + i(0.414)
F3 = v0 + v1 = 0.172 i(0.414)
F7 = v0 v1 = 5.828 + i(2.414)
EXERCISES
4.1 Explain the method of least squares to fit a straight line of the form Y
= a0 + a1x to the data (xi, yi):
x 1 2 3 4 5 6
y 2.4 3.1 3.5 4.2 5.0 6.0
4.2 Find the values of a0 and a1 so that Y = a0 + a1x fits the data given
in the table:
x 0 1 2 3 4
y 1.0 2.9 4.8 6.7 8.6
4.3 If the straight line Y = a0 + a1x is the best fit to the set of data points
(x1, y1), (x2, y2),
, (xn, yn), show that
x y 1
6xi 6yi n , i 1, 2, |, n.
6xi2 6xi yi 6xi
4.4 Use the method of least squares to fit the straight line Y = a + bx to
the data:
x 0 1 2 3
y 2 5 8 11
w 1 1 1 1
x 0 1 2 3 4
y 1 0 3 10 21
EXERCISES 177
x 0 1 2 3 4 5 6
y 71 89 67 43 31 18 9
x 2 4 6 8 10
y 4.077 11.084 30.128 81.897 222.62
4.9 Fit a function of the form y = axb for the following data:
x 61 26 7 2.6
y 350 400 500 600
a
4.10 Using the method of least squares, fit a curve of the form Y = + bx
to the following data (x, y): x
(1, 5.43), (2, 6.28), (4, 10.32), (6, 14.86), (8, 19.51).
4.11 Fit a function of the form y = A1e M1x + A2 eM2 x to the data given by
4.12 Write an algorithm to fit a linear least squares approximation to the data
(xi, yi), i = 1, 2,
, N.
4.13 If the functions f1(x) = 1, f2(x) = x are orthogonal on the interval
[1, 1], find the values of a and b so that the function f3 = 1 + ax + bx2 is
orthogonal to both f1 and f2 on [1, 1].
4.14 Define an orthogonal set of functions and show that the set
nQ x
f (x) = sin , n = 1, 2,
l
is orthogonal on [0, l].
4.15 Explain the difference between Fourier series and Fourier transform.
Find the Fourier series for the function defined by
¬ x, 1 x c 0
f ( x)
® x 2, 0 x c1
178 CHAPTER 4: Least Squares and Fourier Transforms
4.16 Define discrete Fourier transform (DFT) and inverse discrete Fourier
transform (IDFT).
Find the DFT of each of the following sequences using matrix method
(Problems 4.174.20):
4.17 {0, 1, 0, 1}
¬ 1 1 »
4.18 1, , 0, ¼
® 2 2½
4.19 {1, 2, 3, 1}
4.20 {2, 2, 4, 3}
find the DFT of each of the following sequences (Problems 4.21 4.23):
4.21 {1, 2, 3, 4}
4.22 {1, 1,
, 1}, N values.
4.23 {1, 1, 2, 2, 3, 3}
4.24 Write the computational steps for computing the DFT of a sequence
f(t) by the above formula and test it on Problem (4.21).
4.25 List any two properties of DFT and find the IDFT of the sequence {0,
1, 1, 0}.
4.26 State the key equations in the CooleyTukey algorithm for computing
the DFT of the sequence fp, p = 0, 1, 2, 3. Draw the flow-graph for
its computation.
Use the CooleyTukey algorithum to compute the DFT of each of the
following sequences (Problems 4.274.30):
4.27 {1, 1, 0, 0}
4.28 {1, 0, 1, 0}
4.29 {1, 1, 1, 1}
4.30 {1, 2, 1, 2}
4.31 Draw a flow-chart to implement the bit reversal procedure for the
CooleyTukey algorithm.
4.32 Write down the key equations in the CooleyTukey algorithm for
computing the 8-point DFT of the sequence fp, p = 0, 1, 2,
, 7, and
draw the flow-graph for its computation.
EXERCISES 179
Use the CooleyTukey algorithm to compute the DFT of each of the following
sequences (Problems 4.334.35):
4.33 {1, 1, 1, 1, 1, 1, 1, 1}
4.34 {1, 1, 1, 1, 1, 1, 1, 1}
4.35 {1, 2, 3, 4, 5, 6, 7, 8}
4.36 Explain the difference between CooleyTukey and SandeTukey algorithms
for an 8-point computation of the DFT of a sequence. Write down the
key equations of SandeTukey algorithm for computing the DFT of the
sequence fk, k = 0, 1, 2,
, 7.
Use SandeTukey algorithm to compute the DFT of each of the following
sequences (Problems 4.374.40):
4.37 {1, 1, 0, 0}
4.38 {1, 0, 1, 0}
4.39 {1, 2, 3, 4, 5, 6, 7, 8}
4.40 {0, 1, 0, 1, 0, 1, 0, 1}
4.41 Show that Tn(x) = cos (n cos1x) is a polynomial in x of degree n.
4.42 Show that the coefficient of xn in Tn(x) is 2n1.
4.43 Economize the series given by
x3 x5 x7
sinh x x "
6 120 5040
on the interval [1, 1], allowing for a tolerance of 0.0005.
Answers to Exercises
4.1 a1 = 0.503, a0 = 2.021.
4.2 a1 = 2.0, a0 = 0.8.
4.4 a = 2, b = 3.
4.5 a = 1, b = 3 and c = 2.
4.6 a = 81.93, b = 8.28, c = 0.78
4.8 a = 1.5, b = 0.5 = a1
4.9 a = 702, b = 0.17.
4.10 a = 3.02, b = 2.39.
4.11 l1 = 0.99, l2 = 0.96, A1 = 0.499, A2 = 0.491.
4.13 1 3x2.
2
4.15 a0 = 2, an = 0, bn = [1 2(1)n].
nQ
180 CHAPTER 4: Least Squares and Fourier Transforms
4.18 [1, 1 i 2 , 1, 1 + i 2 ]
4.19 [7, 2 i, 1, 2 + i]
4.20 [11, 2 + i, 1, 2 i]
4.21 F0 = 10, F1 = 2 + 2i, F2 = 2, F3 = 2 2i.
⎧N, p=0
4.22 Fp = ⎨
⎩0, p = 1, 2, …, N − 1
© 3 3 3 3 3 3 ¸
4.23 ª –1.5 i, 1.5 i, 12, 1.5 i 1.5 i¹
« 2 2 2 2 º
4.24 [10, 2 + 2i, 2, 2 2i]
4.25 fp = [0.5, 0.25 + 0.25i, 0, 0.25 0.25i]
4.26 F0e f 0 f 2 , F1e f 0 f 2 , F0o = f1 + f3 , F1o = f1 − f3 .
4.27 F0 = 2, F1 = 1 i, F2 = 0, F3 = 1 + i.
4.28 fk = {1, 0, 1, 0}, Fp = {2, 0, 2, 0}
4.29 fk = {1, 1, 1, 1}, Fp = {0, 0, 4, 0}
4.30 fk = {1, 2, 1, 2}, Fp = {6, 0, 0, 0}
4.33 Final stage: F0 = 0, F1 = 0, F2 = 0, F3 = 0; F4 = 8, F5 = 0,
F6 = 0, F7 = 0.
4.34 fk = {1, 1, 1, 1, 1, 1, 1, 1}, Fp = {8, 0, 0, 0, 0, 0, 0, 0}.
4.35 36, 4 + i(9.66), 4 + 4i, 4 + i(1.66), 4, 4 i(1.66), 4 4i, 4
i(9.66).
4.37 Fp = {2, 1 i, 0, 1 + i}
4.38 F0 = 2, F2 = 2, F1 = 0, F3 = 0.
4.39 F p = {36, 4 + 9.66i, 4 + 4i, 4 + 1.66i, 4, 4 1.66i,
4 4i, 4 9.66i}
4.40 Fp = {4, 0, 0, 0, 4, 0, 0, 0}
4.41 Hint: Use mathematical induction
4.42 T1(x) = 211x, T2(x) = 221x2 1,
T3(x) = 231x3 2x, T4(x) = 241x4 8x2 + 1.
383 17 3
4.43 sinh x = x+ x .
384 96
Chapter
Spline Functions
5.1 INTRODUCTION
181
182 CHAPTER 5: Spline Functions
Let the given points be A(1, 8), B(2, 1) and C(3, 18). Equation of
AB is
s1(x) = 8 + (x 1)7 = 7x 15,
and equation of BC is
s2(x) = 1 + (x 2)19 = 19x 39,
Since x = 2.5 belongs to the interval [2, 3], we have
1 ⎡ ( xi − x)2 ( x − xi −1 )2 ⎤
si ( x) = ⎢− mi −1 + mi ⎥ + ci , (5.8)
hi ⎣⎢ 2 2 ⎥⎦
where ci are constants to be determined. Putting x = xi1 in Eq. (5.8), we get
2
1 hi h
ci = yi −1 + mi −1 = yi −1 + i mi −1.
hi 2 2
Hence Eq. (5.8) becomes:
1 ⎡ ( xi − x) 2 ( x − xi −1 )2 ⎤ h
si ( x) = ⎢− mi −1 + mi ⎥ + yi −1 + i mi −1. (5.9)
hi ⎢⎣ 2 2 ⎥⎦ 2
In Eq. (5.9), the mi are still unknown. To determine the mi, we use the
condition of continuity of the function since the first derivatives are already
continuous. For the continuity of the function si(x) at x = xi, we must have
si(xi) = si+1(xi+) (5.10)
From Eq. (5.9), we obtain
hi h
si ( xi −) = mi + yi −1 + i mi −1
2 2
hi (5.11)
= (mi −1 + mi ) + yi −1.
2
Further,
1 ⎡ ( xi +1 − x) 2 ( x − xi ) 2 ⎤ h
si +1 ( x) = ⎢− mi + mi +1 ⎥ + yi + i +1 mi ,
hi +1 ⎣⎢ 2 2 ⎦⎥ 2
184 CHAPTER 5: Spline Functions
and therefore
hi +1 h
si +1 ( xi + ) = − mi + yi + i +1 mi = yi . (5.12)
2 2
Equality of Eqs. (5.11) and (5.12) produces the recurrence relation
2
mi −1 + mi = ( yi − yi −1 ), i = 1, 2, ! , n (5.13)
hi
for the spline first derivatives mi. Equations (5.13) constitute n equations in
(n + 1) unknowns, viz, m0, m1,
, mn. Hence, we require one more condition
to determine the mi uniquely. There are several ways of choosing this condition.
One natural way is to choose s1¢¢(x1) = 0, since the mechanical spline straightens
out in the end intervals. Such a spline is called a natural spline. Differentiating
Eq. (5.9) twice with respect to x, we obtain
1
si′′( x) = (−mi −1 + mi ),
hi
or
1
s′′1 ( x1 ) = (m1 − m0 ).
h1
Hence, we have the additional condition as
m0 = m1. (5.14)
Therefore, Eqs. (5.13) and (5.14) can be solved for mi, which when substituted
in Eq. (5.9) gives the required quadratic spline.
Example 5.2 Determine the quadratic splines satisfying the data given in
Example 5.1. Find also approximate values of y (2.5) and y¢(2.0).
We have n = 2 and h = 1. Equation (5.13) gives
m0 + m1 = 14 and m1 + m2 = 38.
Since m0 = m1, we obtain m0 = m1 = 7, and m2 = 31.
Hence, Eq. (5.9) gives:
( x2 − x)2 ( x − x1 ) 2 7
s2 ( x) = − (7) + (31) − 1 +
2 2 2
(3 − x)2 31 5
=− (7) + ( x − 2) 2 +
2 2 2
= 12 x 2 − 41x + 33,
which is the spline in the interval [2, 3].
Hence,
y(2.5) » s2(2.5) = 5.5 and y¢(2.0) » 7.0.
SECTION 5.2: Cubic Splines 185
The quadratic spline s1(x) in the interval [1, 2] can be determined in a similar
way. A straightforward way of deriving the quadratic splines is as follows:
Since si(x) is a quadratic in (xi1, xi), we can write
si(x) = ai + bix + cix2, (5.15)
where ai, bi and ci are constants to be determined. Clearly, there are 3n constants
and therefore we require 3n conditions to determine them. These conditions
are obtained by using the properties of the quadratic spline. Firstly, we use
the condition that the spline passes through the interior points. This means
si(xi) = ai + bixi + cixi2 i = 1, 2,
, n 1. (5.16)
Next, si(x) is continuous at x = xi. This condition requires
si(xi) = si+1(xi+). (5.17)
Hence, we must have
ai + bi xi + ci xi2 = ai +1 + bi +1 xi + ci +1 xi2 ,
i = 1, 2,
, n 1. (5.18)
Again, s¢i(x) is continuous at x = xi. This gives
bi + 2cixi = bi+1 + 2ci+1xi, i = 1, 2,
, n 1. (5.19)
We thus have 3n 3 conditions and we require three more conditions. Since the
spline passes through the end points also, we must have
y0 = a1 + b1 x0 + c1 x02 (5.20)
and
yn = an + bn xn + cn x n2 . (5.21)
Finally, for the natural spline, we have
s¢¢1(x0) = 0, (5.22)
and this gives
c1 = 0. (5.23)
We have, thus, a completed system of 3n equations in 3n unknowns.
Although this system can certainly be solved, it is obviously more expensive
and, therefore, this method is less preferred to the previous one.
The discontinuity in the second derivatives is an obvious disadvantage of
the quadratic splines and this drawback is removed in the cubic splines
discussed below.
We consider the same set of data points, viz., the data defined in Eq. (5.1),
and let si(x) be the cubic spline defined in the interval [xi1, xi]. The conditions
for the natural cubic spline are
186 CHAPTER 5: Spline Functions
1 ⎡ ( xi − x)3 ( x − xi −1 )3 ⎤
si ( x) = ⎢ M i −1 + M i ⎥ + ci ( xi − x) + di ( x − xi −1) , (5.25)
hi ⎣⎢ 6 6 ⎥⎦
where ci and di are constants to be determined.
Using conditions si(xi1) = yi1 and si(xi) = yi, we immediately obtain
1 ⎛ h2 ⎞ 1 ⎛ h2 ⎞
ci = ⎜ yi −1 − i M i −1 ⎟ and di = ⎜ yi − i M i ⎟ . (5.26)
hi ⎜ 6 ⎟ hi ⎜ 6 ⎟
⎝ ⎠ ⎝ ⎠
Substituting for ci and di in Eq. (5.25), we obtain
1 ⎡ ( x − x)3 ( x − xi −1 )
3
⎛ h2 ⎞
si ( x) = ⎢ i
M i −1 + M i + ⎜ yi −1 − i M i −1 ⎟ ( xi − x)
hi ⎢⎣ 6 6 ⎜ 6 ⎟
⎝ ⎠
⎛ h2 ⎞ ⎤ (5.27)
+ ⎜ yi − i M i ⎟ ( x − xi −1 ) ⎥ .
⎜ 6 ⎟ ⎥⎦
⎝ ⎠
In Eq. (5.27), the spline second derivatives, Mi, are still not known. To
determine them, we use the condition of continuity of s¢i(x). From Eq. (5.27),
we obtain by differentiation:
1 ⎡ −3( xi − x ) 2 3( x − xi −1 ) 2
si′ ( x ) = ⎢ M i −1 + Mi
hi ⎢⎣ 6 6
⎛ h2 ⎞ ⎛ h2 ⎞⎤
− ⎜ yi −1 − i M i −1 ⎟ + ⎜ yi − i M i ⎟ ⎥
⎜ 6 ⎟ ⎜ 6 ⎟⎥
⎝ ⎠ ⎝ ⎠⎦
SECTION 5.2: Cubic Splines 187
hi 1⎛ h2 ⎞ 1 ⎛ h2 ⎞
sí′ ( xi −) = M i − ⎜ yi −1 − i M i −1 ⎟ + ⎜ yi − i M i ⎟
2 hi ⎜⎝ 6 ⎟ hi
⎠
⎜
⎝ 6 ⎟
⎠
1 h h
= ( yi − yi −1 ) + i M i −1 + i M i (i = 1, 2, ! , n). (5.28)
hi 6 3
To obtain the right-hand derivative, we need first to write down the equation
of the cubic spline in the subinterval (xi, xi+1). We do this by setting i = i + 1
in Eq. (5.27)
⎡ ⎛ h i2+1 ⎞
1 ⎢ ( xi +1 − x )3 ( x − xi )3 ⎜
si +1 ( x) = Mi + M i +1 + yi − M i ⎟ ( xi +1 − x)
hi +1 ⎢ 6 6 ⎜ 6 ⎟
⎣ ⎝ ⎠
⎛ h i2+1 ⎞ ⎤
⎜
+ yi +1 − M i +1 ⎟ ( x − xi ) ⎥ , (5.29)
⎜ 6 ⎟ ⎥
⎝ ⎠ ⎦
where hi + 1 = xi + 1 xi. Differentiating Eq. (5.29) and setting x = xi, we obtain the
right-hand derivative at x = xi
1 h h
sí′+1 ( xi +) = ( yi +1 − yi ) − i +1 M i − i +1 M i +1 (i = 0, 1, ! , n − 1). (5.30)
hi +1 3 6
Equality of Eqs. (5.28) and (5.30) produces the recurrence relation
hi 1 h
M i −1 + (hi + hi +1 ) M i + i +1 M i +1
6 3 6
yi +1 − yi yi − yi −1 (i = 1, 2, ! , n − 1). (5.31)
= −
hi +1 hi
For equal intervals, we have hi = hi + 1 = h and Eq. (5.31) simplifies to
6
M i −1 + 4M i + M i +1 =
( yi +1 − 2 yi + yi −1 ), (i = 1, 2, ! , n − 1). (5.32)
h2
The system of Eq. (5.31) has some special significance. If M0 and Mn are
known, then the system can be written as
188 CHAPTER 5: Spline Functions
⎛y −y y − y0 ⎞ ⎫
2(h1 + h2 ) M1 + h2 M 2 = 6 ⎜ 2 1 − 1 ⎟ − h1M 0 ⎪
⎝ h2 h1 ⎠ ⎪
⎪
⎛ y3 − y2 y2 − y1 ⎞ ⎪
h2 M1 + 2(h2 + h3 ) M 2 + h3 M 3 = 6 ⎜ − ⎟ ⎪
⎝ h3 h2 ⎠ ⎪
⎪ (5.33)
⎬
⎛ y4 − y3 y3 − y2 ⎞ ⎪
h3 M 2 + 2(h3 + h4 ) M 3 + h4 M 4 = 6 ⎜ − ⎟
⎝ h 4 h3 ⎠ ⎪
⎪
# ⎪
⎪
⎛ y −y y −y ⎞
hn −1M n −2 + 2(hn −1 + hn ) M n−1 = 6 ⎜ n n −1 − n −1 n− 2 ⎟ − hn M n .⎪
⎝ hn hn−1 ⎠ ⎪⎭
It should be noted that the tabulated function is y = x3 9 and hence the exact
values of y(2.5) and y¢(2.0) are, respectively, 6.625 and 12.0. The convergence
to the actual values, with the increase in the order of the spline, is clearly seen
from Examples 5.1, 5.2 and 5.3.
In many applications, it will be convenient to work with the spline first
derivatives. Denoting sí′ ( xi ) = mi and taking suitable combinations of
Eqs. (5.28) and (5.30), we can derive the following relationship for the mi :
SECTION 5.2: Cubic Splines 189
1 ⎛1 1 ⎞ 1
mi −1 + 2 ⎜ + ⎟ mi + mi +1
hi ⎝ hi hi +1 ⎠ hi +1
3 3
= ( yi +1 − yi ) + ( yi − yi −1 ), i = 1, 2, ! , n − 1. (5.34)
h i2+1 h i2
The above result can easily be derived using the Hermite interpolation formula
given in Section 3.9.3.
For equally spaced knots, Eq. (5.34) assume the simpler form:
3
mi −1 + 4mi + mi +1 = ( yi +1 − yi −1 ), i = 1, 2, ! , n − 1. (5.36)
h
Equations (5.32) or (5.36) constitute (n 1) equations in (n + 1) unknowns,
viz., m0, m1,
, mn. Clearly, two further relations are required in order that
a unique interpolating spline may be found. These conditions are called the
end conditions and are discussed in detail in Kershaw [1971, 1972].
Specifically, we mention three types of end conditions:
ii(i) Natural cubic spline: M0 = Mn = 0
i(ii) D1 spline: si¢(x0) = y¢(x0), si¢(xn) = y¢(xn),
(iii) D2 spline: si¢¢(x0) = M0 = y¢¢(x0) and si¢¢(xn) = Mn = y¢¢(xn).
The following example demonstrates the improvement in accuracy of the
cubic spline interpolates with successive interval halving.
Example 5.4 Given the points (0, 0), (p/2,1) and (p, 0) satisfying the function
y = sin x (0 £ x £ p), determine the value of y (π /6) using the cubic spline
approximation.
We have n = 2 and h = p/2. The recurrence relation for the spline second
derivatives gives:
6×4 48
M 0 + 4 M1 + M 2 = (0 − 2 + 0) = − .
Q 2
Q2
For the natural spline, we have M0 = M2 = 0. Hence, we have
12
M1 = −
Q2
190 CHAPTER 5: Spline Functions
2 ⎛ 2 x3 3 x ⎞
s1 ( x) = ⎜− + ⎟.
Q ⎜⎝ Q 2 2 ⎟⎠
Hence
⎛Q ⎞ ⎛Q ⎞ 2 ⎛ Q Q⎞
y ⎜ ⎟ ≈ s1 ⎜ ⎟ = ⎜ − + ⎟ = 0.4815.
⎝ ⎠
6 ⎝ ⎠
6 Q ⎝ 108 4⎠
We next take h = p /4, i.e., the data points are (0, 0), (Q / 4, 1/ 2), (p/2,1),
(3Q /4,1/ 2) and (Q , 0) . In this case, the recurrence relation gives:
4 M1 M 2 4.029 »
¯¯
M1 4 M 2 M 3 5.699 ¼ (i)
¯
M 2 4 M 3 4.029 ¯½
5 0.087155743 0.087155530
15 0.258819045 0.258818415
25 0.422618262 0.422617233
35 0.573576436 0.573575040
45 0.707106781 0.707105059
SECTION 5.2: Cubic Splines 191
Example 5.5 Given the points (1, 6), (2, 18), and (3, 42), satisfying the
function y = x3 + 5x, determine the cubic spline in the interval [1, 2] using
the end conditions y¢(1) = 8 and y¢(3) = 32.
We have h = 1 and n = 2. The recurrence relation is
m0 + 4m1 + m2 = 3(y2 y0)
Þ 40 + 4m1 = 3(42 6) = 108
Þ m1 = 17.
In [1, 2], the cubic spline is given by
s1(x) = m0(x1 x)2 (x x0) m1(x x0)2 (x1 x)
+ y0(x1 x)2 [2(x x0) + 1] + y1(x x0)2[2(x1 x) + 1]
Substituting the values of xi, yi and mi, we obtain
s1(x) = x3 + 5x,
which is the tabulated function itself. In this case, the spline interpolation is
exact because the two end conditions prescribed are exact and the tabulated
function is a cubic.
will be minimum if and only if z(x) º s(x). This means that s(x) is the
smoothest function interpolating to the set of data points defined above, since
the second derivative is a good approximation to the curvature of a curve. We
write
b b
∫a [ z ′′( x)]2 dx = ∫ a [s′′( x) + z′′( x) − s′′( x)] dx
2
b b
= ∫a [ s′′( x) 2 dx + 2 ∫ a s′′( x)[ z′′( x) − s′′( x)] dx
b
∫ a [ z′′( x) − s′′( x)] dx. (5.38)
2
+
192 CHAPTER 5: Spline Functions
Now,
b n −1 xi +1
∫a s ′′( x)[ z ′′( x) − s′′( x)] dx = ∑∫ x i
s ′′( x)[ z ′′( x) − s′′( x)] dx
i =0
n −1
= ∑{s′′( x)[ z′( x) − s′( x)]} xx i +1
i
i =0
n −1 xi +1
− ∑∫x i
s ′′′( x)[ z ′( x) − s ′( x)] dx. (5.39)
i =0
The first term in Eq. (5.39) simplifies to
s′′( xn )[ z ′( xn ) − s′( xn )] − s ′′( x0 )[ z ′( x0 ) − s ′( x0 )].
Since s′′( xn ) = s ′′( x0 ) = 0, the above expression vanishes. Similarly, the second
term in Eq. (5.39) is zero since s¢¢¢(x) has a constant value in each interval
and s(xi) = z(xi) = yi, for all i. Hence, Eq. (5.38) becomes
b b b
∫a [ z ′′( x)]2 dx = ∫a [s′′( x)]2 dx + ∫ a [ z′′( x) − s′′( x)] dx
2
(5.40)
or
b b
∫a [ z ′′( x)]2 dx ≥ ∫ a [s′′( x)] dx.
2
(5.41)
1 2 iv 1 4 vi
s bb ( xi ) y bb( xi ) h y ( xi ) h y ( xi ) O( h6 ) (5.44)
12 360
1 1 2 v
< s bbb ( xi ) s bbb ( xi –) > y bbb ( xi ) h y ( xi ) O( h4 ) (5.45)
2 12
1 5 viii
s bbb( xi ) s bbb ( xi –) hy iv ( xi ) – h y ( xi ) O( h7 ) (5.46)
720
From the above equations, we obtain
y b( xi ) s b( xi ) O( h4 ) (5.47)
1 2 iv
y bb( xi ) s bb( xi ) h y ( xi ) O( h4 ) (5.48)
12
1
y bbb( xi ) < s bbb ( xi ) s bbb ( xi –)> O( h )
2
(5.49)
2
1
y iv ( xi ) < s bbb ( xi ) – s bbb ( xi –)> O( h )
4
(5.50)
h
These relations can be established* by using the spline recurrence relations
together with the operators E and D.
The cubic splines derived in the previous section can be extended to functions
of two or more variables. We derive the formulae for functions of two variables,
the extension to higher dimensions being straightforward.** Let Li(x) be natural
cubic splines which satisfy
Li ( xj ) = E ij = 1, j = i ⎪⎫
⎬ (5.51)
= 0, j ≠ i.⎪⎭
These splines bear the same relation to the general cubic spline as the Lagrange
polynomials bear to the Lagrange interpolation polynomial. Due
to this reason, we call them cardinal splines. Let s(x) be the natural
cubic spline, in xj1 £ x £ xj, corresponding to the set of data points (xj, yj),
j = 0, 1, 2,
, n. Then, Li(x) are the cardinal splines corresponding to the
set of data points (xj, di, j), where di, j is the Kronecker delta defined above.
1 ⎡ ( x j − x )3 ( x − x j −1 )3 ⎛ h2 ⎞
Li ( x ) = ⎢ M i, j −1 + M i , j + ( xj − x) ⎜ E i , j −1 − M i, j −1 ⎟
h ⎢⎣ 3! 3! ⎜ 3! ⎟
⎝ ⎠
⎛ h2 ⎞⎤
+ ( x − x j −1 ) ⎜ E i , j − M i, ⎟⎟ ⎥ , (5.52)
⎜ j
⎝ 3! ⎠ ⎦⎥
where Mi, j = Li¢¢(xj). It is easy to verify that Eq. (5.52) satisfies conditions
(5.51). As in the case of general splines, the condition of continuity of the
first derivatives leads to the recurrence relation
6
M i , j −1 + 4M i, j + M i , j +1 = (E i, j −1 − 2E i , j + E i, j +1 ). (5.53)
h2
In terms of the cardinal splines Li(x), the general spline s(x), in the interval
xj1 £ x £ xj, can be written as
n
s ( x) = ∑ Li ( x) yi , (5.54)
i=0
where Li(x) and Lj(y) are given by formulae of the type given in Eq. (5.52). The
spline second derivatives, Mij, are calculated from the recurrence relation
(5.53) by imposing the natural end conditions, Mi,0 = Mi,n = 0.
The following examples demonstrate the use of the formulae derived
above.
Example 5.6 Using the data of Example 5.1, viz., (1, 8), (2, 1) and
(3, 18), find the cardinal splines Li(x) and hence determine the general natural
cubic spline in the interval 1 £ x £ 2.
For the interval 1 £ x £ 2 we have j = 1. With h = 1, and j = 1, Eq. (5.52)
gives:
SECTION 5.3: Surface Fitting by Cubic Splines 195
(2 − x)3 ( x − 1)3 ⎛ 1 ⎞
Li ( x) = M i, 0 + M i, 1 + (2 − x) ⎜ E i , 0 − M i, 0 ⎟
6 6 ⎝ 6 ⎠
⎛ 1 ⎞
+ ( x − 1) ⎜ E i, 1 − M i, 1 ⎟
⎝ 6 ⎠
( x − 1)3 ⎛ 1 ⎞
= M i , 1 + (2 − x) E i, 0 + ( x − 1) ⎜ E i, 1 − M i , 1 ⎟ , (i)
6 ⎝ 6 ⎠
since Mi,0 = 0 for the natural cubic spline.
Similarly, the recurrence relation (5.53), becomes:
4Mi,1 = 6(di,0 2di,1 + di,2),
from which we obtain
3 3
M 0, 1 = , M1, 1 = −3, M 2, 1 = .
2 2
Hence, (i) gives:
( x − 1)3 ⎛ 3 ⎞ ⎛ 1⎞ 1 3 5 9
L0 ( x) = ⎜ ⎟ + (2 − x) + ( x − 1) ⎜ − ⎟ = ( x − 1) − x + , (ii)
6 ⎝2⎠ ⎝ 4⎠ 4 4 4
1 3
L1 ( x) = − ( x − 1)3 + ( x − 1), (iii)
2 2
1 1
L2 ( x) = ( x − 1)3 − ( x − 1). (iv)
4 4
⎡1 5 9⎤ ⎡3 1 ⎤
= ⎢ ( x − 1)3 − x + ⎥ (−8) + ⎢ ( x − 1) − ( x − 1)3 ⎥ (−1)
⎣ 4 4 4 ⎦ ⎣ 2 2 ⎦
⎡1 1 ⎤
+ ⎢ ( x − 1)3 − ( x − 1) ⎥ (18)
⎣4 4 ⎦
= 3( x − 1)3 + 4 x − 12,
which is the same as that obtained in Example 5.3. The next example
demonstrates the use of cardinal splines in surface fitting.
Example 5.7 The function z = f (x, y) satisfies the following data for 0 £ x, y
£ 2. Determine the natural cubic spline s(x, y) which approximates the above
data and hence find the approximate value of z(0.5, 0.5).
196 CHAPTER 5: Spline Functions
x
y 0 1 2
0 1 2 9
1 2 3 10
2 9 10 17
For determining z(0.5, 0.5), we need to obtain the natural cubic spline
for the interval 0 £ x, y £ 1.
With h = 1, j = 1, we have
(1 − x)3 x3 ⎛ 1 ⎞ ⎛ 1 ⎞
Li ( x) = M i, 0 + M i , 1 + (1 − x) ⎜ E i , 0 − M i , 0 ⎟ + x ⎜ E i, 1 − M i, 1 ⎟
6 6 ⎝ 6 ⎠ ⎝ 6 ⎠
x3 ⎛ 1 ⎞
= M i , 1 + (1 − x) E i , 0 + x ⎜ E i , 1 − M i, 1 ⎟ , (i)
6 ⎝ 6 ⎠
2 2
s ( x, y ) = ∑ ∑ Li ( x) L j ( y) zi, j
i=0 j =0
= L0 ( x) [ L0 ( y ) z0, 0 + L1 ( y ) z0, 1 + L2 ( y ) z0, 2 ]
13 ⎛ 13 11 3 ⎞ 11 ⎛ 13 11 3 ⎞
= ⎜ × 1 + × 2 − × 9 ⎟ + ⎜ × 2 + × 3 − × 10 ⎟
32 ⎝ 32 16 32 ⎠ 16 ⎝ 32 16 32 ⎠
3 ⎛ 13 11 3 ⎞
− ⎜ × 9 + × 10 − × 17 ⎟
32 ⎝ 32 16 32 ⎠
= 0.875.
The cubic spline formulae derived in the preceding section are global in
nature, which means that they do not permit any local changes in the given
data. Hence, efforts were made to derive spline formulae which are nonglobal.
We require basis functions which allow the degree of the resulting curve to
be changed without any change in the data. The B-splines are such basis
functions which have important applications in computer graphics. The B-splines
can be of any degree but those of second or third degree are usually found
to be sufficient.
The theory of B-splines was first suggested by Schoenberg [1946], but
recurrence formulae for their computation were discovered independently by
Cox [1972] and de Boor [1972].
A B-spline of order n (or degree n 1), denoted by sn,i(x), is a spline of
degree (n 1) with knots kin, kin+1,
, ki, which is zero everywhere except
in the interval k in < x < k i . The cubic B-spline s 4,i (x) with knots
ki4, ki3, ki2, ki1, ki, is such that
(i) on each interval, s4,i(x) is a polynomial in x of degree 3 or less,
(ii) s4,i(x), s¢4,i(x) and s¢¢4,i(x) are continuous, and
(iii) s4,i(x) > 0 inside [ki4, ki] and is identically zero outside [ki4, ki].
A typical cubic B-spline with knots ki4, ki3, ki2, ki1, ki, is shown in
Fig. 5.1.
¥ ¥ C (x k )
3 i
s4,i ( x ) Br xr m
3
m (5.58)
r0 mi – 4
( ki –4 x )3
( ki –4 – ki –3 )( ki –4 – ki –2 )( ki –4 – ki –1 )( ki –4 – ki )
( ki –3 x )3
( ki –3 – ki –4 )( ki –3 – ki –2 )( ki –3 – ki –1 )( ki –3 – ki )
( ki x )3
" (5.60)
( ki – ki –4 )( ki – ki –3 )( ki – ki –2 )( ki – ki –1 )
Denoting
P4,i (x) = (x ki4)(x ki3)(x ki2)(x ki1)(x ki) (5.61)
We obtain
P¢4,i (ki) = (ki ki4)(ki ki3)(ki ki2)(ki ki1) (5.62)
Hence, Eq. (5.60) can be written as
( ki –4 x )3 ( ki –3 x )3 ( ki –2 x )3
s4,i ( x )
b i ( ki –4 ) 3 4,
3 4, b i ( ki –3 ) 3 4,
b i ( ki –2 )
( ki –1 x )3 ( ki x )3
b i ( ki –1 ) 3 4,
3 4, b i ( ki )
¥
i
( km x )3
(5.63)
mi 4
b i ( km )
3 4,
SECTION 5.4: Cubic B-Splines 199
¥
i
( km x )3
(5.65)
mi n
3 nb ,i ( km )
where
3 n,i ( x ) ( x – ki n )( x – ki n1 ) | (x k ) i (5.66)
and Pn,i(x) denoting its derivative with respect to x. From the definition of
a divided difference, we have
sn –1,i ( x ) – sn –1,i –1 ( x )
sn,i ( x ) (5.69)
ki – ki – n
In practice, however, formulae given in Eqs. (5.58), (5.68) and (5.69) are not
used since they are found to be computationally inefficient. Instead, a recurrence
formula discovered independently by Cox [1972] and de Boor [1972] is
found to be efficient. This formula is
s1,i –3
s2,i –2
s1,i –2 s3,i –1
s2,i –1 s4,i
s1,i –1 s3,i
s2,i
s1,i
Figure 5.2 Array of elements for computing s4,i.
¬ 1
¯k – k if k j –1 c x k j
s1, j j j –1 (5.71)
¯
® 0, otherwise.
For example, if ki4 £ x < ki3, the array in Fig. 5.2 simplifies to the following
Fig. 5.3.
s1,i –3
s2,i –2
0 s3,i –1
0 s4,i
0 0
0
0
Figure 5.3 Simplified array of Fig. 5.2.
The numerical computation of B-splines will now become more simpler. The
following examples demonstrate the use of formulae (5.64) and (5.70) for the
computation of B-splines.
¥
i
( km – x )3
s4,i ( x ) (i)
mi – 4
3 4,
b i ( km )
(a) x = 1
Here i = 4, k0 = 0, k1 = 1, k2 = 2, k3 = 3 and k4 = 4.
SECTION 5.4: Cubic B-Splines 201
Therefore,
¥
4
( km x )3
s4,4 (1)
m0
b ( km )
3 4,4
Now,
P¢4,4(2) = (2 0)(2 1)(2 3)(2 4) = 4,
P¢4,4(3) = (3 0)(3 1)(3 2)(3 4) = 6,
and
P¢4,4(4) = (4 0)(4 1)(4 2)(4 3) = 24.
Hence, (ii) gives
1 8 27
s4,4 (1) –
4 6 24
1
.
24
(b) x = 2
We have
(3 2)3 (4 2)3
s4,4 (2)
b (3) 34,4
34,4 b (4)
1 8 1
.
–6 24 6
Example 5.9 With the same data as in Example 5.8, compute cubic
B-splines at x = 1 and x = 2, using formula (5.70).
The formula is
( x ki –4 ) s3,i –1 ( x ) ( ki – x )s3,i
s4,i ( x ) (iii)
ki – ki –4
(a) x = 1
1
We have 1 £ x < 2. Then s1,2 = = 1.
k2 – k1
202 CHAPTER 5: Spline Functions
0
0
0 s3,3
s2,3 s4,4
s1,3 s3,4
s2,4
0
(2 – k1 )s1,2 (3 – 2) s1,3 1
s2,3 ,
3 – k1 2
(2 – k2 )s1,3 (4 – 2)s1,4
s2,4 0,
2
SECTION 5.4: Cubic B-Splines 203
(2 – 0)s2,2 (3 – 2)s2,3 1
s3,3
3 6
(2 – 1)s2,3 (4 – 2)s2,4 1
s3,4 ,
3 6
(2 – 0)s3,3 (4 – 2)s3,4 1
and s4,4 .
4 6
EXERCISES
3
5.1 The function y = x + 9 is tabulated below.
(3, 36), (4, 73), (5, 134)
Predict the value of y(4.5) using quadratic and natural cubic splines and
state the absolute error in each case.
5.2 Given the points (0, 0), (p /2, 1) and (p, 0) satisfying the function y =
sin x, 0 £ x £ p, determine the value of y (p/6) using quadratic spline
approximation. Compare your result with that obtained in Example 5.5.
5.3 Determine the cubic spline s(x) valid in the interval [x0, x1] for the
following data, given that
s¢¢(x0) = y¢¢(x0) and s¢¢(x2) = y¢¢(x2).
Find y(6.3).
5.4 Fit (a) a natural cubic spline and (b) a D1 cubic spline to the following
data:
x 0.10 0.20 0.30
ye x
1.1052 1.2214 1.3499
Find y(0.15) in each case and state which of these is the best fit.
5.5 Derive the cubic spline formula with D1 end conditions. Show that
1 4 v
s b( xi ) yib – h yi O( h6 )
180
Given that the data
(1, 1), (0, 0) and (1, 1)
satisfies the function y = f (x) in 1 £ x £ 1, find the cubic spline
approximation of y (0.5) if y¢(1) = 4 and y¢(1) = 4.
5.6 Determine the cubic spline in 0 £ x £ 1 representing the data points and
the end conditions given in Question 5.5 above.
5.7 Write an algorithm to implement formula (5.27) for computing a cubic
spline in the interval [xi1, xi].
5.8 The data points
(2, 16), (0, 0), (2, 16)
satisfy the relation y = f (x) in the interval 2 £ x £ 2. Determine
the cubic spline valid in this interval and satisfying the end conditions
y¢(2) = 32 and y¢(2) = 32.
EXERCISES 205
5.9 Show that the error in the spline second derivative is given by
1 2 iv
s bb( xi ) yibb h yi O( h4 ).
12
5.10 Prove the minimization property of Section 5.2.1 for the D1 spline.
5.11 If the function y (x) is periodic with period (xn x0), the spline is called
a periodic spline. In this case, we have
s0( r ) ( x ) sn( r ) ( x ), r 0,1, 2.
Using these conditions, obtain the recurrence relation in the matrix
form.
5.12 If the end conditions are taken as
M0 + M2 M + M n –2
M1 = and M n –1 = n ,
2 2
then the spline curve is the same as the single cubic which is fitted
throughout to the given data.
For the data points
(2, 12), (1, 8), (0, 3.9), (1, 0.1),
the single cubic which fits these points is given by
1 3 3 2 241
y=– x − x + x − 3.9.
15 20 60
Find the cubic spline which fits this data with the above end conditions.
5.13 The following table gives the values of z = f (x, y) for different values
of x and y. Use the method of Section 5.3 to find z when
x = 1.5 and y = 1.5. Compare your result with the actual value obtained
from z = f (x, y) = x2 + y2 + y.
y x 1 2 3
1 3 6 11
2 7 10 15
3 13 16 21
find the cardinal splines Li(x) and hence determine the natural cubic
spline valid in the interval 0 £ x £ 2.
206 CHAPTER 5: Spline Functions
5.15 Using the formula (5.58), determine the cubic B-spline s(x) with support
[0, 4] on the knots 0, 1, 2, 3, 4. State whether this is a unique representation.
5.16 With respect to the knots 0, 1, 2, 3, 4, 5, 6, compute B-splines of order
6 at x = 1 using Coxde Boor recurrence formula.
Answers to Exercises
5.1 106.75 (error = 6.625); 103 (error = 2.875)
5.2 0.3333
5.3 11.5953
5.4 1.1622; 1.1618
5.5 s1(0.5) = 0
5.6 s2(x) = 2x3 x2, 0 £ x £ 1
5.8 4x2 4x3; 4x2 + 4x3
1 3 3 2 241
5.12 s1 ( x ) – x x x 3.9
15 20 60
5.13 6.125
3 3 1
5.14 s( x ) x – x – 5, 0 c x c 1
2 2
3
5.15 s( x ) c3 ©« x 4( x 1)3 6( x 2)3 – 4( x – 3)3 ¸
º
1 1
5.16 s1,3 1, s2,3 , s3,4 ,
2 6
1 1
s4,5 , s4,6 0 s5,6 ,
24 120
1
s5,7 0 s6,7 .
720
Chapter
6.1 INTRODUCTION
207
208 CHAPTER 6: Numerical Differentiation and Integration
dy dy du 1 ⎛ 2u − 1 2 3u 2 − 6u + 2 3 ⎞
= = ⎜ 'y0 + ' y0 + ' y0 + " ⎟ . (6.3)
⎜
dx du dx h ⎝ 2 6 ⎟
⎠
This formula can be used for computing the value of dy/dx for non-tabular
values of x. For tabular values of x, the formula takes a simpler form, for
by setting x = x0 we obtain u = 0 from Eq. (6.2), and hence Eq. (6.3) gives
⎡ dy ⎤ 1⎛ 1 1 1 ⎞
⎢ dx ⎥ = ⎜ 'y0 − ' 2 y0 + '3 y0 − ' 4 y0 + " ⎟ . (6.4)
⎣ ⎦ x = x0 h ⎝ 2 3 4 ⎠
Differentiating Eq. (6.3) once again, we obtain
⎡d2y⎤ 1 ⎛ 11 ⎞
⎢ 2⎥ = 2 ⎜ ' 2 y0 − '3 y0 + ' 4 y0 + " ⎟ . (6.6)
⎢⎣ dx ⎥⎦ x = x h ⎝ 12 ⎠
0
⎡ dy ⎤ 1⎛ 1 1 ⎞
⎢ dx ⎥ = ⎜ ∇ yn + ∇ 2 yn + ∇ 3 yn + " ⎟ (6.7)
⎣ ⎦ x = xn h ⎝ 2 3 ⎠
and
⎡d2y ⎤ 1 ⎛ 11 5 ⎞
⎢ 2⎥ = 2 ⎜ ∇ 2 yn + ∇ 3 yn + ∇ 4 yn + ∇ 5 yn + " ⎟ . (6.8)
⎣⎢ dx ⎦⎥ x = x h ⎝ 12 6 ⎠
n
(b) Stirlings formula gives
⎡ dy ⎤ 1 ⎛ 'y−1 + 'y0 1 ' 3 y−2 + ' 3 y−1 1 '5 y−3 + ' 5 y−2 ⎞
⎢ dx ⎥ = ⎜ − + + " ⎟⎟ (6.9)
⎣ ⎦ x = x0 h ⎜⎝ 2 6 2 30 2 ⎠
SECTION 6.2: Numerical Differentiation 209
and
⎡d2y ⎤ 1 ⎛ 1 1 ⎞
⎢ 2⎥ = 2 ⎜ ' 2 y−1 − ' 4 y−2 + ' 6 y−3 − " ⎟ . (6.10)
⎢⎣ dx ⎥⎦ x = x h ⎝ 12 90 ⎠
0
⎛ 1 1 1 1 1 ⎞
hy0′ = ⎜ ' − ' 2 + ' 3 − ' 4 + ' 5 − ' 6 + " ⎟ y0 (6.11)
⎝ 2 3 4 5 6 ⎠
⎛ 1 1 1 1 1 ⎞
= ⎜ ' + ' 2 − ' 3 + ' 4 − ' 5 + ' 6 − " ⎟ y− 1 (6.12)
⎝ 2 6 12 20 30 ⎠
⎛ 11 5 137 6 7 7 363 8 ⎞
h 2 y0′′ = ⎜ ' 2 − '3 + ' 4 − ' 5 + ' − ' + ' − " ⎟ y0 (6.13)
⎝ 12 6 180 10 560 ⎠
⎛ 1 1 13 6 11 7 29 8 ⎞
= ⎜ ' 2 − ' 4 + '5 − ' + ' − ' + " ⎟ y− 1 (6.14)
⎝ 12 12 180 180 560 ⎠
⎛ 1 1 1 1 1 1 1 ⎞
hyn′ = ⎜ ∇ + ∇ 2 + ∇3 + ∇ 4 + ∇5 + ∇ 6 + ∇ 7 + ∇8 + " ⎟ yn (6.15)
⎝ 2 3 4 5 6 7 8 ⎠
⎛ 1 1 1 1 1 1 1 ⎞
= ⎜ ∇ − ∇ 2 − ∇3 − ∇ 4 − ∇5 − ∇ 6 − ∇ 7 − ∇8 − " ⎟ yn +1
⎝ 2 6 12 20 30 42 56 ⎠
(6.16)
⎛ 11 5 137 7 363 ⎞
h 2 yn′′ = ⎜ ∇ 2 + ∇3 + ∇ 4 + ∇5 + ∇ 6 + ∇7 + ∇8 + " ⎟ yn (6.17)
⎝ 12 6 180 10 560 ⎠
⎛ 1 1 13 6 11 7 29 8 ⎞
= ⎜ ∇ 2 − ∇ 4 − ∇5 − ∇ − ∇ − ∇ − " ⎟ yn +1. (6.18)
⎝ 12 12 180 180 560 ⎠
For more details, the reader is referred to Interpolation and Allied Tables.
The following examples illustrate the use of the formulae stated above.
Example 6.1 From the following table of values of x and y, obtain dy/dx
and d2y/dx2 for x = 1.2:
x y x y
1.0 2.7183 1.8 6.0496
1.2 3.3201 2.0 7.3891
1.4 4.0552 2.2 9.0250
1.6 4.9530
210 CHAPTER 6: Numerical Differentiation and Integration
x y Δ Δ2 Δ3 Δ4 Δ5 Δ6
1.0 2.7183
0.6018
1.2 3.3201 0.1333
0.7351 0.0294
1.4 4.0552 0.1627 0.0067
0.8978 0.0361 0.0013
1.6 4.9530 0.1988 0.0080 0.0001
1.0966 0.0441 0.0014
1.8 6.0496 0.2429 0.0094
1.3395 0.0535
2.0 7.3891 0.2964
1.6359
2.2 9.0250
⎡ dy ⎤ 1 ⎡ 1 1 1 1 ⎤
⎢ dx ⎥ = ⎢0.7351 − 2 (0.1627) + 3 (0.0361) − 4 (0.0080) + 5 (0.0014) ⎥
⎣ ⎦ x =1.2 0.2 ⎣ ⎦
= 3.3205.
⎡ dy ⎤ 1 ⎡ 1 1 1 1 ⎤
⎢ dx ⎥ = ⎢ 0.6018 + (0.1333) − (0.0294) + (0.0067) − (0.0013⎥
⎣ ⎦ x =1.2 0.2 ⎣ 2 6 12 20 ⎦
= 3.3205, as before.
⎡d2y⎤ 1 ⎡ 11 5 ⎤
⎢ 2⎥ = ⎢0.1627 − 0.0361 + 12 (0.0080) − 6 (0.0014) ⎥ = 3.318.
⎣⎢ dx ⎦⎥ x =1.2 0.04 ⎣ ⎦
⎡d2y⎤ 1 ⎡ 1 1 ⎤
⎢ 2⎥ = ⎢0.1333 − 12 (0.0067) + 12 (0.0013) ⎥ = 3.32.
⎣⎢ dx ⎦⎥ x =1.2 0.04 ⎣ ⎦
SECTION 6.2: Numerical Differentiation 211
Example 6.2 Calculate the first and second derivatives of the function
tabulated in the preceding example at the point x = 2.2 and also dy/dx at
x = 2.0.
We use the table of differences of Example 6.1. Here xn = 2.2, yn = 9.0250
and h = 0.2. Hence formula (6.15) gives
⎡ dy ⎤ 1 ⎡ 1 1 1 1 ⎤
⎢ dx ⎥ = ⎢1.6359 + (0.2964) + (0.0535) + (0.0094) + (0.0014) ⎥
⎣ ⎦ x =2.2 0.2 ⎣ 2 3 4 5 ⎦
= 9.0228.
⎡d2y⎤ 1 ⎡ 11 5 ⎤
⎢ 2⎥ = ⎢ 0.2964 + 0.0535 + (0.0094) + (0.0014) ⎥ = 8.992.
⎣⎢ dx ⎦⎥ x =2.2 0.04 ⎣ 12 6 ⎦
To find dy/dx at x = 2.0, we can use either (6.15) or (6.16). Formula (6.15)
gives
⎡ dy ⎤ 1 ⎡ 1 1 1
⎢ dx ⎥ = ⎢1.3395 + 2 (0.2429) + 3 (0.0441) + 4 (0.0080)
⎣ ⎦ x = 2.0 0.2 ⎣
1 1 ⎤
+ (0.0013) + (0.0001) ⎥
5 6 ⎦
= 7.3896.
whereas from formula (6.16), we obtain
⎡ dy ⎤ 1 ⎡ 1 1 1 1 ⎤
⎢ dx ⎥ = ⎢1.6359 − (0.2964) − (0.0535) − (0.0094) − (0.0014) ⎥
⎣ ⎦ x =2.0 0.2 ⎣ 2 6 12 20 ⎦
= 7.3896.
Example 6.3 Find dy/dx and d2y/dx2 at x = 1.6 for the tabulated function of
Example 6.1.
Choosing x0 = 1.6, formula (6.9) gives
= 4.9530.
⎡d2y ⎤ 1
⎢ 2⎥ = 2 ' 2 y−1 + T2 , (6.21)
⎢⎣ dx ⎥⎦ x = x h
0
where
1
T2 = 2
| ' 4 y−2 | . (6.22)
12h
The rounding error, on the other hand, is inversely proportional to h in the
case of first derivatives, inversely proportional to h2 in the case of second
SECTION 6.2: Numerical Differentiation 213
y−2 − 8 y−1 + 8 y1 − y2
= +" (6.23)
12h
has the maximum rounding error
18ε 3ε
= .
12h 2h
Finally, the formula
⎡d2y⎤ Δ 2 y− 1 y − 2 y0 + y1
⎢ 2⎥ = 2
+ " = −1 +" (6.24)
⎣⎢ dx ⎦⎥ x = x h h2
0
has the maximum rounding error 4ε /h 2. It is clear that in the case of higher
derivatives, the rounding error increases rather rapidly.
Example 6.4 Assuming that the function values given in the table of
Example 6.1 are correct to the accuracy given, estimate the errors in the
values of dy/dx and d2y/dx2 at x = 1.6.
Since the values are correct to 4D, it follows that e < 0.00005 = 0.5 ´ 104.
Value of dy/dx at x = 1.6:
1 0.0361 + 0.0441
=
6(0.2) 2
= 0.03342
and
3F
Rounding error = , from (6.23)
2h
3(0.5) 10−4
=
0.4
= 0.00038.
214 CHAPTER 6: Numerical Differentiation and Integration
Hence,
Total error = 0.03342 + 0.00038 = 0.0338.
Using Stirlings formula from Eq. (6.19), with the first differences, we obtain
⎛ dy ⎞ 'y + 'y0 0.8978 + 1.0966 1.9944
⎜ ⎟ = −1 = = = 4.9860.
⎝ dx ⎠ x =1.6 2h 0.4 0.4
The exact value is 4.9530 so that the error in the above solution is (4.9860
4.9530), i.e., 0.0330, which agrees with the total error obtained above.
Value of d2y/dx2 at x = 1.6: Using Eq. (6.24), we obtain
⎡d2 y⎤ ' 2 y−1 0.1988
⎢ 2⎥ = = = 4.9700
⎣⎢ dx ⎦⎥ x =1.6 h2 0.04
so that the error = 4.9700 4.9530 = 0.0170.
Also,
1 1
Truncation error = 2
| ' 4 y− 2 | = × 0.0080 = 0.01667
12h 12 (0.04)
and
4F 4 × 0.5 × 10−4
Rounding error = = = 0.0050.
h2 0.04
Hence
⎡d2y ⎤
Total error in ⎢ 2 ⎥ = 0.0167 + 0.0050 = 0.0217.
⎢⎣ dx ⎥⎦ x =1.6
Example 6.6 From the following data for y(x), find y ¢(1.0).
x –2 –1 2 3
y ( x) –12 –8 3 5
The function from which the above data was calculated is given by
1 3 3 2 241
y=– x − x + x – 3.9. Hence, the exact value of y¢(1) is 3.51667.
15 20 60
To apply the cubic spline formula (5.31), we observe that h1 = 1,
h2 = 3 and h3 = 1.
For i = 1, 2, the recurrence relation gives:
8M1 + 3M2 = 2
and
3M1 + 8M2 = 10,
14 74
since M0 = M3 = 0. We obtain M1 = and M2 = . In 1 £ x £ 2,
we have 55 55
1 © (2 x)3 14 ( x 1)3 ¦ 74 µ ¸
s2 ( x) ª § ¶¹
3 «ª 6 55 6 ¨ 55 · º¹
1© 21 ¸ 1© 9 ¦ 74 µ ¸
ª 8 ¹ (2 x) ª3 § ¶ ¹ ( x 1)
3« 55 º 3« 6 ¨ 55 · º
Differentiating the above and putting x = 1, we obtain
1 © 7 148 461 276 ¸
y b(1) { s2b (1.0)
3 ª« 55 55 55 55 ¹º
3.52727, on simplification.
yi +1 − yi – yi 2 4 yi 1 3 yi
y ′( xi ) = ; y b( xi ) O(h2 )
h 2h
yi 2 yi 1 yi 2 – yi 3 4 yi 2 5 yi 1 2 yi
y bb ( xi ) ; y bb ( xi ) ;
h2 h2
SECTION 6.3: Maximum and Minimum Values of a Tabulated Function 217
Example 6.7 From the following table, find x, correct to two decimal
places, for which y is maximum and find this value of y.
x y
1.2 0.9320
1.3 0.9636
1.4 0.9855
1.5 0.9975
1.6 0.9996
1.2 0.9320
0.0316
1.3 0.9636 –0.0097
0.0219
1.4 0.9855 –0.0099
0.0120
1.5 0.9975 –0.0099
0.0021
1.6 0.9996
Let x0 = 1.2. Then formula (6.25), terminated after second differences, gives
2p −1
0 = 0.0316 +
(−0.0097)
2
from which we obtain p = 3.8. Hence
x = x0 + ph = 1.2 + (3.8) (0.1) = 1.58.
For this value of x, Newtons backward difference formula at xn = 1.6 gives
−0.2 (−0.2 + 1)
y (1.58) = 0.9996 − 0.2(0.0021) + (−0.0099)
2
= 0.9996 − 0.0004 + 0.0008
= 1.0.
h2 h3 (6.34)
= hy0 + y0′ + y0′′ + "
2 6
Similarly,
h h⎛ h2 h3 ⎞
( y0 + y1 ) = ⎜ y0 + y0 + hy0′ + y0′′ + y0′′′+ " ⎟
2 ⎜
2⎝ 2 6 ⎟
⎠
h2 h3
= hy0 + y0′ + y0′′ + " (6.35)
2 4
From Eqs. (6.34) and (6.35), we obtain
x1
h 1
∫ y dx −
2
( y0 + y1 ) = − h3 y0′′ + " ,
12
(6.36)
x0
which is the error in the interval [x0, x1]. Proceeding in a similar manner we
obtain the errors in the remaining subintervals, viz., [x1, x2], [x2, x3],
and
[xn1, xn]. We thus have
SECTION 6.4: Numerical Integration 221
1 3
E=−h ( y0′′ + y1′′+ " + yn′′−1 ), (6.37)
12
where E is the total error. Assuming that y ′′( x ) is the largest value of the
n quantities on the right-hand side of Eq. (6.37), we obtain
1 3 b−a 2
E=− h ny ′′( x ) = − h y ′′( x ) (6.38)
12 12
since nh = b a.
Similarly,
x4
h
∫ y dx =
3
( y2 + 4 y3 + y4 )
x2
#
and finally
xn
h
∫ y dx =
3
( yn −2 + 4 yn −1 + yn ).
xn − 2
Summing up, we obtain
xn
h
∫ y dx =
3
[ y0 + 4( y1 + y3 + y5 + " + yn −1 )
x0
+ 2 ( y2 + y4 + y6 + " + yn −2 ) + yn ], (6.39)
⎡ 3 3 1 ⎤
= 3h ⎢ y0 + ( y1 − y0 ) + ( y2 − 2 y1 + y0 ) + ( y3 − 3 y2 + 3 y1 − y0 ) ⎥
⎣ 2 4 8 ⎦
3h
= ( y0 + 3 y1 + 3 y2 + y3 ).
8
Similarly
x6
3h
∫ y dx =
8
( y3 + 3 y4 + 3 y5 + y6 )
x3
1 ⎛ h2 ⎞ 1 ⎛ h2 ⎞ ⎫⎪
+ ( xi − x) ⎜ yi −1 − M i −1 ⎟ + ( x − xi −1 ) ⎜ yi − M i ⎟ ⎬ dx,
h ⎜ 6 ⎟ h ⎜ 6 ⎟
⎝ ⎠ ⎝ ⎠ ⎭⎪
using Eq. (5.27). On carrying out the integration and simplifying, we obtain
n ⎡h h3 ⎤
I= ∑ ⎢⎢ 2 ( yi −1 + yi ) − 24 (M i −1 + M i ) ⎥⎥, (6.44)
i =1 ⎣ ⎦
where M i , the spline second-derivatives, are calculated from the recurrence
relation
6
M i −1 + 4M i + M i +1 = ( yi −1 − 2 yi + yi +1 ), i = 1, 2, …, n − 1.
h2
The use of the cubic spline method is demonstrated in Example 6.13.
b
I= ∫ y dx
a
and evaluate it by the trapezoidal rule (6.33) with two different subintervals
of widths h1 and h2 to obtain the approximate values I1 and I2, respectively.
Then Eq. (6.38) gives the errors E1 and E2 as
1
E1 = − (b − a )h12 y ′′( x ) (6.45)
12
and
1
E2 = − (b − a ) h22 y ′′( x ). (6.46)
12
Since the term y ′′( x ) in Eq. (6.46) is also the largest value of y ′′( x) , it is
reasonable to assume that the quantities y ′′( x ) and y ′′( x ) are very nearly the
same. We therefore have
E1 h12
=
E2 h22
and hence
E2 h2
= 2 2 2.
E2 − E1 h2 − h1
h22
E2 = ( I 2 − I1 ). (6.47)
h22 − h12
We therefore obtain a new approximation I3 defined by
I1 h22 − I 2 h12
I 3 = I 2 − E2 = , (6.48)
h22 − h12
which, in general, would be closer to the actual valueprovided that the
errors decrease monotonically and are of the same sign.
If we now set
1 1
h2 = h1 = h
2 2
Equation (6.48) can be written in the more convenient form
⎛ 1 ⎞ 1 ⎡ ⎛1 ⎞ ⎤
I ⎜ h, h ⎟ = ⎢ 4 I ⎜ h ⎟ − I ( h ) ⎥ , (6.49)
⎝ 2 ⎠ 3 ⎣ ⎝ 2 ⎠ ⎦
SECTION 6.4: Numerical Integration 225
, (h )
⎛ 1 ⎞
, ⎜ h, h
⎝ 2 ⎟⎠
⎛ 1 1 ⎞
, ⎜ h, h, h ⎟
⎝ 2 4 ⎠
⎛1 ⎞ ⎛ 1 1 1 ⎞
, ⎜ h⎟ , ⎜ h, h, h, h ⎟
⎝2 ⎠ ⎝ 2 4 8 ⎠
⎛1 1 ⎞
, ⎜ h, h ⎟
⎝2 4 ⎠
⎛1 ⎞ ⎛1 1 1 ⎞
, ⎜ h⎟ , ⎜ h, h, h ⎟
⎝4 ⎠ ⎝2 4 8 ⎠
⎛1 1 ⎞
, ⎜ 4 h, 8 h ⎟
⎝ ⎠
⎛1 ⎞
, ⎜ h⎟
⎝8 ⎠
The computations can be stopped when two successive values are sufficiently
close to each other. This method, due to L.F. Richardson, is called the
deferred approach to the limit and the systematic tabulation of this is called
Romberg Integration.
x3
3h 3h3
(b) ∫ y dx =
2
( y1 + y2 ) +
4
y ′′( x ), ( x0 < x < x3 ) (6.53)
x0
x4
4h 14
(c) ∫ y dx =
3
(2 y1 − y2 + 2 y3 ) + h5 y iv ( x ), ( x0 < x < x4 )
45
(6.54)
x0
x5
5h 95 5 iv
(d) ∫ y dx =
24
(11y1 + y2 + y3 + 11y4 ) +
144
h y ( x ), ( x0 < x < x5 )
x0
(6.55)
x6
6h 41 7 vi
(e) ∫ y dx =
20
(11y1 − 14 y2 + 26 y3 − 14 y4 + 11 y5 ) +
140
h y ( x ),
x0
( x0 < x < x6 ). (6.56)
We know that
7.52
Area = ∫ f ( x) dx
7.47
with h = 0.01, the trapezoidal rule given in Eq. (6.32) gives
0.01
Area = [1.93 + 2(1.95 + 1.98 + 2.01 + 2.03) + 2.06] = 0.0996.
2
Estimate the volume of the solid formed, giving the answer to three decimal
places.
If V is the volume of the solid formed, then we know that
1
V =Q ∫ y 2 dx
0
Hence we need the values of y2 and these are tabulated below, correct to
four decimal places
x y2
0.00 1.0000
0.25 0.9793
0.50 0.9195
0.75 0.8261
1.00 0.7081
With h = 0.25, Simpsons rule gives
Q (0.25)
V= [1.0000 + 4(0.9793 + 0.8261) + 2(0.9195) + 0.7081]
3
= 2.8192.
228 CHAPTER 6: Numerical Differentiation and Integration
x y
0.0 1.0000
0.5 0.6667
1.0 0.5000
1
I = [1.0 + 2(0.8000 + 0.6667 + 0.5714) + 0.5] = 0.6970.
8
1
I= [1.0 + 4(0.8000 + 0.5714) + 2(0.6667) + 0.5] = 0.6932.
12
SECTION 6.4: Numerical Integration 229
1
I [1.0 2(0.8889 0.8000 0.7273 0.6667)
16
0.6154 0.5714 0.5333) 0.5]
0.6941.
(b) Simpsons rule gives
1
I [1.0 4(0.8889 0.7273 0.6154 0.5333)
24
2(0.8000 0.6667 0.5714) 0.5]
0.6932.
Hence the value of I may be taken to be equal to 0.693, correct to three decimal
places. The exact value of I is loge2, which is equal to 0.693147
. This
example demonstrates that, in general, Simpsons rule yields more accurate
results than the trapezoidal rule.
Example 6.11 Use Rombergs method to compute
1
1
I= ∫ 1 + x dx,
0
correct to three decimal places.
We take h = 0.5, 0.25 and 0.125 successively and use the results obtained in
the previous example. We therefore have
⎛1 ⎞ ⎛1 ⎞
I (h) = 0.7084, I ⎜ h ⎟ = 0.6970, and I ⎜ h ⎟ = 0.6941
⎝2 ⎠ ⎝4 ⎠
Hence, using Eq. (6.49), we obtain
⎛ 1 ⎞ 1
I ⎜ h, h ⎟ = 0.6970 + (0.6970 − 0.7084) = 0.6932.
⎝ 2 ⎠ 3
230 CHAPTER 6: Numerical Differentiation and Integration
⎛1 1 ⎞ 1
I ⎜ h, h ⎟ = 0.6941 + (0.6941 − 0.6970) = 0.6931
⎝2 4 ⎠ 3
Finally,
⎛ 1 1 ⎞ 1
I ⎜ h, h, h ⎟ = 0.6931 + (0.6931 − 0.6932) = 0.6931.
⎝ 2 4 ⎠ 3
The table of values is, therefore,
0.7084
0.6932
0.6970 0.6931
0.6931
0.6941
x y
0 0
0.5 1.0
1.0 0.0
2
a−1 + a1 = h.
and 3 (iv)
Solving (ii), (iii) and (iv) for a1, a0 and a1, we obtain
2 4h
a−1 = = a1 and a0 = .
3 3
232 CHAPTER 6: Numerical Differentiation and Integration
En− 1 1 1
= ( E n − 1) − ( E n − 1) + B1hD ( E n − 1) + B3 h3 D3 ( E n − 1) + " (6.58)
E − 1 hD 2
Operating this identity on y0 , we obtain
En −1 1 1
y0 = ( E n − 1) y0 − ( E n − 1) y0 + B1hD( E n − 1) y0 + "
E −1 hD 2
1 1
= ( yn − y0 ) − ( yn − y0 ) + B1h( yn′ − y0′ ) + B3h3 ( yn′′′− y0′′′ )
hD 2
+ B5 h5 ( yn v − y0 v ) + " (6.59)
It can be easily shown that the left-hand side denotes the sum
y0 + y1 + y2 + L + yn1, whereas the term
1
( yn − y0 )
hD
on the right side can be written as
xn
1
h ∫ y dx
x0
since 1/D can be interpreted as an integration operator.
SECTION 6.5: EulerMaclaurin Formula 233
h4 h6 (6.60)
( ynbbb y0bbb) ( ynv y0v ) "
720 30,240
which is called the EulerMaclaurins formula for integration. The first
expression on the right-hand side of Eq. (6.60) denotes the approximate
value of the integral obtained by using trapezoidal rule and the other expressions
represent the successive corrections to this value. It should be noted that this
formula may also be used to find the sum of a series of the form y0 + y1
+ y2 + L + yn. The use of this formula is illustrated by the following
examples.
Example 6.15 Evaluate
Q /2
I= ∫ sin x dx
0
using the EulerMaclaurins formula.
In this case, formula (6.60) simplifies to
Q /2
h h 2 h4 h6
∫ sin x dx =
2
( y0 + 2 y1 + 2 y2 + " + 2 yn −1 + yn ) + + +
12 720 30, 240
+ " (i)
0
Q Q2 Q4
= + + , approximately
4 192 1,84,320
= 0.837330.
On the other hand with h = p/8, we obtain
Q /2
Q
± sin x dx 16 [(0 2(0.382683) .707117 0.923879 1.000000)]
0
0.987119 0.012851 0.000033
1.000003.
234 CHAPTER 6: Numerical Differentiation and Integration
h5
+ ( y nv − y 0v ) − " (i)
30, 240
Here y (x) = x2, y¢(x) = 2x and h = 1.
Hence Eq. (i) gives
n
1 1
∫x
2
Sum = dx + (n 2 + 1) + (2n − 2)
2 12
1
1 1 1
= (n3 − 1) + (n 2 + 1) + (n − 1)
3 2 6
1
= (2n3 + 3n 2 + n)
6
n(n + 1)(2n + 1)
= .
6
b 5
h© ¦ a bµ ¸ h
I ± y ( x) dx { y ( a ) 4 y § ¶ y (b) yiv (Y1 ), a Y1 b
3 ª« ¨ 2 · ¹
º 90
a
(b a)h4 iv (6.62)
I (a, b) y (Y1 ),
180
where
h© ¦ a bµ ¸
I ( a, b) ª y a
4 y §¨ ¶ y (b) ¹ .
·
(6.63)
3« 2 º
b
h© ¦ 3a b µ ¦ a bµ ¦ a 3b µ ¸
I ± y ( x) dx 6 ª y (a) 4 y §¨ 4 ·
¶ 2y §
¨ 2 ·
¶ 4y §
¨ 4 ·
¶ y (b) ¹
a « º
h 4 (b a) iv
y (Y2 )
180 t 16
h© ¦ 3a b µ ¦ a bµ ¸
ª y (a ) 4 y § ¶ y§ ¶
6« ¨ 4 · ¨ 2 · ¹º
h © ¦ a bµ ¦ a 3b µ ¸ (b a) h4 iv
y§ ¶ 4y§ ¶ y (b) ¹ y (Y2 )
6 «ª ¨ 2 · ¨ 4 · º 180 t 16
¦ a bµ ¦ab µ (b a )h4 iv
I § a, ¶ I§ , b¶ y (Y2 ), (6.64)
¨ 2 · ¨ 2 · 180 t 16
where
¦ a bµ h © ¦ 3a b µ ¦ a bµ ¸
I § a, ¶ ª y (a) 4 y § ¶ y§
¨ 2 · 6« ¨ 4 · ¨ 2 ¶· ¹º (6.65a)
and
¦ a b µ h © ¦ a bµ ¦ a 3b µ ¸
I§ , b¶ ª y § 4y§ y(b)¹ .
¨ 2 · 6 « ¨ 2 ¶· ¨ 4 ¶· º
(6.65b)
Assuming
y iv (ξ1 ) = y iv (ξ 2 )
236 CHAPTER 6: Numerical Differentiation and Integration
1 ⎛ a+b⎞ ⎛a+b ⎞
I ( a, b) − I ⎜ a, ⎟−I⎜ ,b ⎟ < ε (6.68)
15 ⎝ 2 ⎠ ⎝ 2 ⎠
for some e > 0 in the interval [a, b], then Eq. (6.67) means that
b
⎛ a+b⎞ ⎛a+b ⎞
∫ y ( x) dx − I ⎜ a,
⎝
⎟−I⎜
2 ⎠ ⎝ 2
,b⎟ < ε
⎠
(6.69)
a
and that
b
⎛ a+b⎞ ⎛a+b ⎞
∫ y ( x) dx ≈ I ⎜ a,
⎝
⎟+I⎜
2 ⎠ ⎝ 2
, b ⎟.
⎠
(6.70)
a
Example 6.17 Test the error estimate given by Eq. (6.67) in the evaluation
of the integral
Q /2
I= ∫ cos x dx.
0
SECTION 6.6: Numerical Integration with Different Step Sizes 237
Example 6.18 Test the error estimate given in Eq. (6.67) in the evaluation
of the integral
Q /2
I= ∫ (8 + 4sin x) dx.
0
Exact value = 4(p + 1)
Now,
⎛ Q⎞ Q ⎡ ⎛ 4 ⎞ ⎤ Q ⎛ 16 ⎞
I ⎜ 0, ⎟ = ⎢8 + 4 ⎜ 8 + ⎟ + 12 ⎥ = ⎜ 52 + ⎟,
⎝ 2 ⎠ 12 ⎣ ⎝ 2⎠ ⎦ 12 ⎝ 2⎠
⎛ Q⎞ Q ⎡ ⎛ Q⎞ 4 ⎤ Q ⎛ Q 4 ⎞
I ⎜ 0, ⎟ = ⎢8 + 4 ⎜ 8 + 4 sin ⎟ + 8 + ⎥ = ⎜ 48 + 16sin + ⎟,
⎝ 4 ⎠ 24 ⎣ ⎝ 8⎠ 2 ⎦ 24 ⎝ 8 2⎠
⎛Q Q ⎞ Q ⎡ 4 ⎛ 3Q ⎞ ⎤
I⎜ , ⎟= ⎢8+ + 4 ⎜ 8 + 4 sin ⎟ + 12 ⎥
⎝ 4 2 ⎠ 24 ⎣ 2 ⎝ 8 ⎠ ⎦
Q ⎡ 4 3Q ⎤
= 52 + + 16sin ⎥
24 ⎢⎣ 2 8 ⎦
238 CHAPTER 6: Numerical Differentiation and Integration
Therefore,
⎛ Q⎞ ⎛Q Q ⎞ Q ⎡ 8 Q 3Q ⎤
I ⎜ 0, ⎟ + I ⎜ , ⎟ = ⎢100 + + 16 sin + 16sin ⎥
⎝ 4⎠ ⎝ 4 2 ⎠ 24 ⎣ 2 8 8 ⎦
Hence
1 ⎡ ⎛ Q⎞ ⎛ Q⎞ ⎛ Q Q ⎞⎤
⎢ I ⎜ 0, ⎟ − I ⎜ 0, ⎟ − I ⎜ , ⎟ ⎥
15 ⎣ ⎝ 2 ⎠ ⎝ 4⎠ ⎝ 4 2 ⎠⎦
1 Q ⎡ 32 8 Q 3Q ⎤
= ⎢104 + − 100 − − 16 sin − 16sin
15 24 ⎣ 2 2 8 8 ⎥⎦
Q ⎡ 24 Q 3Q ⎤
= 4+ − 16 sin − 16sin
360 ⎢⎣ 2 8 8 ⎥⎦
= 0.00057 .
Q /2
⎛ Q⎞ ⎛Q Q ⎞
Actual Error = ∫ (8 + 4 sin x) dx − I ⎜ 0, ⎟ − I ⎜ , ⎟
⎝ 4⎠ ⎝4 2⎠
0
Q ⎛ 8 Q 3Q ⎞
= 4(Q + 1) − ⎜100 + + 16 sin − 16 sin ⎟
24 ⎝ 2 8 8 ⎠
= 16.56637 − 16.56691
= 0.00054.
± ¥W F (u )
1 n
F ( u)du W1 F ( u1 ) W2 F (u2 ) " Wn F ( un ) i i (6.72)
1 i 1
In Eq. (6.72), there are altogether 2n arbitrary parameters and therefore the
weights and abscissae can be determined such that the formula is exact when F(u)
is a polynomial of degree not exceeding (2n 1). Hence, we start with
F (u ) = c0 + c1u + c2 u 2 + c3u 3 + " + c2 n −1u 2 n −1. (6.73)
We then obtain from Eq. (6.72)
1 1
2 2
= 2c0 + c2 + c4 + " (6.74)
3 5
Substituting these values on the right-hand side of Eq. (6.72), we obtain
1
± F (u ) du c0 (W1 W2 " Wn )
1
c1 (W1u1 W2u2 W3u3 " Wn un )
c2n 1 (W1u12n 1 W2u 22n 1 W3u 23n 1 " Wnu 2nn 1 ). (6.75)
Now, Eqs. (6.74) and (6.75) are identical for all values of ci and hence
comparing the coefficients of ci, we obtain the 2n equations
W1 W2 W3 " Wn 2
»
¯
W1u1 W2u2 W3u3 " Wnun 0 ¯
¯¯
(6.76)
W1u1 W2u 2 W3u 3 " Wnu n 2/3 ¼
2 2 2 2
¯
# ¯
2 n 1 2 n 1 2n 1 2 n 1 ¯
W1u1 W2u 2 W3u 3 " Wnu n 0 ¯½
in 2n unknowns Wi and ui (i = 1, 2,
, n).
240 CHAPTER 6: Numerical Differentiation and Integration
Since this formula is exact when F(u) is a polynomial of degree not exceeding
3, we put successively F(u) = 1, u, u2 and u3. Then Eq. (6.77) gives the four
equations:
W1 + W2 = 2 ⎫
⎪
W1u1 + W2 u2 = 0 ⎪
⎪
⎬ (6.78)
W1u 12 + W2 u 22 = 2/3 ⎪
⎪
W1u 13 + W2u 23 = 0. ⎪
⎭
The solution of these equations is
1
W1 = W2 = 1, u2 = −u1 = . (6.79)
3
This method, when applied to the general system given in Eq. (6.76) above,
will be extremely complicated and difficult, and an alternate method must
be chosen to solve the nonlinear system (6.76).
It can be shown that the ui are the zeros of the (n + 1)th Legendre
polynomial Pn+1(u) which can be generated using the recurrence relation
(n + 1) Pn +1 (u ) = (2n + 1)uPn (u ) − nPn −1 (u ), (6.80)
where P0(u) = 1 and P1(u) = u. The first-five Legendre polynomials are
given by
P0 (u ) = 1 ⎫
⎪
P1 (u ) = u ⎪
⎪
⎪ (6.81)
P2 (u ) = (1/2) (3u 2 − 1) ⎬
⎪
P3 (u ) = (1/2) (5u 3 − 3u ) ⎪
⎪
P4 (u ) = (1/8) (35u 4 − 30u 2 + 3). ⎪⎭
It can also be shown that the corresponding weights Wi are given by
1 n u −uj
Wi = ∫ j =∏ u −uj
0, j ≠ i i
du, (6.82)
−1
n ± ui Wi
In the general case, the limits of the integral in Eq. (6.71) have to be
changed to those in Eq. (6.72) by means of the transformation
1 1
x= u (b − a ) + (a + b). (6.83)
2 2
The use of Table 6.1 is illustrated by the following example:
1
Example 6.19 Find I = ∫ 0 x dx, by Gauss formula.
The first step is to change the limits by Eq. (6.83). So, we get
1
x= (u + 1)
2
This gives
1 n
1 1
I=
4 ∫ (u + 1) du = ∑
4 i =1
Wi F (ui ),
−1
where F(ui) = ui + 1.
For simplicity, we take n = 4 and using the abscissae and weights
corresponding to n = 4 in Table 6.1, we obtain
1
I≈ [( −0.86114 + 1) (0.34785) + (−0.33998 + 1) (0.65214)
4
+ (0.33998 + 1) (0.65214) + (0.86114 + 1) (0.34785)]
= 0.49999…,
where the abscissae and weights have been rounded to five decimal places.
*
See, for example, Sastry [1973; 1976].
**
See, Noble [1964], p. 241.
244 CHAPTER 6: Numerical Differentiation and Integration
h
I [1 2(e h cos X h e2h cos 2X h e 3h cos 3X h ")]
2
∞
h
=
2
+h ∑ e− nh cos X nh
n =1
∞
e − nh Re (eiX nh )
h
=
2
+h ∑
n =1
e
¥
© ¸
e( iX 1) nh ¹
1
hª Re
ª2 n 1 ¹
« º
SECTION 6.10: Numerical Double Integration 245
©1 ¬ ( 1 iX )h » ¸
¯ e ¯
hª Re ¹
( 1 iX ) h ¼
ª« 2 ¯1 e
® ¯¹
½ º
⎡1 iX h
⎪⎧ e ⎪⎫⎤
= h ⎢ + Re ⎨ h iX h ⎬
⎥
⎢⎣ 2 ⎪⎩ e − e ⎪⎭⎥⎦
h e2h − 1
= ⋅ , on simplification (6.92)
2 1 + e 2h − 2eh cos X h
The right side of Eq. (6.92) can be further simplified by using hyperbolic
functions.
With h = 0.1 and w = 1, formula (6.92) gives
∞
∫
I = e− x cos x dx
0
0.1 e0.2 − 1 © 1 1 ¸
= ⋅ ª 0.1, X 3¹
2 1 + e0.2 − 2e0.1 cos (0.1) «1 X2 10 º
0.1 0.221402758
= ⋅
2 2.221402758 − 2.199299334
= 0.500833622,
so that the absolute error in the above result is 0.000833622. Table 6.2 gives
the values of the integral given in Eq. (6.91) for different values of w and
h = 0.1. For comparison, exact values of the integral are also tabulated.
y j +1 xi +1
I= ∫ ∫ f ( x, y ) dx dy, (6.93)
yj xi
where
xi+1 = xi + h and yj+1 = yj + k.
By the repeated application of trapezoidal rule to Eq. (6.93), we get
y j +1
h
I=
2 ∫ [ f ( xi , y ) + f ( xi +1 , y )] dy
yj
hk
= [ f ( xi , y j ) + f ( xi +1 , y j ) + f ( xi , y j +1 ) + f ( xi +1 , y j +1 )]
4
hk
= [ fi, j + fi +1, j + fi, j +1 + fi +1, j +1 ], (6.94)
4
y j +1
h
I=
3 ∫ [ f ( xi −1 , y ) + 4 f ( xi , y ) + f ( xi +1 , y )] dy
y j −1
hk
= [ f ( xi −1 , y j −1 ) + 4 f ( xi −1 , y j ) + f ( xi −1 , y j +1 )
9
+ 4{ f ( xi , y j −1 ) + 4 f ( xi , y j ) + f ( xi , y j +1 )}
+ f ( xi +1 , y j −1 ) + 4 f ( xi +1 , y j ) + f ( xi +1 , y j +1 )]
hk
= [ fi −1, j −1 + fi −1, j +1 + fi +1, j −1 + fi +1, j +1
9
+ 4( fi −1, j + fi , j −1 + fi , j +1 + fi +1, j ) + 16 fi , j ]. (6.96)
using the trapezoidal and Simpsons rules. With h = k = 0.5, we have the
following table of values of ex + y.
x
y 0 0.5 1.0
0 1 1.6487 2.7183
0.5 1.6487 2.7183 4.4817
1.0 2.7183 4.4817 7.3891
0.25
I= [1.0 + 4 (1.6487) + 6 (2.7183) + 4(4.4817) + 7.3891]
4
12.3050
=
4
= 3.0762.
Using Simpsons rule given in Eq. (6.96) repeatedly, we obtain
0.25
I [1.0 2.7183 7.3891 2.7183
9
4 (1.6487 4.4817 4.4817 1.6487) 16 (2.7183)]
26.59042
9
2.9545.
The exact value of the double integral is 2.9525 and therefore it can
be verified that the result given by Simpsons rule is about sixty times more
accurate than that given by the trapezoidal rule.
EXERCISES
d
6.1 Find J0(x) at x = 0.1 from the following table:
dx
(0, 1.0), (0.1, 0.9975), (0.2, 0.9900), (0.3, 0.9776), (0.4, 0.9604).
6.2 The following table gives angular displacements q (in radians) at different
times t (seconds):
(0, 0.052), (0.02, 0.105), (0.04, 0.168), (0.06, 0.242), (0.08, 0.327),
(0.10, 0.408), (0.12, 0.489).
Calculate the angular velocity at t = 0.06.
248 CHAPTER 6: Numerical Differentiation and Integration
dy
6.3 From the following values of x and y, find
at x = 0.6.
dx
(0.4, 1.5836), (0.5, 1.7974), (0.6, 2.0442), (0.7, 2.3275),
(0.8, 2.6511).
6.4 The distances (x cm) traversed by a particle at different times
(t seconds) are given below.
x 0 1 2 3 4 5 6
y 6.9897 7.4036 7.7815 8.1291 8.4510 8.7506 9.0309
6.6 A rod is rotating in a plane about one of its ends. The angle q (in radians)
at different times t (seconds) are given below.
t 0 0.2 0.4 0.6 0.8 1.0
R 0.0 0.15 0.50 1.15 2.0 3.20
Find its angular velocity and angular acceleration when t = 0.6 seconds.
6.7 Tabulate the function y = f (x) = x3 10x + 6 at x0 = 0.5, x1 = 1.00
and x2 = 2.0. Compute its first and second derivatives at x = 1.00 using
Lagranges interpolation formula. Compare your results with true values.
dy
6.8 Given the following values of x and y, find at x = 2:
dx
(0, 2), (2, 2), (3, 1).
6.9 A cubic function y = f (x) satisfies the following data:
x 0 1 3 4
f ( x) 1 4 40 85
Determine f (x) and hence find f ¢(2) and f ¢¢(2).
6.10 The function y = 3xex is tabulated below.
(3, 0.4481), (4, 0.2198), (5, 0.1011).
Find y¢(x) at x = 3, 4 and 5 and compare your results with the exact
values.
EXERCISES 249
dy
6.11 From the following values of x and y, find at x = 2 using the cubic
dx
spline method.
(2, 11), (3, 49), (4, 123)
dy
6.12 From the following values of x and y, determine the value of at
dx
each of the points by fitting a natural cubic spline through them.
(1, 3), (2, 11), (4, 69), (5, 131).
6.13 Given the values of x and y:
(1.2, 0.9320), (1.3, 0.9636), (1.4, 0.9855), (1.5, 0.9975), (1.6, 0.9996),
find x, correct to two decimal places, for which y is maximum and find
this value of y.
6.14 If y = A + Bx + Cx2 and y0, y1, y2 are the values of y corresponding
to x = 0, h and 2h, respectively, prove that
2h
h
± y dx 3 ( y0 4 y1 y2 ) .
0
6.15 Evaluate
Q 2
x
(a) ∫ x sin x dx and (b) ∫ 5 + 2 x dx
0 −2
using the trapezoidal rule with five ordinates.
6.16 State the trapezoidal rule for finding an approximate area under a given
curve. A curve is given by the points (x, y) given below.
(0, 23), (0.5, 19), (1.0, 14), (1.5, 11), (2.0, 12.5), (2.5, 16),
(3.0, 19), (3.5, 20), (4.0, 20).
Estimate the area bounded by the curve, the x-axis and the extreme
ordinates.
6.17 Write an algorithm to evaluate the integral
xn
I= ∫ y dx
x0
by the trapezoidal rule with step size h. Given the values of x and y(x);
(0, 0.399), (0.5, 0.352), (1.0, 0.242) (1.5, 0.129), (2.0, 0.054)
find an approximate value of
2
∫ y( x) dx.
0
250 CHAPTER 6: Numerical Differentiation and Integration
∫
I = x 2 log x dx.
3
x2 n
1
6.21 Write an algorithm to evaluate ± y dx using Simpsons -rule when
3
x0
3
6.25 Derive Simpsons -ru le,
8
x3
3
± y dx 8 h ( y0 3 y1 3 y2 y3 )
x0
∫ y dx,
1.0
as accurately as possible.
6.28 Evaluate
2
dx
∫ 3
x + x +1
0
1
by Simpsons -rule with h = 0.25.
3
252 CHAPTER 6: Numerical Differentiation and Integration
6.33 Let
2
∫x
2
f ( x) dx = k0 f (0) + k1 f (1) + k2 f (2).
0
If f (x) is approximated by a quadratic through the points x = 0, 1, and
2, then find the values of k0, k1 and k2.
6.34 Using the trapezoidal rule, show that
e
x cos X x dx { h sinh h
±e 2 cosh h cos X h
(Einarsson)
0
∞
h sinh h
∫e
−x
cos X x dx ≈ (c1 cosh h + c2 cos X h),
cosh 2h − cos 2X h
0
where
⎡1 + cos 2 X h sin 2X h ⎤
c1 = 2 ⎢ − ⎥
⎢⎣ X h X 3h3 ⎥⎦
2 2
EXERCISES 253
© sin h X cos X h ¸
and c2 4ª ¹
« X3 3
h X 2 h2 º
use this formula to show that
e
x cos x dx 0.500001391
±e
0
6.36 If
Q /4
∫ cos
2
I= x dx,
0
compute
⎛ Q⎞ ⎛ Q⎞ ⎛Q Q ⎞
I ⎜ 0, ⎟ , I ⎜ 0, ⎟ and I ⎜ , ⎟
⎝ 4⎠ ⎝ 8⎠ ⎝8 4⎠
6.37 Verify the error estimate given in Eq. (6.67) for Problem 6.36.
6.38 Test the error estimate given in Eq. (6.67) in the evaluation of the
integral
Q /2
I= ∫ cos x dx
0
6.39 Use the trapezoidal rule to evaluate the double integral
2 4
± ± ( x xy y ) dx dy.
2 2
–2 0
1
6.40 Use Simpsons -rule to evaluate the double integral in Problem 6.39
3
and compare the results with the exact value.
Answers to Exercises
6.1 0.0505
6.2 3.975
6.3 2.6444
6.4 0.55
6.5 (a) 0.3931 (b) 0.3341 (c) 0.2706 (d) 0.0256.
2
6.6 3.73 rad/s; 4.48 rad/s
6.7 5.5; 5.0.
6.8 0
254 CHAPTER 6: Numerical Differentiation and Integration
6.9 17; 6
6.10 (a) 0.2831 (b) 0.1735 (c) 0.0639.
6.11 29
6.12 s1(x) = 2(x 1)3 + 3(2 x) + 9(x 1), 1 £ x £ 2.
6.13 1.0
6.15 (a) p, (b) 1.0794
6.16 66.5
6.17 0.475
6.18 (a) 1.1000, (b) 1.0987
6.19 1.1873
6.20 177.4816
6.21 0.2947
6.22 0.7855
6.23 IT = 0.9871, Is = 1.0002
6.24 1.570858
6.25 0.69319; 0.69317
6.27 0.9513
6.28 0.815
6.29 4.21667
6.31 1.5
6.32 0.693122
2 8 6
6.33 k0 = – , k1 = , k2 = .
15 5 5
6.36 0.269583
6.37 See Example 6.16.
6.38 Error = 0.00014
6.39 112
6.40 106.6667
Chapter
7.1 INTRODUCTION
Most problems arising from engineering and applied sciences require the
solution of systems of linear algebraic equations and computation of eigenvalues
and eigenvectors of a matrix. We assume that the readers are familiar with
the theory of determinants and elements of matrix algebra since these provide
a convenient way to represent linear algebraic equations. For example, the
system of equations.
a11x1 + a12x2 + a13x3 = b1
a21x1 + a22x2 + a23x3 = b2
a31x1 + a32x2 + a33x3 = b3
may be represented as the matrix equation, where
AX = b
255
256 CHAPTER 7: Numerical Linear Algebra
⎡1 2 3⎤
A = ⎢⎢0 1 2 ⎥⎥
⎢⎣0 0 1 ⎥⎦
Let
⎡1 −2 1⎤
A −1
= ⎢⎢0 1 –2 ⎥⎥
⎢⎣0 0 1⎥⎦
Since the inverse of a triangular matrix is easily computed, it follows that
the inverse of a nonsingular matrix A can be easily obtained if A is expressed
as a product of two triangular matrices.
In particular, if A = LU, where L and U are lower and upper triangular
matrices, then it follows that
A1 = (LU)1 (7.1)
1 1
= U L
The next section will be devoted to the LU decomposition of a nonsingular
square matrix and this will be used in the solution of a system of linear
algebraic equations.
Let
be a nonsingular square matrix. Then A can be factorized into the form LU,
where
258 CHAPTER 7: Numerical Linear Algebra
⎡2 3 1⎤
A = ⎢⎢1 2 3 ⎥⎥
⎢⎣ 3 1 2 ⎥⎦
into the LU form.
Let
©1 0 0¸ ©2 3 1¸
ª ¹ ª
1 1 5 ¹¹
Lª 1 0¹ and U ª0
ª2 ¹ ª 2 2¹
ª3 ¹ ª0 0 18¹º
ª –7 1¹ «
«ª 2 ¹
º
The distance between a vector and the null vector is a measure of the size
or length of the vector. This is called a norm of the vector. The norm of the
vector x, written as || x ||, is a real number which satisfies the following
conditions or axioms:
260 CHAPTER 7: Numerical Linear Algebra
¥ |x |
m
|| x || 1 | x1 | | x2 | " | xn | i (7.9)
i 1
1/2
¥ |x |
© n ¸
2 2 2 2¹
|| x || 2 | x1 | | x2 | " | xn | ª i || x ||e (7.10)
ª i 1 ¹
« º
|| x || e max | xi | . (7.11)
i
The norm || < ||2 is called the Euclidean norm since it is just the formula for
distance in the three-dimensional Euclidean space. The norm || < || ∞ is called
the maximum norm or the uniform norm.
It is easy to show that the three norms || x ||1 , || x ||2 and || x || e satisfy the
conditions (7.5) to (7.7), given above. Conditions (7.5) and (7.6) are trivially
satisfied. Only condition (7.7), the triangle inequality, needs to be shown to
be true. For the norm || x ||1 we observe that
¥ |x y |
n
|| x y || i i
i 1
c ¥ (| x | | y |)
n
i i
i 1
¥ ¥|y |
n n
| xi | i
i 1 i 1
c max (| xi | | yi |)
i
|| x || e || y || e . (7.13)
The proof for the Euclidean norm is left as an exercise to the reader.
To define matrix norms, we consider two matrices A and B for which
the operations A + B and AB are defined. Then,
| A + B| ≤ | A | + | B | (7.14)
| AB | ≤ | A | | B | (7.15)
|B A | = | B | | A | (B a scalar). (7.16)
From Eq. (7.15) it follows that
| A p | ≤ | A | p, (7.17)
where p is a natural number. In the above equations, | A | denotes the matrix
A with absolute values of the elements.
By the norm of a matrix A = | aij |, we mean a nonnegative number, denoted
by || A ||, which satisfies the following conditions
|| B A || | B | || A || (B a scalar) (7.19)
|| A B || c || A || || B || (7.20)
|| AB || c || A || || B || . (7.21)
|| A ||1 = max
j
∑ | aij | (the column norm) (7.23)
i
1/2
⎡ ⎤
|| A || e = ⎢ ∑ | aij |
⎢⎣ i,
2⎥
⎥⎦
(the Euclidean norm) (7.24)
j
262 CHAPTER 7: Numerical Linear Algebra
|| A || ∞ = max
i
∑ | aij | (the row norm). (7.25)
j
In addition to the above, we have || A ||2 defined by
= (1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81)1/2
= (285)1/2
= 16.88.
|| A || ∞ = max [1 + 2 + 3, 4 + 5 + 6, 7 + 8 + 9]
= 24.
The concept of the norm of a matrix will be useful in the study of the
convergence of iterative methods of solving linear systems. It is also used
in defining the stability of a system of equations.
′ = a22 − a12 (a21/a11 ), etc. Thus the primes indicate that the original
where a22
element has changed its value. Similarly, we can multiply the first equation
by a31/a11 and add it to the third equation of the system (7.27). This
eliminates the unknown x1 from the third equation of Eq. (7.27) and we
obtain
′ x2 + a33
a32 ′ x3 + " + a3′ n xn = b3′ . (7.29)
In a similar fashion, we can eliminate x1 from the remaining equations and
after eliminating x1 from the last equation of Eq. (7.27), we obtain the
system
264 CHAPTER 7: Numerical Linear Algebra
In Eq. (7.31), the double primes indicate that the elements have changed
twice. It is easily seen that this procedure can be continued to eliminate x3
from the fourth equation onwards, x4 from the fifth equation onwards, etc.,
till we finally obtain the upper-triangular form:
Step 2: We now have to obtain the required solution from the system
(7.32). From the last equation of this system, we obtain
b n( n 1)
xn ( n 1)
. (7.33)
a nn
This is then substituted in the (n − 1) th equation to obtain xn −1 and the process
is repeated to compute the other unknowns. We have therefore first computed
xn, then xn −1 , xn − 2 , …, x2 , x1 , in that order. Due to this reason, the process is
called back substitution.
The inverse can now be obtained easily, since the back-substitution process
with each column of the matrix I will yield the corresponding column of A1,
where I is given by
© 1 0 0 ¸
ª ¹
I B
ª 21 1 0 ¹.
ª ¹
B
« 31 B 32 1 º
Example 7.7 We shall consider again the system given in Example 7.6.
We have here
⎡2 1 1 ⎤
⎢ ⎥
A = ⎢3 2 3 ⎥ .
⎢ ⎥
⎣⎢1 4 9 ⎦⎥
The augmented system is
⎡2 1 1 # 1 0 0 ⎤
⎢ ⎥
⎢3 2 3 # 0 1 0 ⎥.
⎢ ⎥
⎣⎢1 4 9 # 0 0 1 ⎦⎥
SECTION 7.5: Solution of Linear SystemsDirect Methods 269
⎡2 1 1 # 1 0 0 ⎤
⎢ ⎥
⎢0 1/2 3/2 # −3/2 1 0 ⎥.
⎢ ⎥
⎢⎣0 7/2 17/ 2 # −1/2 0 1 ⎥⎦
⎡2 1 1 # 1 0 0⎤
⎢0 1/2 3/2 # −3/2 1 0 ⎥⎥ .
⎢
⎢⎣ 0 0 −2 # 10 −7 1⎥⎦
⎡2 1 1 # 1⎤
⎢0 1/ 2 3/2 # −3/ 2 ⎥⎥ ,
⎢
⎢⎣0 0 −2 # 10 ⎥⎦
⎡2 1 1 # 0⎤
⎢0 1/ 2 3/2 # 1 ⎥⎥
⎢
⎢⎣0 0 −2 # −7 ⎥⎦
and
⎡2 1 1 # 0⎤
⎢0 1/2 3/2 # 0 ⎥⎥ ,
⎢
⎢⎣ 0 0 −2 # 1⎥⎦
whose solution by back substitution yields the three columns of the matrix:
⎡ −3 5/ 2 −1/ 2⎤
⎢ 12 −17/ 2 3/2⎥⎥ ,
⎢
⎢⎣ −5 7/ 2 −1/2⎥⎦
⎛1⎞
| A | = 2 ⎜ ⎟ (−2) = −2
⎝2⎠
by looking at the triangulated coefficient matrix. If this value is zero, then we
cannot back substitute and the matrix has no inverse.
270 CHAPTER 7: Numerical Linear Algebra
If the right-hand side vector is B = (b1, b2, b3), then the forward substitution
can be accomplished by the statements:
Do j = 1(1)N 1
Do i = j + 1(1) N
b(i) = b(i) l(i, j) * b( j)
Next i
Next j
End.
Similarly, the backsubstitution can be effected by the steps:
Do j = N(1)1
b( j) = b( j)/u( j, j)
Do i = 1(1) j 1
b(i) = b(i) u(i, j) * b( j)
Next i
Next j
End
SECTION 7.5: Solution of Linear SystemsDirect Methods 273
©2 3 1¸ ©9 ¸
A ªª 1 2 3¹ and B ªª6 ¹¹
¹
ª« 3 1 2¹º ª«8 ¹º
© 1 0 0¸ ©2 3 1 ¸
L ªª 0.5 1 0¹¹ and U
ª
ª
0 0.5 2.5¹¹
ª«1.5 –7 1¹º ª
«0 0 18 ¹º
In the final step, we have to eliminate x2 from the third equation. For this
we multiply the second equation by a32 ′ /a22
′ and subtract it from the third
equation. We then obtain
′′ x3 = b3′′,
a33 (7.46)
where the double primes indicate that the concerned elements have changed
′ /a22
their values twice. In this step, the multiplier is given by l32 = a32 ′ . The
final form of the matrix of coefficients is the upper-triangular matrix given by
⎡ a11 a12 a13 ⎤
⎢
U =⎢ 0 ′
a22 ′ ⎥.
a23 ⎥ (7.47)
⎢⎣ 0 0 ′′ ⎥⎦
a33
Equation (7.47) suggests that in any computer program, the places occupied
by the zero elements may be used to store the values of the multipliers. Thus,
after elimination, the matrix A may be written as
⎡ a11 a12 a13 ⎤
⎢l ′
a22 ′
a23 ⎥,
⎢ 21 ⎥ (7.48)
⎢⎣ l31 l32 ′′
a33 ⎥⎦
Matrices of the type, given in Eq. (7.50), called the tridiagonal matrices,
occur frequently in the solution of ordinary and partial differential equations
by finite difference methods. The method of factorization described earlier
can be conveniently applied to solve the system (7.49). For example, for a
(3 ´ 3) matrix we have
⎡ b1 c1 0⎤ ⎡1 0 0 ⎤ ⎡b1 c1 0 ⎤
⎢a b2 c2 ⎥⎥ = ⎢⎢l21 1 0⎥⎥ ⎢⎢ 0 u22 c2 ⎥⎥
⎢ 2
⎢⎣ 0 a3 b3 ⎥⎦ ⎢⎣ 0 l32 1 ⎥⎦ ⎢⎣ 0 0 u33 ⎥⎦
This matrix equation gives
l21b1 = a2, l21c1 + u22 = b2, »
¼ (7.51)
l32u22 = a3, l32c2 + u33 = b3 ½
From these four equations, we can compute l21, u22, l32 and u33 and these
values are stored in the locations occupied by a2, b2, a3 and b3, respectively.
These computations can be achieved by the following statements:
Do i = 2(1)N
a(i) = a(i)/b(i 1)
b(i) = b(i) a(i) c(i 1)
Next i
When the decomposition is complete, forward and back substitutions give
the required solution. This algorithm is due to Thomas and possesses all the
advantages of the LU decomposition.
276 CHAPTER 7: Numerical Linear Algebra
So,
k = 4.468 ´ 103
Hence the system is ill-conditioned.
⎡ 25 24 10⎤
A = ⎢⎢66 78 37 ⎥⎥
⎣⎢92 –73 –80⎥⎦
Now,
| A | = 1.0.
Also,
s1 = 36.0694, s2 = 108.6692 and s3 = 142.1021.
Therefore,
k = 1.7954 ´ 106.
which shows that A is ill-conditioned.
Let x1(1) , x2(1) and x3(1) be an approximate solution. Substituting these values
in the left side of Eq. (7.55), we get new values of b1, b2 and b3. Let these
new values be b1(1) , b2(1) and b3(1) . The new system of equations is given by
a11 x1(1) a12 x2(1) a13 x3(1) b1(1) »
¯
(1) (1) (1) (1) ¯
a21 x1 a22 x2 a23 x3 b2 ¼ (7.56)
¯
a31 x1 a32 x2 a33 x3 b3 ¯
(1) (1) (1) (1)
½
Subtracting each equation given in Eq. (7.56) from the corresponding
equation given in Eq. (7.55), we obtain
a11e1 + a12 e2 + a13e3 = d1 ⎫
⎪⎪
a21e1 + a22 e2 + a23e3 = d 2 ⎬ (7.57)
⎪
a31e1 + a32 e2 + a33e3 = d3 ⎪⎭
where ei = xi xi(1) and di = bi bi(1) . We now solve the system (7.57) for
e1, e2 and e3. Since ei = xi xi(1) , we obtain
xi = xi(1) + ei , (7.58)
which is a letter approximation for xi. The procedure can be repeated to
improve upon the accuracy.
2 x(1) y (1) 3 »¯
¼ (i)
and 2 x(1) 1.01y (1) 3.01¯½
Subtracting each equation of (i) from the corresponding equation of the
given system, we get
2(x x(1)) + (y y(1)) = 1
and
2(x x(1)) + 1.01(y y(1)) = 1.
Solving the above system of equations, we obtain
1
x − x(1) = − and y − y (1) = 0.
2
SECTION 7.6: Solution of Linear SystemsIterative Methods 279
Hence
1
x= and y = 1,
2
which is the exact solution of the given system.
We have so far discussed some direct methods for the solution of simultaneous
linear equations and we have seen that these methods yield the solution after
an amount of computation that is known in advance. We shall now describe
the iterative or indirect methods, which start from an approximation to the
true solution and, if convergent, derive a sequence of closer approximations
the cycle of computations being repeated till the required accuracy is obtained.
This means that in a direct method the amount of computation is fixed,
while in an iterative method the amount of computation depends on the
accuracy required.
In general, one should prefer a direct method for the solution of a linear
system, but in the case of matrices with a large number of zero elements,
it will be advantageous to use iterative methods which preserve these elements.
Let the system be given by
|
Suppose x1(1) , x2(1) , , xn(1) are any first approximations to the unknowns
|
x1 , x2 , , xn . Substituting in the right side of Eq. (7.60), we find a system
of second approximations
b1 a12 (1) a ⎫
x1(2) = − x − " − 1n xn(1) , ⎪
a11 a11 2 a11
⎪
⎪
b a a
x2(2) = 2 − 21 x1(1) − " − 2 n xn(1) , ⎪
a22 a22 a22 ⎪
⎪
b3 a31 (1) a3n (1) ⎬ (7.61)
(2)
x3 = − x1 − " − xn , ⎪
a33 a33 a33 ⎪
# ⎪
⎪
(2) bn an1 (1) an,n −1 (1) ⎪
xn = − x −" − x .⎪
ann ann 1 ann n −1 ⎪⎭
Similarly, if x1(n), x2(n),…, xn( n) are a system of nth approximations, then the
next approximation is given by the formula
b1 a12 ( n ) a ⎫
x1( n +1) = − x2 − " − 1n xn( n) , ⎪
a11 a11 a11
⎪
⎪
b2 a21 a
x2( n +1) = − x1( n) − " − 2 n xn( n) , ⎪⎪
a22 a22 a22 ⎬ (7.62)
⎪
# ⎪
bn a a n, n −1 ( n ) ⎪
xn( n +1) = − n1 x1( n) − " − x .⎪
ann ann ann n−1 ⎪⎭
If we write Eq. (7.60) in the matrix form
X BX C (7.63)
then the iteration formula (7.62) may be written as
X ( n 1) BX ( n ) C. (7.64)
This method is due to Jacobi and is called the method of simultaneous
displacements. It can be shown that a sufficient condition for the convergence
of this method is that
|| B || 1. (7.65)
A simple modification in this method sometimes yields faster convergence
and is described below:
In the first equation of Eq. (7.60), we substitute the first approximation
( x1(1) , x 2(1) , x 3(1) ,…, x n(1) ) into the right-hand side and denote the result as x1(2) .
In the second equation, we substitute ( x1(2), x 2(1) , x 3(1) ,…, x n(1) ) and denote
SECTION 7.6: Solution of Linear SystemsIterative Methods 281
the result as x 2(2). In the third, we substitute ( x1(2) , x 2(2), x 3(1) ,…, x n(1) ) and
call the result as x 3(2). In this manner, we complete the first stage of iteration
|
and the entire process is repeated till the values of x1 , x2 , , xn are obtained
to the accuracy required. It is clear, therefore, that this method uses an
improved component as soon as it is available and it is called the method of
successive displacements, or the GaussSeidel method.
The Jacobi and GaussSeidel methods converge, for any choice of the
first approximation x (1) j ( j = 1, 2, …, n), if every equation of the system (7.60)
satisfies the condition that the sum of the absolute values of the coefficients
aij/aii is almost equal to, or in at least one equation less than unity, i.e.
provided that
|, n),
n aij
∑ aii
≤ 1, (i 1, 2, (7.66)
j =1, j ≠ i
where the < sign should be valid in the case of at least one equation. It
can be shown that the GaussSeidel method converges twice as fast as the
Jacobi method. The working of the methods is illustrated in the following
examples:
Example 7.13 We consider the equations:
10 x1 − 2 x2 − x3 − x4 =3
−2 x1 + 10 x2 − x3 − x4 = 15
− x1 − x2 + 10 x3 − 2 x4 = 27
− x1 − x2 − 2 x3 + 10 x4 = −9.
To solve these equations by the iterative methods, we re-write them as
follows:
x1 = 0.3 + 0.2 x2 + 0.1x3 + 0.1x4
x2 = 1.5 + 0.2 x1 + 0.1x3 + 0.1x4
x3 = 2.7 + 0.1x1 + 0.1x2 + 0.2 x4
x4 = −0.9 + 0.1x1 + 0.1x2 + 0.2 x3 .
It can be verified that these equations satisfy the condition given in
Eq. (7.66). The results are given in Tables 7.1 and 7.2:
Table 7.1 Gauss–Seidel Method
n x1 x2 x3 x4
n x1 x2 x3 x4
From Tables 7.1 and 7.2, it is clear that twelve iterations are required by
Jacobis method to achieve the same accuracy as seven GaussSeidel iterations.
Example 7.14 Solve the system
6x + y + z = 20
x + 4y z = 6
x y + 5z = 7
using both Jacobi and GaussSeidel methods.
(a) Jacobis method
We rewrite the given system as
20 1 1
x y z 3.3333 0.1667 y 0.1667 z
6 6 6
y 1.5 0.25 x 0.25 z
z 1.4 0.2 x 0.2 y
In matrix form, the above system may be written as
X = C + BX
where
⎡ 2.9991⎤ ⎡ 2.9995⎤
⎢ ⎥ ⎢ ⎥
X (8) = ⎢1.0012 ⎥ and X (9) = ⎢1.0005 ⎥ .
⎢ ⎥ ⎢ ⎥
⎢⎣1.0010 ⎥⎦ ⎢⎣1.0004 ⎥⎦
©3¸
ª ¹
X ª1¹ i.e., x 3, y 1 and z 1.
ª ¹
ª
«1¹
º
⎡ 2.8499 ⎤
⎢ ⎥
X (1) = ⎢1.0167 ⎥
⎢ ⎥
⎢⎣1.0333 ⎥⎦
Then
x(2) = 3.3333 0.1667 ´ 1.0167 0.1667 ´ 1.0333 = 2.9916
y(2) = 1.5 0.25 ´ 2.9916 + 0.25 ´ 1.0333 = 1.0104
z(2) = 1.4 0.2 ´ 2.9916 + 0.2 ´ 1.0104 = 1.0038
Similarly, we find
x(3) = 2.9975, y(3) = 1.0016, z(3) = 1.0008,
x(4) = 2.9995, y(4) = 1.0003, z(4) = 1.0002,
x(5) = 2.9998, y(5) = 1.0001, z(5) = 1.0001.
At this stage, we can conclude that
x = 3, y = 1, z = 1.
284 CHAPTER 7: Numerical Linear Algebra
⎡5 0 1⎤
A = ⎢⎢0 −2 0 ⎥⎥ .
⎢⎣ 1 0 5⎥⎦
5−M 0 1
0 −2 − M 0 = 0.
1 0 5−M
7 x1 + x3 = 0 and x1 + 7 x3 = 0
The solution is x1 = x3 = 0 with x2 arbitrary. In particular, we take x2 = 1
and the eigenvector is
⎡0 ⎤
X 1 = ⎢⎢1 ⎥⎥ .
⎢⎣0 ⎥⎦
(ii) l2 = 4. With
⎡ x1 ⎤
X 2 = ⎢⎢ x2 ⎥⎥
⎢⎣ x3 ⎥⎦
as the eigenvector, the equations are
x1 + x 3 = 0 and 6x2 = 0,
from which we obtain
x1 = x3 and x2 = 0.
286 CHAPTER 7: Numerical Linear Algebra
© 1/ 2 ¸
ª ¹
X2 ª 0 ¹.
ª 1/ 2 ¹º
«
(iii) l3 = 6. If
⎡ x1 ⎤
X 3 = ⎢⎢ x2 ⎥⎥
⎢⎣ x3 ⎥⎦
is the required eigenvector, then the equations are
− x1 + x3 = 0
−8 x2 = 0
x1 − x3 = 0,
which give x1 = x3 and x2 = 0.
Choosing x1 = x3 = 1/ 2, the normalized eigenvector is given by
⎡1/ 2 ⎤
⎢ ⎥
X3 = ⎢ 0 ⎥.
⎢1/ 2 ⎥
⎣ ⎦
⎡1 6 1⎤
A = ⎢⎢1 2 0 ⎥⎥ .
⎢⎣0 0 3⎥⎦
Let the initial eigenvector be
⎡1 ⎤
⎢0 ⎥ = X (0) ,
⎢ ⎥ say.
⎢⎣0 ⎥⎦
Then we have
⎡1 6 1 ⎤ ⎡1 ⎤ ⎡1 ⎤
AX (0)
= ⎢⎢1 2 0 ⎥⎥ ⎢⎢0 ⎥⎥ = ⎢⎢1 ⎥⎥ = X (1) , say
⎢⎣0 0 3⎥⎦ ⎢⎣0 ⎥⎦ ⎢⎣0 ⎥⎦
SECTION 7.7: Matrix Eigenvalue Problem 287
a11 − M a12 0
| A1 |= a12 a22 − M a23 = 0.
0 a23 a33 − M
Suppose that the above equation is written in the form
G3 (M ) = 0. (7.72)
288 CHAPTER 7: Numerical Linear Algebra
a11 − M a12
G2 ( M ) =
a12 a22 − M
= ( a11 − M ) (a22 − M ) − a 12
2
= G1 (M ) ( a22 − M ) − a 12
2
G0 ( M ) (7.76)
G3 (M ) = G2 (M ) (a33 − M ) − a 23
2
G1 (M ). (7.77)
In general, if
a11 − λ a12 0 … 0
a12 a22 − λ a23 … 0
φk (λ ) = , (2 c k c n), (7.78)
0 … … … …
0 … … ak −1, k akk − λ
then the recursion formula is
G k (M ) = (akk − M ) G k −1( M ) − ak2−1, k G k − 2 ( M ), (2 ≤ k ≤ n). (7.79)
where the primes denote that the elements have changed. Householder suggests
that P could be of the form
P = I 2VVT, (7.82)
where
V = [0, v2, v3]T and VTV = I (7.83)
The matrix equation in (7.83) means that
v22 + v32 = 1. (7.84)
It follows that
⎡1 0 0 ⎤
⎢ ⎥
P = ⎢0 1− 2v22 −2v2 v3 ⎥ (7.85)
⎢ ⎥
⎢⎣0 –2v2 v3 1 − 2v32 ⎥⎦
It can be verified that P is a symmetric orthogonal matrix as required. By
direct multiplications, we find PAP and equating it to Eq. (7.81) and after
some manipulations, we obtain
1© a12 ¸
v22 ª1 B ¹ (7.86)
2ª 2 2 ¹
« a12 a13 º
and
a13
v3 = B (7.87)
2 2
2v2 a12 + a13
290 CHAPTER 7: Numerical Linear Algebra
In Eq. (7.86), if the sign chosen is the same as that of a12, then v2 would
have a larger value and v3 can be computed from Eq. (7.87). See Wilkinson
[1960].
⎡1 0 0 ⎤
P1 = I − 2VV T = ⎢⎢0 −3/5 −4 / 5⎥⎥ .
⎢⎣0 −4/5 3/5 ⎥⎦
Hence we have
⎡1 0 0 ⎤ ⎡1 3 4 ⎤ ⎡1 0 0 ⎤
A1 = P1 AP1 = ⎢⎢0 −3/5 −4/5⎥⎥ ⎢⎢ 3 2 −1⎥⎥ ⎢⎢0 −3/5 −4/5⎥⎥
⎢⎣0 −4/5 3/5 ⎥⎦ ⎢⎣ 4 −1 1⎥⎦ ⎢⎣0 −4/5 3/5 ⎥⎦
⎡1 −5 0 ⎤
= ⎢⎢ −5 2/5 1/5 ⎥⎥ , on simplification .
⎣⎢ 0 1/5 13/5⎦⎥
SECTION 7.8: Singular Value Decomposition 291
7.7.3 QR Method
This is the most efficient and widely used general method for the computation
of all the eigenvalues of a general nonsymmetric matrix. Originally, due to
J.G.F. Francis, the method is quite complicated and, therefore, only a brief
presentation is given below.
Let A1 = A be the given matrix. Suppose that A1 is factorized into the form
A 1 = Q 1 R1 (7.88)
where Q1 is an orthogonal matrix and R1 is an upper triangular matrix.
Therefore,
Q11A1 = R1 (7.89)
The essential feature of this method is to find orthogonal matrices
P1P2
Pn1 such that
Pn1Pn2
P2P1A1 = R1 (7.90)
The matrices P are of the form I 2VVT such that P1A1 will contain zeros
below the diagonal in its first column, P2 P1A1 will contain zeros in its second
column below the diagonal, and so on. If we carry out this procedure with
each column of A1, then the final result will be R1, which is an upper
triangular matrix. The sequence {Ai} converges either to a triangular matrix
or to a near triangular matrix. In either case, the eigenvalues can be computed
easily.
and
UTU = VTV = VVT = In (7.96)
The decomposition defined by Eq. (7.94) is called the singular value
decomposition (SVD) of the matrix A.
⎡1 2⎤
A = ⎢⎢1 1 ⎥⎥ .
⎢⎣1 3 ⎥⎦
We have
⎡1 1 1⎤ ⎡3 6⎤
AT = ⎢ and AT A = ⎢
⎣2 1 3⎥⎦ ⎣6 14 ⎥⎦
The eigenvalues of ATA are given by M1 = 16.64 and M2 = 0.36. For the corres-
ponding eigenvectors, we have
⎡3 6 ⎤ ⎡ x1 ⎤ ⎡x ⎤
⎢6 ⎥ ⎢ ⎥ = 16.64 ⎢ 1 ⎥ ,
⎣ 14 ⎦ ⎣ x2 ⎦ ⎣ x2 ⎦
which gives the system:
3 x1 + 6 x2 = 16.64 x1
6 x1 + 14 x2 = 16.64 x2 .
The solution is given by
© 0.4033¸
x1 ª ¹.
« 0.9166 º
Again, we have
⎡3 6 ⎤ ⎡ x1 ⎤ ⎡x ⎤
⎢6 ⎥ ⎢ ⎥ = 0.36 ⎢ 1 ⎥ ,
⎣ 14 ⎦ ⎣ x2 ⎦ ⎣ x2 ⎦
EXERCISES 293
⎡0.5480 ⎤ ⎡ 0.1833 ⎤
⎢ 0.3235 ⎥ and ⎢ 0.8555 ⎥ .
⎢ ⎥ ⎢ ⎥
⎢⎣0.7727 ⎥⎦ ⎢⎣ −0.4889 ⎥⎦
⎡1 2 ⎤ ⎡ 0.5480 0.1833⎤
⎡ 4.080 0 ⎤ ⎡ 0.4033 0.9166 ⎤
A = ⎢⎢1 1 ⎥⎥ = ⎢⎢ 0.3235 0.8555⎥⎥ ⎢ .
⎣ 0 0.60⎥⎦ ⎢⎣ 0.9166 −0.4033 ⎥⎦
⎢⎣1 3 ⎥⎦ ⎢⎣0.7727 −0.4889 ⎥⎦
EXERCISES
© 2 5 –2¸ ⎡3 5⎤
If B ª
–1 0 0¹ and C = ⎢1
¹
0 ⎥⎥ , find A = BC.
ª ⎢
«ª 2 3 4 º¹ ⎣⎢ 2 0 ⎥⎦
7.3 Show that the product of two upper triangular matrices is also an
upper triangular matrix.
294 CHAPTER 7: Numerical Linear Algebra
⎡1 2 3⎤ ⎡ –1 0 2⎤
If A = ⎢⎢0 1 2 ⎥⎥ and B = ⎢ 0 1 –1⎥⎥ , find AB.
⎢
⎢⎣0 0 4 ⎥⎦ ⎢⎣ 0 0 3⎥⎦
7.4 Explain the back substitution process for the solution of the system
©a11 a12 " a1n ¸ © x1 ¸ © b1 ¸
ª
ª
0 a22 " a2n ¹¹ ª ¹ ª ¹
x b
ª 2¹ ª 2¹
ª # ¹ ª # ¹ ª# ¹
ª ¹ ª ¹ ª ¹
ª« 0 0 0 ann ¹º « xn ¹º ª
ª «bn ¹º
and give an algorithm to implement it. Solve the following system
2 x1 – 3x2 + x3 = – 1
–3x2 – x3 = – 9
5 x3 = 15
7.5 Find the inverse of the matrix
⎡2 3 1 ⎤
⎢
A = ⎢0 1.5 2.5⎥⎥
⎣⎢0 0 18 ⎦⎥
7.6 Find the inverse of the matrix
⎡2 0 0⎤
L = ⎢⎢ 2 1 0 ⎥⎥
⎢⎣ 3 2 2 ⎥⎦
7.7 Factorize the matrix
⎡4 3 –1⎤
A = ⎢⎢ 1 1 1⎥⎥
⎢⎣ 3 5 3⎥⎦
into the product LU where L is unit lower triangular and U upper
triangular.
7.8 Crouts Decomposition If a matrix A is decomposed into the product
of a lower triangular matrix and a unit upper triangular matrix, it is
called Crouts decomposition.
Decompose the matrix.
⎡1 1 1⎤
A = ⎢⎢ 4 3 –1⎥⎥
⎢⎣ 3 5 3⎥⎦
by Crouts method.
EXERCISES 295
⎡1 –1 1⎤
A = ⎢⎢1 –2 4 ⎥⎥
⎢⎣1 2 2 ⎥⎦
7.14 Solve the system of equations
10x + y + z = 12
2x + 10y + z = 13
x + y + 3z = 5
by both Gauss elimination and Gauss-Jordan methods.
7.15 Decompose the matrix
⎡5 –2 1⎤
A = ⎢⎢7 1 –5⎥⎥
⎢⎣ 3 7 4 ⎥⎦
296 CHAPTER 7: Numerical Linear Algebra
⎡4 3 2⎤
A = ⎢⎢ 2 3 4 ⎥⎥
⎢⎣ 1 2 1⎥⎦
into the form LU, where L is a lower triangular matrix and U is unit
upper triangular.
7.19 Solve the following system by Gauss elimination:
2x1 + 3x2 x3 + 2x4 = 7
x1 + x2 + x3 + x4 = 2
x1 + x2 + 3x3 2x4 = 6
x1 + 2x2 + x3 x4 = 2
7.20 An approximate solution of the system
10x1 + x2 + x3 = 12
x1 + 10x2 + x3 = 12
x1+ x2 + 10x3 = 12
is given as
x1(0) = 0.4, x2(0) = 0.6 and x3(0) = 0.8.
Use the iterative method of Section 7.5.11 to improve this solution.
7.21 Solve the system
10x + 2y + z = 9
2x + 20y 2z = 44
2x + 3y + 10z = 22
by Jacobis method.
7.22 Solve the system given in Problem 7.21 by GaussSeidel method.
EXERCISES 297
⎡5 0 1⎤ ⎡ x1 ⎤ ⎡ 8⎤
⎢0 –2 0 ⎥⎥ ⎢⎢ x2 ⎥⎥ = ⎢⎢ –4 ⎥⎥
⎢
⎢⎣ 1 0 5⎥⎦ ⎢⎣ x3 ⎥⎦ ⎢⎣ 16 ⎥⎦
by Choleskys method.
7.25 Explain what is meant by ill-conditioning of a matrix. Give two examples
of ill-conditioned matrices.
Is the matrix
⎡ 1 1⎤
⎢1 2 3⎥
⎢ ⎥
A=⎢
1 1 1⎥
⎢2 3 4⎥
⎢ ⎥
⎢1 1 1⎥
⎢⎣ 3 4 5 ⎥⎦
ill-conditioned?
7.26 Define norm of a matrix. List the different types of norms of a matrix.
What is condition number of a matrix.? Explain how the condition
number is useful in determining whether a matrix is ill-conditioned.
7.27 Centro-symmetric systems Equations of the type
a11x1 + a12x2 + a13x3 + a14x4 = b1 (i)
a21x1 + a22x2 + a23x3 + a24x4 = b2 (ii)
a24x1 + a23x2 + a22x3 + a21x4 = b3 (iii)
a14x1 + a13x2 + a12x3 + a11x4 = b4 (iv)
are called centro-symmetric systems. Such systems can be solved
easily by the following method. Adding (i) and (iv), we obtain an
298 CHAPTER 7: Numerical Linear Algebra
equation for (x1 + x4) and (x2 + x3). Similarly, adding (ii) and (iii), we
obtain another equation for (x1 + x4) and (x2 + x3). These two equations
give the values of (x1 + x4) and (x2 + x3). Again by subtractions, we
get two equations in (x1 x4) and (x2 x3). Computation of x1, x4 and
x2, x3 is now fairly easy.
Solve the system
x1 + x2 + 3x3 2x4 = 6
2x1 + 3x2 x3 + 2x4 = 7
2x1 x2 + 3x3 + 2x4 = 3
2x1 + 3x2 + x3 + x4 = 1
7.28 Determine the eigenvalues and the corresponding eigenvectors for
the following matrices:
⎡1 0 0⎤ ⎡5 0 1⎤
⎡ 2 2⎤
(a) ⎢ ⎥ (b) ⎢⎢0 1 1 ⎥⎥ (c) ⎢⎢0 –2 0 ⎥⎥
⎣⎢ 2 1 ⎦⎥ ⎢⎣0 1 1 ⎥⎦ ⎢⎣1 0 5 ⎥⎦
7.29 Use the iterative method to find the smallest eigenvalue of the matrix
©1 6 1¸
A ªª1 2 0¹¹
ª
«0 0 3¹º
7.30 Determine the largest eigenvalue and the corresponding eigenvector of
the matrix
© 1 3 –1¸
ª
B
ª
3 2 4 ¹¹
ª
« –1 4 10¹º
7.31 Using Householders method, obtain the tridiagonal form of the matrix
©1 3 4¸
A ªª 3 1 2¹¹
ª
«4 2 1 ¹º
7.32 Given the matrix
©0 1 4¸
A ªª1 3 1 ¹¹
ª« 2 1 0 ¹º
Answers to Exercises
©3 2 4 ¸ © x ¸ ©7 ¸
ª
7.1 (a) ª
2 1 1¹¹ ªª y ¹¹ ªª7 ¹¹
ª
«1 3 5¹º ª« z ¹º ª« 2¹º
© 2 0 ?1 ? 2¸ © x ¸ ©? 8¸
ª
ª
0 1 2 ? 1¹¹ ªª y ¹¹ ªª ? 1¹¹
(b)
ª 1 ?1 0 ? 1¹ ª z ¹ ª? 6¹
ª ¹ª ¹ ª ¹
«? 1
ª 3 0 ? 2¹º ª« u ¹º ª
« 7¹º
⎡ 7 10 ⎤
7.2 ⎢ –3 –5⎥
⎢ ⎥
⎢⎣17 10 ⎥⎦
7.4 x1 = 1, x2 = 2, x3 = 3
⎡1 7 ⎤
⎢2 –3
18 ⎥
⎢ ⎥
−1 ⎢ 5⎥
7.5 A = 0 +2 –
⎢ 18 ⎥
⎢ ⎥
⎢0 1 ⎥
0
⎣⎢ 18 ⎥⎦
⎡1 ⎤
⎢2 0 0⎥
−1 ⎢ ⎥
7.6 L = ⎢ –1 1 0⎥
⎢1 1⎥
⎢ –1 ⎥
⎣⎢ 4 2 ⎦⎥
⎡ ⎤
⎢1 0 0⎥
⎡4 3 –1⎤
⎢ ⎥ ⎢ 5 ⎥⎥
L=⎢ 0⎥ ,
1 1
7.7 1 U = ⎢0
⎢4 ⎥ ⎢ 4 4⎥
⎢ ⎥ ⎢0
⎢3 ⎣ 0 –10 ⎥⎦
11 1⎥
⎣⎢ 4 ⎦⎥
⎡1 0 0 ⎤ ⎡1 1 1⎤
7.8 ⎢4 –1 0 ⎥⎥ ⎢⎢0 1 5⎥⎥
⎢
⎢⎣ 3 2 –10 ⎥⎦ ⎢⎣0 0 1⎥⎦
7.10 x1 = 1, x2 = 1, x3 = 2.
7.11 x1 = 2.1557, x2 = 1.2746, x3 = 1.6246.
7.12 x1 = 1.0, x2 = 0.5, x3 = 0.5.
© ¸ © 3 1¸
ª4 0 0¹ ª1
4 2¹
ª ¹ ª ¹
ª 3
7.18 L 2 0 ¹, U ª
0 1 2¹
ª 2 ¹ ª ¹
ª ¹ ª ¹
ª1 5
–2¹ ª0 0 1¹
ª« 4 ¹º ª« ¹º
7.19 x4 = 2, x3 = 1, x2 = 0, x1 = 1.
7.20 x1 = x2 = x3 = 1.
7.21 5th iteration values are 0.9989, 1.9993, 2.9984.
7.22 4th iteration values are 0.9991, 1.9998, 2.9998.
7.23 6th iteration values are 0.9936, 1.5070, 1.8485.
7.24 x3 = 3, x2 = 2, x1 = 1.
7.25 ill-conditioned
7.27 x1 = 1, x2 = 0, x3 = 1, x4 = 2.
© 1 ¸ © 2¸
7.28 (a) M = 0, ª ¹; M 3, ª ¹
«– 2 º « 1 º
⎡ 0 ⎤ ⎡1 ⎤ ⎡ 0 ⎤
⎢ ⎥ ⎢0 ⎥ ; λ = 2, ⎢ ⎥
(b) λ = 0, ⎢ 1/ 2 ⎥ ; λ = 1, ⎢ ⎥ ⎢1/ 2 ⎥
⎢ ⎥ ⎢⎣0 ⎥⎦ ⎢ ⎥
⎣ –1/ 2 ⎦ ⎣1/ 2 ⎦
EXERCISES 301
© 0¸ © 1/ 2¸ ©1/ 2¸
ª ¹ ª ¹ ª ¹
(c) M – 2, 1 ;
ª ¹
M 4, ª 0 ¹; M 6, ª 0 ¹
ª ª ¹ ª ¹
« 0¹
º « –1/ 2º «1/ 2º
⎡ 1 ⎤
7.29 l = 1, ⎢ −0.33⎥
⎢ ⎥
⎢⎣ 0 ⎥⎦
⎡ 0.02 ⎤
7.30 l = 10.6, ⎢ 0.46 ⎥
⎢ ⎥
⎢⎣ 1.0 ⎥⎦
⎡ 1 –5 0 ⎤
⎢ 0.56 ⎥⎥
7.31 A1 = ⎢ –5 2.92
⎢⎣ 0 0.56 –0.92 ⎥⎦
⎡0 1 4 ⎤
7.32 ⎢0 2 0.8 ⎥⎥
⎢
⎢⎣0 –1 –0.4 ⎥⎦
Chapter
Numerical Solution of
Ordinary Differential Equations
8.1 INTRODUCTION
302
SECTION 8.2: Solution by Taylors Series 303
Example 8.1 From the Taylor series for y (x), find y (0.1) correct to four
decimal places if y (x) satisfies
y′ = x − y 2 and y (0) = 1.
The Taylor series for y (x) is given by
x2 x3 x 4 iv x5 v
y ( x) = 1 + xy0′ + y0′′ + y0′′′+ y + y +"
2 6 24 0 120 0
The derivatives y0′ , y0′′, … etc. are obtained thus:
y ′( x) = x − y 2 y0′ = −1
y ′′( x) = 1 − 2 yy ′ y0′′ = 3
y ′′′( x) = −2 yy ′′ − 2 y ′2 y0′′′= −8
y iv ( x) = −2 yy ′′′ − 6 y ′y ′′ y 0iv = 34
y vi ( x) = xy v ( x) + y iv ( x) + 4 y iv ( x) = xy v ( x) + 5 y iv ( x), (v)
SECTION 8.3: Picards Method of Successive Approximations 305
x2 x3 x 4 iv
y ( x) = y (0) + xy ′(0) + y ′′(0) + y ′′′(0) + y (0)
2 6 24
x5 v x6 vi
+ y (0) + y (0) + "
120 720
Hence
Equation (8.3), in which the unknown function y appears under the integral
sign, is called an integral equation. Such an equation can be solved by the
method of successive approximations in which the first approximation to y
is obtained by putting y0 for y on right side of Eq. (8.3), and we write
x
y (1) = y0 + ∫ f ( x, y0 ) dx
x0
The integral on the right can now be solved and the resulting y(1) is substituted
for y in the integrand of Eq. (8.3) to obtain the second approximation y(2):
x
y (2) = y0 + ∫ f ( x, y (1) ) dx
x0
Proceeding in this way, we obtain y (3) , y (4) ,…, y ( n −1) and y ( n ) , where
x
∫ f ( x, y ( n −1) ) dx
( n)
y = y0 + with y (0) = y0 (8.4)
x0
306 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
then the sequence y (1) , y (2) , … converges to the solution of Eq. (8.1).
Example 8.3 Solve the equation y ′ = x + y 2, subject to the condition y = 1
when x = 0.
We start with y (0) = 1 and obtain
x
1
∫ ( x + 1) dx = 1 + x + 2 x .
(1) 2
y =1+
0
Then the second approximation is
x
⎡ ⎛ 1 ⎞ ⎤
2
∫
(2)
y =1+ ⎢ x + ⎜1 + x + x 2 ⎟ ⎥ dx
0 ⎢⎣ ⎝ 2 ⎠ ⎥⎦
3 2 2 3 1 4 1 5
=1+ x +
x + x + x + x .
2 3 4 20
It is obvious that the integrations might become more and more difficult as
we proceed to higher approximations.
Example 8.4 Given the differential equation
dy x2
= 2
dx y + 1
with the initial condition y = 0 when x = 0, use Picards method to obtain y
for x = 0.25, 0.5 and 1.0 correct to three decimal places.
We have
x
x2
y= ∫ y2 + 1
dx.
0
(0)
Setting y = 0, we obtain
x
1
y (1) = ∫ x 2 dx = x3
3
0
and
x
x2 ⎛1 ⎞ 1 1
∫ dx = tan −1 ⎜ x3 ⎟ = x3 − x9 + "
(2)
y = 6
0
(1/9) x + 1 ⎝3 ⎠ 3 81
SECTION 8.4: Eulers Method 307
so that y(1) and y(2) agree to the first term, viz., (1/3)x3. To find the range
of values of x so that the series with the term (1/3)x3 alone will give the
result correct to three decimal places, we put
1 9
x ≤ 0.0005
81
which yields
x ≤ 0.7
Hence
1
y (0.25) = (0.25)3 = 0.005
3
1
y (0.5) = (0.5)3 = 0.042
3
1 1
y (1.0) = − = 0.321
3 81
We have so far discussed the methods which yield the solution of a differential
equation in the form of a power series. We will now describe the methods
which give the solution in the form of a set of tabulated values.
Suppose that we wish to solve the Eqs. (8.1) for values of y at
x = xr = x0 + rh(r = 1, 2,
). Integrating Eq. (8.1), we obtain
x1
y1 = y0 + ∫ f ( x, y ) dx. (8.6)
x0
The exact solution is y = e− x and from this the value at x = 0.04 is 0.9608.
h2
y ( xn1 ) y ( xn ) hy b ( xn ) y bb ( xn ) "
2
h2
y ( xn ) hy b( xn ) y bb (U n ), where xn c U n c xn1. (8.9)
2
We usually encounter two types of errors in the solution of differential
equations. These are (i) local errors, and (ii) rounding errors. The local
error is the result of replacing the given differential equation by means of
the equation
yn +1 = yn + hyn′ .
This error is given by
1
Ln +1 = – h 2 y ′′ (U n ) (8.10)
2
The total error is then defined by
en = yn y(xn) (8.11)
Since y0 is exact, it follows that e0 = 0.
Neglecting the rounding error, we write the total solution error as
en +1 = yn +1 − y ( xn +1 )
= yn + hyn′ – [ y ( xn ) + hy ′( xn ) – Ln +1 ]
= en + h [ f ( xn , yn ) – y ′( xn )] + Ln +1.
SECTION 8.4: Eulers Method 309
Þ en 1 en h < f ( xn , yn ) f ( xn , y ( xn ))> Ln 1.
By mean value theorem, we write
vf
f ( xn , yn ) f ( xn , y( xn )) < yn – y( xn )> ( xn , Yn ), y ( xn ) c Y n c yn .
vy
Hence, we have
en +1 = en ⎡⎣1 + hf y ( xn , Yn ) ⎤⎦ + Ln +1 (8.12)
Since e0 = 0, we obtain successively:
e1 L1 ; e2 ©1
«
hf y ( x1 , Y1 )¸º L1 L2 ;
See the book by Isaacson and Keller [1966] for more details.
Example 8.6 We consider, again, the differential equation y ′ = − y with the
condition y (0) = 1, which we have solved by Eulers method in Example 8.5.
Choosing h = 0.01, we have
1 + hf y ( xn , Yn ) = 1 + 0.01( −1) = 0.99.
and
1
Ln +1 = − h 2 y ′′( Sn ) = −0.00005 y ( Sn ).
2
In this problem, y ( Sn ) ≤ y ( xn ), since y ′ is negative. Hence we successively
obtain
| L1 | ≤ 0.00005 = 5 × 10−5,
It can be verified that the estimate for e4 agrees with the actual error in the
value of y(0.04) obtained in Example 8.5.
RungeKutta methods are designed to give greater accuracy and they possess
the advantage of requiring only the function values at some selected points
on the subinterval.
If we substitute y1 = y0 + hf ( x0 , y0 ) on the right side of Eq. (8.13), we
obtain
h
y1 = y0 + [ f 0 + f ( x0 + h, y0 + hf 0 )],
2
where f 0 = f ( x0 , y0 ). If we now set
k1 = hf 0 and k 2 = hf ( x0 + h, y0 + k1 )
then the above equation becomes
1
y1 = y0 + (k1 + k2 ), (8.15)
2
which is the second-order RungeKutta formula. The error in this formula
can be shown to be of order h3 by expanding both sides by Taylors series.
Thus, the left side gives
h2 h3
y0 hy0b y0bb y0bbb "
2 6
and on the right side
⎡ ∂f ∂f ⎤
k2 = hf ( x0 + h, y0 + hf 0 ) = h ⎢ f 0 + h + hf 0 + O (h 2 ) ⎥ .
⎣ ∂x0 ∂y0 ⎦
Since
df ( x, y ) ∂f ∂f
= +f ,
dx ∂x ∂y
we obtain
k2 = h [ f 0 + hf 0′ + O (h 2 )] = hf 0 + h 2 f 0′ + O (h3 ),
h2
= y0 + hy0′ + y0′′ + O ( h3 ).
2
It therefore follows that the Taylor series expansions of both sides of Eq. (8.15)
agree up to terms of order h2, which means that the error in this formula
is of order h3.
More generally, if we set
y1 = y0 + W1k1 + W2 k 2 (8.16a)
where
k1 = hf 0 ⎫⎪
⎬ (8.16b)
k2 = hf ( x0 + α 0 h, y0 + β 0 k1 ) ⎪⎭
312 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
then the Taylor series expansions of both sides of the last equation in (8.16a)
gives the identity
h2 ⎛ ∂f ∂f ⎞ 3
y0 + hf0 + ⎜ + f0 ⎟ + O (h ) = y0 + (W1 + W2 ) hf0
2 ⎝ ∂x ∂y ⎠
⎛ ∂f ∂f ⎞
+ W2 h2 ⎜ B 0 + C0 f0 ⎟ + O (h3 ).
⎝ ∂x ∂y ⎠
Equating the coefficients of f (x, y) and its derivatives on both sides, we
obtain the relations
1 1
W1 + W2 = 1, W2B 0 = , W2 C0 = . (8.17)
2 2
Clearly, B 0 = C0 and if B 0 is assigned any value arbitrarily, then the remaining
parameters can be determined uniquely. If we set, for example, B 0 = C0 = 1,
then we immediately obtain W1 = W2 = 1/2, which gives formula (8.15).
It follows, therefore, that there are several second-order RungeKutta formulae
and that formulae (8.16) and (8.17) constitute just one of several such
formulae.
Higher-order RungeKutta formulae exist, of which we mention only the
fourth-order formula defined by
y1 = y0 + W1k1 + W2 k 2 + W3 k3 + W4 k 4 (8.18a)
where
k1 = hf ( x0 , y0 ) ⎫
⎪
k2 = hf ( x0 + B 0 h, y0 + C0 k1 ) ⎪⎪
⎬ (8.18b)
k3 = hf ( x0 + B1h, y0 + C1k1 + O1k2 ) ⎪
⎪
k4 = hf ( x0 + B 2 h, y0 + C 2 k1 + O 2 k2 + E1k3 ), ⎪⎭
where the parameters have to be determined by expanding both sides of the
first equation of (8.18a) by Taylors series and securing agreement of terms
up to and including those containing h4. The choice of the parameters is,
again, arbitrary and we have therefore several fourth-order RungeKutta
formulae. If, for example, we set
1 ⎫
B 0 = C0 = , B1 = 1 , B 2 = 1, ⎪
2 2 ⎪
1 ⎪
C1 = ( 2 − 1), C2 = 0 ⎪
2 ⎪
⎬ (8.19)
1 1 1 ⎪
O1 = 1 − , O = − , E = 1 + ,
2
2
2
1
2 ⎪
⎪
1 1⎛ 1 ⎞ 1⎛ 1 ⎞⎪
W1 = W4 = , W2 = ⎜1 − ⎟, W3 = ⎜1 + ⎟,
6 3⎝ 2⎠ 3⎝ 2 ⎠ ⎪⎭
SECTION 8.5: RungeKutta Method 313
B 0 = B1 = 1 , 1 ⎫
C0 = O1 =
2 2 ⎪
⎪
C1 = C2 = O 2 = 0, ⎪ (8.20)
B 2 = E1 = 1 ⎬
⎪
W1 = W4 = ,
1 2 ⎪
W2 = W3 = ⎪
6 6 ⎭
leads to the fourth-order RungeKutta formula, the most commonly used
one in practice:
1
y1 = y0 + (k1 + 2k2 + 2k3 + k4 ) (8.21a)
6
where
k1 = hf ( x0 , y0 ) ⎫
⎪
⎛ 1 1 ⎞⎪
k2 = hf ⎜ x0 + h, y0 + k1 ⎟ ⎪
⎝ 2 2 ⎠⎪
(8.21b)
⎬
⎛ 1 1 ⎞⎪
k3 = hf ⎜ x0 + h, y0 + k2 ⎟ ⎪
⎝ 2 2 ⎠
⎪
k4 = hf ( x0 + h, y0 + k3 ) ⎪
⎭
in which the error is of order h5. Complete derivation of the formula is
exceedingly complicated, and the interested reader is referred to the book by
Levy and Baggot. We illustrate here the use of the fourth-order formula by
means of examples.
Example 8.8 Given dy/dx = y − x where y (0) = 2, find y (0.1) and y (0.2)
correct to four decimal places.
(i) RungeKutta second-order formula: With h = 0.1, we find k1 = 0.2
and k 2 = 0.21. Hence
1
y1 = y (0.1) = 2 + (0.41) = 2.2050.
2
To determine y2 = y (0.2), we note that x0 = 0.1 and y0 = 2.2050. Hence,
k1 = 0.1(2.105) = 0.2105 and k2 = 0.1(2.4155 − 0.2) = 0.22155.
It follows that
1
y2 = 2.2050 + (0.2105 + 0.22155) = 2.4210.
2
Proceeding in a similar way, we obtain
y3 = y (0.3) = 2.6492 and y4 = y (0.4) = 2.8909
314 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
We next choose h = 0.2 and compute y (0.2) and y(0.4) directly. With h = 0.2.
x0 = 0 and y0 = 2, we obtain k1 = 0.4 and k2 = 0.44 and hence y(0.2) =
2.4200. Similarly, we obtain y(0.4) = 2.8880.
From the analytical solution y = x + 1 + ex, the exact values of y(0.2)
and y(0.4) are respectively 2.4214 and 2.8918. To study the order of conver-
gence of this method, we tabulate the values as follows:
x Computed y Exact y Difference Ratio
Example 8.10 We consider the initial value problem y ′ = 3x + y/2 with the
condition y(0) = 1.
The following table gives the values of y(0.2) by different methods, the
exact value being 1.16722193. It is seen that the fourth-order RungeKutta
method gives the accurate value for h = 0.05.
Method h Computed value
n (n + 1) 2 n (n + 1) (n + 2) 3 (8.22)
f ( x, y ) = f 0 + n∇f 0 + ∇ f0 + ∇ f0 + "
2 6
where
x − x0
n= and f 0 = f ( x0 , y0 ).
h
If this formula is substituted in
x1
y1 = y0 + ∫ f ( x, y ) dx, (8.23)
x0
we get
x1
⎡ n ( n + 1) 2 ⎤
y1 = y0 + ∫ ⎢ f0 + n∇f0 +
⎣ 2
∇ f0 + "⎥ dx
⎦
x0
1
⎡ n (n + 1) 2 ⎤
= y0 + h ∫ ⎢⎣ f0 + n∇f0 + 2
∇ f0 + "⎥ dn
⎦
0
⎛ 1 5 3 251 4 ⎞
= y0 + h ⎜1 + ∇ + ∇ 2 + ∇3 + ∇ + "⎟ f0 .
⎝ 2 12 8 720 ⎠
It can be seen that the right side of the above relation depends only on y0,
y1, y2,
, all of which are known. Hence this formula can be used to
compute y1. We therefore write it as
⎛ 1 5 3 251 4 ⎞
y 1p = y0 + h ⎜ 1 + ∇ + ∇ 2 + ∇3 + ∇ + "⎟ f0 (8.24)
⎝ 2 12 8 720 ⎠
n (n 1) 2 n (n 1) (n 2) 3
f ( x, y ) f1 nf1 f1 f1 " (8.25)
2 6
SECTION 8.6: PredictorCorrector Methods 317
0
⎡ n (n + 1) 2 ⎤
= y0 + h ∫ ⎢⎣ f1 + n∇f1 + 2
∇ f1 + "⎥ dn
⎦
1
⎛ 1 1 1 19 4 ⎞
= y0 + h ⎜1 − ∇ − ∇ 2 − ∇3 − ∇ − " ⎟ f1 (8.26)
⎝ 2 12 24 720 ⎠
The right side of Eq. (8.26) depends on y1, y0, y1,
where for y1 we
p
use y 1 , the predicted value obtained from (8.24). The new value of y1 thus
obtained from Eq. (8.26) is called the corrected value, and hence we rewrite
the formula as
⎛ 1 1 1 19 4 ⎞
y 1c = y0 + h ⎜ 1 − ∇ − ∇ 2 − ∇3 − ∇ − " ⎟ f 1p (8.27)
⎝ 2 12 24 720 ⎠
This is called AdamsMoulton corrector formula the superscript c indicates
that the value obtained is the corrected value and the superscript p on the
right indicates that the predicted value of y1 should be used for computing
the value of f (x1, y1).
In practice, however, it will be convenient to use formulae (8.24) and
(8.27) by ignoring the higher-order differences and expressing the lower-
order differences in terms of function values. Thus, by neglecting the fourth
and higher-order differences, formulae (8.24) and (8.27) can be written as
h
y 1p = y0 + (55 f 0 − 59 f −1 + 37 f −2 − 9 f −3 ) (8.28)
24
and
h
y 1c = y0 +
(9 f 1p + 19 f 0 − 5 f −1 + f −2 ) (8.29)
24
in which the errors are approximately
251 5 (4) 19 5 (4)
h f0 and − h f 0 respectively.
720 720
The general forms of formulae (8.28) and (8.29) are given by
h
y np+1 = yn + [55 f n − 59 f n −1 + 37 f n − 2 − 9 f n −3 ] (8.28a)
24
and
h
y nc +1 = yn +
[9 f np+1 + 19 f n − 5 f n −1 + f n − 2 ] (8.29a)
24
Such formulae, expressed in ordinate form, are often called explicit predictor
corrector formulae.
318 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
The values y1, y2 and y3, which are required on the right side of
Eq. (8.28) are obtained by means of the Taylors series, or Eulers method,
or RungeKutta method. Due to this reason, these methods are called starter
methods. For practical problems, RungeKutta fourth-order formula
together with formulae (8.28) and (8.29) have been found to be the most
successful combination. The following example will illustrate the application
of this method.
0.2
y p (0.8) 0.6841 {55 [1 (0.6841) 2 ] 59 [1 (0.4228)2 ]
24
37 [1 (0.2027)2 ] 9}
1.0233, on simplification.
Using this predicted value on the right side of Eq. (8.29), we obtain
0.2
y c (0.8) 0.6841 {9 [1 (0.0233)2 ] 19 [1 (0.6841) 2 ]
24
5 [1 (0.4228)2 ] [1 (0.2027)2 ]}
1.0296, which is correct to four decimal places
The importance of the method lies in the fact that when once y 1p is computed
from formula (8.28), formula (8.29) can be used iteratively to obtain the
value of y1 to the accuracy required.
n (n − 1) 2 n (n − 1) (n − 2) 3 (8.30)
f ( x , y ) = f 0 + n Δf 0 + Δ f0 + Δ f0 + "
2 6
Substituting Eq. (8.30) in the relation
x4
y4 = y0 + ∫ f ( x, y ) dx (8.31)
x0
SECTION 8.6: PredictorCorrector Methods 319
we obtain
x4
⎡ n (n − 1) 2 ⎤
y4 = y0 + ∫ ⎢ f 0 + n'f 0 +
⎣ 2
' f 0 + "⎥ dx
⎦
x0
4
⎡ n (n − 1) 2 ⎤
= y0 + h ∫ ⎢⎣ f0 + n'f0 + 2
' f 0 + "⎥ dn
⎦
0
⎛ 20 2 8 ⎞
= y0 + h ⎜ 4 f0 + 8'f0 + ' f0 + '3 f 0 + " ⎟
⎝ 3 3 ⎠
4h
= y0 + (2 f1 − f 2 + 2 f3 ) (8.32)
3
after neglecting fourth- and higher-order differences and expressing differences
'f 0 , ' 2 f 0 and '3 f 0 in terms of the function values.
This formula can be used to predict the value of y4 when those of y0,
y1, y2 and y3 are known. To obtain a corrector formula, we substitute
Newtons formula from (8.30) in the relation
x2
y2 = y0 + ∫ f ( x, y ) dx (8.33)
x0
and get
2
⎡ n (n − 1) 2 ⎤
y2 = y0 + h ∫ ⎢⎣ f0 + n'f0 + 2
' f 0 + "⎥ dn
⎦
0
⎛ 1 ⎞
= y0 + h ⎜ 2 f0 + 2'f0 + ' 2 f0 + " ⎟
⎝ 3 ⎠
h (8.34)
= y0 + ( f0 + 4 f1 + f 2 )
3
The value of y4 obtained from Eq. (8.32) can therefore be checked by
using Eq. (8.34).
The general form of Eqs. (8.32) and (8.34) are:
4h
ynp+1 = yn −3 + (2 f n − 2 − f n −1 + 2 f n ) (8.32a)
3
and
h
ync +1 = yn −1 + ( f n −1 + 4 f n + f n +1 ) (8.34a)
3
320 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
–0.1 1.0900
0 1.0000
0.1 0.8900
0.2 0.7605
4 (0.1)
y (0.3) = 1.09 + [2 (−1) − (−1.19790) + 2 (−1.38164)] = 0.614616.
3
In order to apply Eq. (8.34), we need to compute y ′(0.3). We have
0.1
y (0.3) = 0.89 + [−1.197900 + 4 (−1.38164) + (−1.532247)] = 0.614776.
3
( xi − x) 2 ( x − xi −1 ) ( x − xi −1 )2 ( xi − x)
s ( x) = mi −1 − mi
h2 h2
( xi − x)2 [2( x − xi −1 ) + h] ( x − xi −1 )2 [2( xi − x) + h]
+ yi −1 + yi , (8.35)
h3 h3
which gives
2mi −1 4mi 6
s′′( xi ) = + − 2 ( yi − yi −1 )
h h h
2mi −1 4mi 6
= + − 2 ( si − si −1 ). (8.38)
h h h
If we now consider the initial-value problem
dy
= f ( x, y ) (8.39a)
dx
and
y ( x0 ) = y0 (8.39b)
then from Eq. (8.39a), we obtain
d2y ∂f ∂f dy
= + ,
dx 2 ∂x ∂y dx
or
y ′′( xi ) = f x ( xi , yi ) + f y ( xi , yi ) f ( xi , yi )
= f x ( xi , si ) + f y ( xi , si ) f ( xi , si ). (8.40)
Equating Eqs. (8.38) and (8.40), we obtain
2mi −1 4mi 6
+ − 2 ( si − si −1 ) = f x ( xi , si ) + f y ( xi , si ) f ( xi , si ) (8.41)
h h h
from which si can be computed. Substitution in Eq. (8.35) gives the required
solution.
The following example demonstrates the usefulness of the spline method.
y = 13e x /2 − 6 x − 12 (ii)
We take, for simplicity, n = 2, i.e. h = 0.5 and compute the value of y (0.5).
Here f ( x, y ) = 3x + y/2 and therefore we have fx = 3 and fy = 1/2. Also,
1
f ( xi , si ) = 3 xi + si .
2
SECTION 8.8: Simultaneous and Higher-Order Equations 323
In a similar manner, one can extend the Taylor series method or Picards
method to the system (8.42). The extension of the RungeKutta method to
a system of n equations is quite straightforward.
We now consider the second-order differential equation
y ′′ = F ( x, y, y ′) (8.44a)
with the initial conditions
y ( x0 ) = y0 and y ′( x0 ) = y0′ . (8.45a)
The cubic spline method is a one-step method and at the same time a
global one. The step-size can be changed during computations and, under
certain conditions, gives O(h4) convergence. The method can also be extended
to systems of ordinary differential equations.
h2 h3
y ( x + h) = y ( x) + hy ′( x) + y ′′( x) + y ′′′( x) + " (8.50)
2 6
from which we obtain
y ( x + h) − y ( x ) h
y ′( x) = − y ′′( x) −"
h 2
Thus we have
y ( x + h) − y ( x )
y ′( x) = + O ( h) (8.51)
h
326 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
h2 h3
y ( x − h) = y ( x) − hy ′( x ) + y ′′( x ) − y ′′′( x ) + " (8.52)
2 6
from which we obtain
y ( x ) − y ( x − h)
y ′( x) = + O ( h) (8.53)
h
which is the backward difference approximation for y ′( x).
A central difference approximation for y ′( x) can be obtained by subtracting
Eq. (8.52) from Eq. (8.50). We thus have
y ( x + h) − y ( x − h)
y ′( x) = + O ( h 2 ). (8.54)
2h
It is clear that Eq. (8.54) is a better approximation to y ′( x) than either
Eq. (8.51) or Eq. (8.53). Again, adding Eqs. (8.50) and (8.52), we get an
approximation for y ′′( x)
y ( x − h) − 2 y ( x ) + y ( x + h)
y ′′( x) = + O (h 2 ). (8.55)
h2
In a similar manner, it is possible to derive finite-difference approximations
to higher derivatives.
To solve the boundary-value problem defined by Eqs. (8.46) and (8.47),
we divide the range [x0, xn] into n equal subintervals of width h so that
xi = x0 + ih, i = 1, 2, …, n.
The corresponding values of y at these points are denoted by
y ( xi ) = yi = y ( x0 + ih), i = 0, 1, 2, …, n.
From Eqs. (8.54) and (8.55), values of y ′( x) and y ′′( x) at the point x = xi
can now be written as
y − yi −1
yi′ = i +1 + O (h2 )
2h
and
y − 2 yi + yi +1
yi′′ = i −1 + O (h 2 ).
h2
Satisfying the differential equation at the point x = xi , we get
yi′′+ fi yi′ + gi yi = ri
Substituting the expressions for yi′ and yi′′, this gives
yi −1 − 2 yi + yi +1 yi +1 − yi −1
2
+ fi + gi yi = ri , i = 1, 2, …, n − 1,
h 2h
where yi = y ( xi ), gi = g ( xi ), etc.
SECTION 8.10: Boundary-Value Problems 327
h 2 iv
U = ( y i + 2 fi yi′′′ ) + O (h 4 ). (8.58)
12
Thus, the finite difference approximation defined by Eq. (8.56) has second-
order accuracy for functions with continuous fourth derivatives on [x0, xn].
Further, it follows that τ → 0 as h → 0, implying that greater accuracy in
the result can be achieved by using a smaller value of h. In such a case, of
course, more computational effort would be required since the number of
equations become larger.
An easier way to improve accuracy is to employ Richardsons deferred
approach to the limit, assuming that the O(h2) error is proportional to h2.
This means that the error has the form
y ( xi ) − yi = h 2 e( xi ) + O ( h4 ) (8.59)
For extrapolation to the limit, we solve Eq. (8.56) twice, with the
interval lengths h and h/2 respectively. Let the corresponding solutions of
Eq. (8.56) be denoted by yi(h) and yi(h/2). For a point xi common to both,
we therefore have
y ( xi ) − yi (h) = h2 e( xi ) + O (h 4 ) (8.60a)
and
2
⎛h⎞ h
y ( xi ) − yi ⎜ ⎟ = e( xi ) + O (h 4 ) (8.60b)
⎝2⎠ 4
from which we obtain
4 yi (h /2) − yi (h)
y ( xi ) = . (8.61)
3
328 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
We have explained the method with simple boundary conditions (8.47) where
the function values on the boundary are prescribed. In many applied problems,
however, derivative boundary conditions may be prescribed, and this requires
a modification of the procedures described above. The following examples
illustrate the application of the finite-difference method.
Example 8.15 A boundary-value problem is defined by
y ′′ + y + 1 = 0, 0 ≤ x ≤1
where
y (0) = 0 and y (1) = 0.
With h = 0.5, use the finite-difference method to determine the value of y(0.5).
This example was considered by Bickley [1968]. Its exact solution is
given by
1 − cos 1
y ( x) = cos x + sin x − 1,
sin1
from which, we obtain
y (0.5) = 0.139493927.
Here nh = 1. The differential equation is approximated as
yi −1 − 2 yi + yi +1
+ yi + 1 = 0
h2
and this gives after simplification
yi −1 − (2 − h 2 ) yi + yi +1 = − h2 , i = 1, 2, …, n − 1
which together with the boundary conditions y0 = 0 and yn = 0, comprises
a system of (n + 1) equations for the (n + 1) unknowns y0 , y1 , …, yn .
Choosing h = 1/2 (i.e. n = 2), the above system becomes
⎛ 1⎞ 1
y0 − ⎜ 2 − ⎟ y1 + y2 = − .
⎝ 4 ⎠ 4
With y0 = y2 = 0, this gives
1
y1 = y (0.5) = = 0.142857142…
7
Comparison with the exact solution given above shows that the error in the
computed solution is 0.00336.
On the other hand, if we choose h = 1/4 (i.e. n = 4), we obtain the three
equations:
31 1
y0 − y1 + y2 = −
16 16
31 1
y1 − y2 + y3 = −
16 16
31 1
y2 − y3 + y4 = − ,
16 16
SECTION 8.10: Boundary-Value Problems 329
If we divide the interval [0, 1] into two equal subintervals, then from Eq. (i)
and the recurrence relations for Mi, we obtain
3
y (0.5) = = 0.13636, (ii)
22
and
25
M 0 = −1, M1 = − , M 2 = −1
22
Hence we obtain
47 47
s ′(0) =
, s′(1) = − , s′(0.5) = 0.
88 88
From the analytical solution of the problem (i), we observe that
y(0.5) = 0.13949 and hence the cubic spline solution of the boundary-value
problem has an error of 2.24% (see Bickley [1968]).
Example 8.18 Given the boundary-value problem
x 2 y ′′ + xy ′ − y = 0; y (1) = 1, y (2) = 0.5
apply the cubic spline method to determine the value of y(1.5).
The given differential equation is
1 1
y ′′ = − y ′ + 2 y. (i)
x x
Setting x = xi and y ′′( xi ) = M i , Eq. (i) becomes
1 1 (ii)
Mi = − yi′ + 2 yi .
xi xi
Using the expressions given in Eqs. (8.63) and (8.64), we obtain
1 ⎛ h h y − yi ⎞ 1
Mi = − ⎜ − M i − M i +1 + i +1 ⎟ + 2 yi , i = 0, 1, 2,…, n − 1. (iii)
xi ⎝ 3 6 h ⎠ xi
and
1 ⎛h h y − yi −1 ⎞ 1
Mi = − M i + M i −1 + i ⎟ + 2 yi , i = 1, 2,…, n. (iv)
xi ⎜⎝ 3 6 h ⎠ xi
2 y0 + y1 = 24 ( y1 − y0 ) (x)
Equations (ix) and (x) yield
598
y1 = y (0.5) = = 0.7266.
823
Thus the error in the cubic spline solution is 0.0044. This example demonstrates
the superiority of the cubic spline method over the finite difference method
when the boundary value problem contains derivative boundary conditions.
¥B G ( x),
n
t( x) i i (8.69)
i1
334 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
where fi(x) are called base functions. Substituting for t(x) in Eq. (8.67), we
obtain a residual. Denoting this residual by R(t),
we obtain
R(t ) = t ′′ + p( x)t ′ + q( x)t − f ( x) (8.70)
Usually the base functions fi(x) are chosen as weight functions. We, therefore,
have
b
∫
I = Gi ( x) R(t ) dx = 0, (8.71)
a
which yields a system of equations for the parameters ai. When ai are
known, t(x) can be calculated from Eq. (8.69).
0 0
on integrating by parts.
1
± t b(1 2 x ) dx, since the first term vanishes.
0
© 1 ¸
1
ª\t (1 2 x )^0 ¹
ª
± t (–2) dx¹
« 0 º
1
∫
= − 2 t dx, since t = 0 at x = 0 and x = 1.
0
EXERCISES 335
EXERCISES
8.1. Given
dy
= 1 + xy, y (0) = 1,
dx
obtain the Taylor series for y(x) and compute y(0.1), correct to four
decimal places.
8.2 Show that the differential equation
d2y
= – xy, y (0) = 1 and y ′(0) = 0 ,
dx 2
has the series solution
x3 1 t 4 6 1 t 4 t 7 9
y 1 x x "
3! 6! 9!
336 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
8.3 If
dy 1
= with y (4) = 4,
dx x 2 + y
compute the values of y (4.1) and y (4.2) by Taylors series method.
8.4 Use Picards method to obtain a series solution of the problem given
in Problem 8.1 above.
8.5 Use Picards method to obtain y (0.1) and y (0.2) of the problem defined
by
dy
x yx 4 , y(0) 3.
dx
8.6 Using Eulers method, solve the following problems:
dy 3 3 dy
(a) x y , y(0) 1 (b) 1 y 2 , y(0) 0
dx 5 dx
8.7 Compute the values of y (1.1) and y (1.2) using Taylors series method
for the solution of the problem
y ′′ + y 2 y1 = x3 , y (1) = 1 and y ′(1) = 1.
8.8 Find, by Taylors series method, the value of y (0.1) given that
y bb – xy b y 0, y(0) 1 and y b(0) 0.
8.9 Using Picards method, find y (0.1), given that
dy y x
and y (0) 1.
dx y x
8.10 Using Taylors series, find y (0.1), y (0.2) and y (0.3) given that
dy
= xy + y 2 , y (0) = 1.
dx
8.11 Given the differential equation
dy
= x2 + y
dx
with y (0) = 1, compute y (0.02) using Eulers modified method.
∂ 2u ∂ 2u
+
= 2, 0 ≤ x, y ≤ 1
∂x 2 ∂y 2
with u = 0 on the boundary C of the square region 0 £ x £ 1, 0 £ y £ 1.
Answers to Exercises
8.1 1.1053
x3 1 × 4 6 1 × 4 × 7 9
8.2 1− + x − x +"
3! 6! 9!
8.3 4.005, 4.0098
340 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
x 2 x3 x 4
8.4 1 + x + + + +"
2 3 8
8.5 3.005, 3.0202
8.8 1.005012
8.9 1.0906
8.11 1.0202
Numerical Solution of
Partial Differential Equations
9.1 INTRODUCTION
D = B2 4AC, (9.2)
where D is computed at any point in the (x, y) plane. Equation (9.1) is said
to be elliptic, parabolic or hyperbolic according as D < 0, D = 0 or D > 0.
For example,
uxx + uyy = 0 (Laplace equation) is elliptic (9.3)
uxx uyy = 0 (Wave equation) is hyperbolic (9.4)
ut = uxx (heat conduction equation) is parabolic (9.5)
In the study of partial differential equations, usually three types of problems
arise:
(i) Dirichlets Problem Given a continuous function f on the boundary
C of a region R, it is required to find a function u(x, y), satisfying the
Laplace equation in R, i.e., to find u(x, y) such that
u xx + u yy = 0 in R, ⎫⎪
⎬ (9.6)
and u = f on C. ⎪⎭
(ii) Cauchys Problem.
utt u xx 0 for t 0
1442443
u ( x, 0) f ( x)
(9.7)
vu ( x, 0)
and g ( x)
vt
where f (x) and g(x) are arbitrary.
(iii)
ut u xx for t 0»¯
¼ (9.8)
and u ( x, 0) f ( x) ¯½
In partial differential equations, the form of the equation is always associated
with a particular type of boundary conditions. In this case, the problem is
said to be well-defined (or well-posed). The problems defined in Eqs. (9.6)
to (9.8) are well-posed. If, however, we associate Laplace equation with
Cauchy boundary conditions, the problem is said to be ill-posed. Thus, the
problem defined by
u xx u yy 0 »
¯¯
u ( x, 0) f ( x)¼
¯ (9.9)
and u y ( x, 0) g ( x) ¯½
is an ill-posed problem.
344 CHAPTER 9: Numerical Solution of Partial Differential Equations
S (x, y + 'y)
R (x + 'x, y + 'y)
P (x, y) Q (x + 'x, y)
O
X
Figure 9.1 xy-plane coincides with a rectangular face PQRS.
In the same way, we obtain the gain of heat from the faces PQ and SR in
time Dt as
¦ vu © vu ¸ µ
© ¸
kB 'x § ª ¹
ª ¹ ¶ 't
§ « vx º y 'y « vy º y ¶
¨ ·
SECTION 9.2: Laplaces Equation 345
¦ © vu ¸ © vu ¸ © vu ¸ © vu ¸ µ
ª ¹ ª ¹ ¶
§ ª
vx ¹ ª vx ¹
« vy º y 'y « vy º y¶
kB ' x ' y § « º x 'x « ºx
't
§ 'x 'y ¶
§ ¶
§ ¶
¨ ·
¦ © vu ¸ © vu ¸ © vu ¸ © vu ¸ µ
ª ¹ ª ¹ ¶
§ ª ¹ ª ¹
§ «
vx º x 'x « vx º x « vy º y 'y « v y º y¶
SB s 'x 'y 'u kB 'x 'y 't (9.11)
§ 'x 'y ¶
§ ¶
§ ¶
¨ ·
vu k ¦ v2u 2
v uµ
§ 2
vt Ss 2¶
¨ vx vy ·
¦ v 2u v
2 µ
u
a2 § 2
2¶
, (9.12)
¨ vx vy ·
k
where a
2
. Equation (9.12) gives the temperature distribution in the
Ss
plate in the transient state. When the temperature u(x, t) is constant, i.e., at
∂u
the steadystate condition, = 0 and Eq. (9.12) reduces to Laplaces equation
∂t
(9.10).
Using the method of separation of variables, it can be shown that
Eq. (9.10) possesses the solutions
The proper form of solution has to be chosen depending upon the physical
conditions of the problem.
346 CHAPTER 9: Numerical Solution of Partial Differential Equations
ui +1, j − ui, j
ux = + O ( h) (9.15)
h
ui , j − ui −1, j
= + O ( h) (9.16)
h
ui +1, j − ui −1, j
= + O (h2 ) (9.17)
2h
and
ui −1, j − 2ui, j + ui +1, j
u xx = 2
+ O (h2 ) (9.18)
h
where
ui, j = u (ih, jk ) = u ( x, y )
ui, j +1 − ui , j
uy = + O (k ) (9.19)
k
ui, j − ui , j −1
= + O (k ) (9.20)
k
ui, j +1 − ui , j −1
= + O (k 2 ) (9.21)
2k
and
ui , j −1 − 2ui , j + ui , j +1
u yy = + O (k 2 ) (9.22)
k2
We can now obtain the finite-difference analogues of partial differential
equations by replacing the derivatives in any equation by their corresponding
difference approximations given above. Thus, the Laplace equation in two
dimensions, namely
SECTION 9.3: Finite-Difference Approximations to Derivatives 347
u xx + u yy = 0
has its finite-difference analogue
1 1
(u
2 i +1, j
− 2ui, j + ui −1, j ) + 2 (ui, j +1 − 2ui , j + ui, j −1 ) = 0. (9.23)
h k
If h = k , this gives
1
ui , j =
(ui +1, j + ui −1, j + ui , j +1 + ui , j −1 ), (9.24)
4
which shows that the value of u at any point is the mean of its values at
the four neighbouring points. This is called the standard five-point formula
[see Fig. 9.2(a)], and is written
ui +1, j + ui −1, j + ui, j +1 + ui, j −1 − 4ui, j = 0 (9.25)
By expanding the terms on the right side of Eq. (9.24) by Taylors series,
it can be shown that
1
ui +1, j + ui −1, j + ui, j +1 + ui, j −1 − 4ui , j = h2 (u xx + u yy ) − h 4u xxyy + O ( h6 )
6
1 (9.26)
= − h4u xxyy + O ( h6 )
6
Instead of formula given in Eq. (9.24), we may also use the formula
1
ui , j = (ui −1, j −1 + ui +1, j −1 + ui +1, j +1 + ui −1, j +1 ) (9.27)
4
which uses the function values at the diagonal points [see Fig. 9.2(b)], and
is therefore called the diagonal five-point formula. This is perfectly valid
since it is well-known that the Laplace equation remains invariant when the
coordinate axes are rotated through 45°. Expanding the terms on the right
side of Eq. (9.27) by Taylors series, it can be shown that
2
ui −1, j −1 + ui +1, j −1 + ui +1, j +1 + ui −1, j +1 − 4ui, j = h4 u xxyy + O (h6 ) (9.28)
3
ui –1, j u i, j ui +1, j u i, j
(a) (b)
Figure 9.2 Approximations to Laplace’s equation.
348 CHAPTER 9: Numerical Solution of Partial Differential Equations
Neglecting terms of the order h6, it follows from Eqs. (9.26) and (9.28) that
the error in the diagonal formula is four times that in the standard formula.
Hence, in all computations we should prefer to use the standard five-point
formula, whenever possible.
Eliminating the term containing h4 from both Eqs. (9.26) and (9.28), we
obtain the nine-point formula
ui −1, j −1 + ui +1, j −1 + ui +1, j +1 + ui −1, j +1
It is clear that the error in this formula is of order h6. In a similar manner,
the finite-difference analogues of Eqs. (9.4) and (9.5) can be obtained.
In this chapter, we consider those partial differential equations which
can be replaced by the finite-difference analogues. These analogues, or
difference equations, are then used as approximations to the concerned
partial differential equations. Our general procedure is, therefore, to replace
the partial differential equation by a finite-difference analogue and then
obtain the solution at the mesh points. In the next section, we will discuss
Laplaces equation which is generally solved by reduction to a system of
algebraic equations. In Section 9.4, we will discuss methods for the numerical
solution of the parabolic Eq. (9.5). Hyperbolic equations are considered in
Section 9.8.
u7 u8 u9
c 14 c8
u4 u5 u6
c15 c7
u1 u2 u3
c16 c6
c5
c1 c2 c3 c4
1 ( n)
u i(,nj+1) = [u i −1, j + u i(+n1,) j + u i(,nj)−1 + u i(,nj)+1 ] (9.31)
4
for the interior mesh points. This is called the point Jacobi method.
ui(,nj1) ui(,nj)
F ij t 100% (9.34)
uij( n 1)
It was shown by B.A. Carré that for w = 1.875, the rate of convergence
of Eq. (9.33) is twice as fast as that when w = 1, and for w = 1.9, the rate
of convergence is 40 times greater than that when w = 1. In general, however,
it is difficult to estimate the best value of w. The following examples illustrate
the methods of solution.
Example 9.1 Solve Laplaces equation for the square region shown in
Fig. 9.4, the boundary values being as indicated.
Y
1 2 B
C
u3 u4
1 4
R S
P Q
2 5
u1 u2
X
0 4 5 A
Figure 9.4
SECTION 9.4: Solution of Laplaces Equation 351
It is seen from the figure that the boundary values are symmetric about
the diagonal AC. Hence, u1 = u4 and we need find only u1, u2 and u3. The
standard five-point formula applied at the point P gives
u2 + u3 + 2 + 4 − 4u1 = 0.
Hence we have
1
u1 =(u2 + u3 + 6).
4
The iteration formula is therefore
1 ⎡ (n)
u 1( n +1) = u + u 3( n ) + 6 ⎤ .
4⎣ 2 ⎦
Similarly, the iteration formulae at the points Q and R are given by
1 ( n +1) 5
u 2( n +1) = u + ,
2 1 2
and
1 ( n +1) 1
u 3( n +1) =
u + .
2 1 2
For the first iteration, let u2 = 5 (since it is nearer to the value u = 5), and
u 3(0) = 1. Hence
1
u 1(1) = (5 + 1 + 6) = 3,
4
1 5
u 2(1) = (3) + = 4,
2 2
1 1
u 3(1) = (3) + = 2.
2 2
For the second iteration, we have
1
u 1(2) = (4 + 2 + 6) = 3,
4
1 5
u 2(2) = (3) + = 4,
2 2
and
1 1
u 3(2) =
(3) + = 2.
2 2
Since the values are unchanged, we conclude that u1 = 3, u2 = 4, u3 = 2 and
u4 = 3.
1 1
0 u4 0
u3
0 0
u1 u2
0 0
Figure 9.5
(a) To start Jacobis iteration process, we obtain the approximate values
of u1, u2, u3 and u4 as follows:
1
u 1(1) = (0 + 0 + 0 + 1) = 0.25;
4
1
u 2(1) = (0 + 0 + 0 + 1) = 0.25;
4
1
u 3(1) =
(1 + 1 + 0 + 0) = 0.5;
4
1
u 4(1) = (1 + 1 + 0 + 0) = 0.5.
4
The iterations have been continued using Eq. (9.31), and seven successive
iterates are given below:
u1 u2 u3 u4
(c) SOR method: With w = 1.1, three successive iterates obtained by using
Eq. (9.33) are given below.
u1 u2 u3 u4
Example 9.3 Solve Laplaces equation for Fig. 9.6 given below:
0 u7 u8 u9 0
0 0
u4 u5 u6
0 0
u1 u2 u3
0 0 0 0 0
Figure 9.6
We first compute the quantities u5, u7, u9, u1 and u3 by using the diagonal
five-point formula given in Eq. (9.27). Thus, we obtain
u 5(1) = 25.00; u 7(1) = 42.75; u 9(1) = 43.75;
C D
2
u3 u4
u =0 u=0
u1 u2
1
A B
X
0 1 2 3
Figure 9.7
Let the values of u at the four grid points, A, B, C, D be u1, u2, u3, u4,
respectively. Let the grid points be defined by x = ih, y = jh, where h = 1,
i, j = 0, 1, 2, 3. At the point A, i = 1, j = 1. The standard five-point formula
applied at the point A gives
u2 + u3 + 0 + 0 − 4u1 = −10 (1 + 1 + 10)
i.e.,
1
u1 (u2 u3 120) (i)
4
Again, the standard five-point formula applied at the point B gives
u1 + u4 + 0 + 0 − 4u2 = −10 (4 + 1 + 10)
i.e.,
1
u2 = (u1 + u4 + 150) (ii)
4
Similarly, the standard five-point formula applied at the points C and D gives,
respectively
1
u3 = (u1 + u4 + 150) (iii)
4
and
1
u4 = (u2 + u3 + 180) (iv)
4
SECTION 9.4: Solution of Laplaces Equation 355
From (ii) and (iii), it is seen that u2 = u3 and so we need to find only u1, u2
and u4 from (i), (ii) and (iv). The iteration formulae are therefore given by
1
u 1( n +1) = u 2( n ) + 30
2
1 ⎡ ( n+1)
u 2( n +1) = u1 + u 4( n) + 150 ⎤
4 ⎣ ⎦
1 ( n +1)
u 4( n +1) =
u + 45.
2 2
(0) (0)
For the first iteration, we assume that u 2 = u 4 = 0. Hence we obtain
u 1(1) = 30,
1
u 2(1) = (30 + 0 + 150) = 45
4
1
u 4(1) =
(45) + 45 = 67.5.
2
For the second iteration, we have
1 1
u 1(2) u 2(1) 30 (45) 30 52.5
2 2
1 © (2) 1
u 2(2) u 1 u 4(1) 150¸ [52.5 67.5 150] 67.5
4 « º 4
1 © (2) ¸
u 4(2) u 45 78.75.
2« 2 º
For the third iteration, we obtain
1 1
u 1(3) = u 2(2) + 30 = (67.5) + 30 = 63.75
2 2
1 ⎡ (3) 1
u 2(3) = u 1 + u 4(2) + 150 ⎤ = [63.75 + 78.75 + 150] = 73.125.
4 ⎣ ⎦ 4
1 (3) 1
u 4(3) = u + 45 = (73.125) + 45 = 81.5625.
2 2 2
The fourth iteration gives
1 1
u 1(4) = u 2(3) + 30 = (73.125) + 30 = 66.5625
2 2
1 ⎡ (4) 1
u 2(4) = u + u 4(3) + 150 ⎤ = [66.5625 + 81.5625 + 150] = 74.53125
4⎣ 1 ⎦ 4
1 (4) 1
u 4(4) = u 2 + 45 = (74.53125) + 45 = 82.2656.
2 2
356 CHAPTER 9: Numerical Solution of Partial Differential Equations
0 u u2,2 u3,2
0,2 u1,2 0
0
u0,1 u3,1
u1,1 u2,1 0
0 0 u3,0
u 0,0 u 1,0 u 2,0
Figure 9.8
To apply formulae given in Eqs. (9.41) and (9.42), we relabel the internal
mesh points, as in Fig. 9.8.
To start the iterations, we set r = 0. For the first row, j = 1. Then,
Eq. (9.41) gives
For computing the function values on the second row, we set j = 2 in (9.41)
to obtain
u i(1) (1) (1) (0) (0) (ii)
−1, 2 − 4u i , 2 + u i +1, 2 = −u i , 1 − u i , 3
Substituting the boundary values and solving the above equations, we obtain
8 17
u 1,(2)1 =
= 0.1778 and u 1,(2)2 = = 0.3778
45 45
To compute the values on the second column, we now set i = 2 in Eq. (9.42)
(2) (2) (2) (1) (1)
u 2, j −1 − 4u 2, j + u 2, j +1 = −u 1, j − u 3, j (iv)
Substituting the boundary values in the above two equations and solving
them, we obtain
(2) (2)
u 2, 1 = 0.1778 and u 2, 2 = 0.3778
360 CHAPTER 9: Numerical Solution of Partial Differential Equations
The iterations are continued to improve the function values obtained first on
the rows, then on the columns, and so on. The reader is advised to continue
these computations for the next iteration.
¼ (9.46)
u ( x, t ) e p B t (c2 e px c3e px )
2 2
¯½
From Eq. (9.46), the appropriate form of solution should be chosen depending
upon the boundary conditions given. It is clear that to solve Eq. (9.44), we
need one initial condition and two boundary conditions. In the sequel, we
shall discuss the finite difference and cubic spline approximations to this
equation.
∂u uik +1 − uik
≈ (9.47)
∂t l
SECTION 9.5: Heat Equation in One Dimension 361
and
v2u 1
2
{ uk
2 i 1
2uik uik1
(9.48)
h vx
Equation (9.44) is replaced by the finite difference analogue
uik 1 uik u k 2uik uik1
B 2 i 1 ,
l h2
which simplifies to
uik 1 M uik1 uik1 (1 2M ) uik , (9.49)
where
α 2l
λ= (9.50)
h2
In Eq. (9.49), uik +1 is expressed explicitly in terms of uik−1 , uik+1 and uik .
Hence it is called the explicit formula for the solution of one-dimensional
1
heat equation. It can be shown that Eq. (9.49) is valid only for 0 £ÿl £ ,
2
which is called the stability condition for the explicit formula.
1
If we set l = in Eq. (9.49), we obtain the simple formula
2
1
uik 1 uik1 uik1
(9.51)
2
which is called BenderSchmidt recurrence formula. It is clear that
Eqs. (9.49) and (9.51) have limited application because of the restriction on
the values of l. A formula which does not have any restriction on l is that
∂ 2u
due to Crank and Nicolson. In Eq. (9.44), if we replace by the average
∂x 2
of its finite difference approximations on the kth and (k +1)th time levels,
we obtain
v2u 1
2
k
ui 1 2uik uik1 uik11 2uik 1 uik11
vx 2h 2
Hence, Eq. (9.44) is approximated by
uik 1 uik B2
2 uik1 2uik uik1 uik11 2uik 1 uik11
l 2h
which simplifies to
Muik11 (2 2M )uik 1 Muik11 Muik1 (2 2M )uik Muik1 (9.52)
On the left side of Eq. (9.52) we have three unknowns and on the right side,
all are known quantities. This is called CrankNicolson formula for the one-
dimensional heat equation and it is an implicit formula.
362 CHAPTER 9: Numerical Solution of Partial Differential Equations
Example 9.6 Use the BenderSchmidt formula to solve the heat conduction
problem
∂u 1 ∂ 2u
=
∂t 2 ∂x 2
with the conditions u(x, 0) = 4x x2 and u(0, t) = u(4, t) = 0.
1
Setting h = 1, we see that l = 1 when l = .
2
Now, the initial values are
u(0, 0) = 0, u(1, 0) = 3,
u(2, 0) = 4, u(3, 0) = 3
and u(4, 0) = 0.
Further, u(0, t) = u(4, t) = 0.
For l = 1, BenderSchmidt formula gives
1
u11 (0 4) 2,
2
1
u12 (3 3) 3,
2
1
u13 = (4 + 0) = 2.
2
Similarly, for l = 2, we obtain
1
u12 (0 3) 1.5,
2
1
u22 (2 2) 2,
2
1
u32 (3 0) 1.5.
2
Continuing in this way, we obtain
By symmetry, we have
u11 = u14 and u12 = u31
Solving the above system, we obtain
u12 u13 0.6460
Hence, u(0.6, 0.04) » 0.6460, the error in which is 0.0052.
∂u ∂ 2u
=
∂t ∂x 2
subject to the conditions
u(x, 0) = 0, u(0, t) = 0 and u(1, t) = t.
¦ 1 1µ
Using CrankNicolson scheme, find the value of u § , ¶ taking
¨ 2 8·
1 1 1 1
successively (i) h = , l = , (ii) h = , l = . Compare the results
2 8 4 8
1 1
obtained with the exact value of u ¦§ , µ¶ = 0.01878.
¨ 2 8·
1 1 1
(i) h = , l = . Then λ = .
2 8 2
CrankNicolson scheme gives
1 1
u11 , since u10 0 and u12 .
48 8
0.02083 (error 0.00205).
(ii) h = 1 , l = 1 . Then M = 2.
4 8
Therefore, CrankNicolson scheme gives
With k = 0, we obtain
–3u11 − u12 = 0
u11 − 3u12 + u31 = 0
1
u12 − 3u13 = – .
8
Solving the above system, we obtain
⎛1 1⎞ 1
u12 = u ⎜ , ⎟ ≈ = 0.01786 (error = 0.00092).
⎝ 2 8 ⎠ 56
The iterative methods discussed in Section 9.4 can be applied to solve the
finite-difference equations obtained in the preceding section. In the Crank
Nicolson method, the partial differential equation
∂u ∂ 2u
=
∂t ∂x 2
is replaced by the finite-difference equation
1
(1 + r ) ui , j +1 = ui , j + r (ui −1, j +1 + ui +1, j + ui +1, j +1 + ui −1, j − 2ui , j ) (9.53)
2
where r = k /h2.
In Eq. (9.53), the unknowns are ui, j +1 , ui −1, j +1 and ui +1, j +1 , and all others
are known since they were already computed at the jth step. Hence, dropping
the js and setting
1
ci = ui, j + r (ui −1, j − 2ui, j + ui +1, j )
2 (9.54)
Eq. (9.53) can be written as
r c
ui = (ui −1 + ui +1 ) + i (9.55)
2 (1 + r ) 1+ r
r c
u i( n +1) = [u i(−n1) + u i(+n1) ] + i , (9.56)
2 (1 + r ) 1+ r
which expresses the (n + 1) th iterate in terms of the nth iterates only, and is
known as Jacobis iteration formula.
366 CHAPTER 9: Numerical Solution of Partial Differential Equations
It can be seen from Eq. (9.56) that at the time of computing u i( n +1) , the
latest value of ui −1 , namely u i(−n1+1) , is already available. Hence, the convergence
of Jacobis iteration formula can be improved by replacing u i(−n1) in formula
given in Eq. (9.56) by its latest value available, namely by u i(−n1+1). Accordingly,
we obtain the formula
r c
u i( n +1) = [u i(−n1+1) + u i(+n1) ] + i (9.57)
2 (1 + r ) 1+ r
which is called the GaussSeidel iteration formula. It can be shown that
Eq. (9.57) converges for all finite values of r and that it converges twice as
fast as Jacobis scheme.
Equation (9.57) can be rewritten as
⎧ r c ⎫
u i( n +1) = u i( n) + ⎨ [u i(−n1+1) + u i(+n1) ] + i − u i( n) ⎬
⎩ 2 (1 + r ) 1+ r ⎭
from which it is clear that the expression within the curly brackets is the
difference between the nth and (n + 1)th iterates. If we take the difference
to be ω times this expression, we then obtain
⎧ r c ⎫
u i( n +1) = u i( n ) + X ⎨ [u i(−n1+1) + u i(+n1) ] + i − u i( n ) ⎬ (9.58)
⎩ 2 (1 + r ) 1+ r ⎭
which is called the successive over-relaxation (or SOR) method. ω is called
the relaxation factor and it lies, generally, between 1 and 2.
Example 9.9 Solve
∂u ∂ 2u
=
∂t ∂x 2
subject to the initial condition u = sin π x at t = 0 for 0 ≤ x ≤ 1 and u = 0 at
x = 0 and x = 1 for t > 0, by the GaussSeidel method.
We choose h = 0.2 and k = 0.02 so that r = k /h2 = 1/2. Equation (9.57)
therefore becomes
1 ( n +1) 2
u i( n +1) = [u + u i(+n1) ] + ci (i)
6 i −1 3
Let the values of u at the interior mesh points on the row corresponding to
t = 0.02 be u1 , u2 , u3 , u4 , as shown in Fig. 9.9.
Applying formula given in Eq. (i) at the four interior mesh points, we
obtain successively
1 2 ⎡ 1 ⎤
u 1( n+1) = [0 + u 2( n) ] + ⎢0.5878 + 4 (0 − 2 × 0.5878 + 0.9511) ⎥
6 3 ⎣ ⎦
1 (ii)
= u 2( n) + 0.3544
6
SECTION 9.6: Iterative Methods for the Solution of Equations 367
u=0 u=0
u1 u2 u3 u4
k = 0.02
x
0 0.2 0.4 0.6 0.8 1.0
u
0.0 0.5878 0.9511 0.5878 0.9511 0.0
Figure 9.9
1 ( n+1) 2 ⎡ 1 ⎤
u 2( n+1) = [u + u 3( n) ] + ⎢0.9511 + 4 (0.5878 − 2 × 0.9511 + 0.9511) ⎥
6 1 3 ⎣ ⎦
1 ( n+1)
= [u + u 3( n) ] + 0.5736 (iii)
6 1
1 ( n+1) 2 ⎡ 1 ⎤
u 3( n+1) = [u 2 + u 4( n) ] + ⎢0.9511 + 4 (0.9511 − 2 × 0.9511 + 0.5878) ⎥
6 3 ⎣ ⎦
1 ( n+1)
= [u + u 4( n) ] + 0.5736 (iv)
6 2
1 ( n+1) 2 ⎡ 1 ⎤
u 4( n+1) = [u 3 + 0] + ⎢0.5878 + 4 (0.9511 − 2 × 0.5878 + 0.0) ⎥
6 3 ⎣ ⎦
1 ( n +1)
= u + 0.3544 (v)
6 3
Equations (ii), (iii), (iv) and (v) can now be used to obtain better approximations
for u1, u2, u3 and u4, respectively. The table below gives the successive
iterates of u1, u2, u3 and u4 corresponding to t = 0.02.
x 0.0 0.2 0.4 0.6 0.8 1.0
u(x ) 0.0 0.5878 0.9511 0.9511 0.5878 0.0
n=0 0.0 0.5878 0.9511 0.9511 0.5878 0.0
n=1 0.0 0.5129 0.8176 0.8078 0.4890 0.0
n=2 0.0 0.4907 0.7900 0.7868 0.4855 0.0
n=3 0.0 0.4861 0.7858 0.7855 0.4853 0.0
n=4 0.0 0.4854 0.7854 0.7854 0.4853 0.0
n=5 0.0 0.4853 0.7854 0.7854 0.4853 0.0
368 CHAPTER 9: Numerical Solution of Partial Differential Equations
The symmetry of the solution about x = 0.5 is quite clear in the above table.
2
The analytical solution of the problem is given by u = e−π t sin π x and the
exact values of u for x = 0.2 and x = 0.4 are respectively 0.4825 and 0.7807.
The percentage error in both the solutions is about 0.6%, and the error can
be reduced by taking a finer mesh. The reader should check some of the figures
given in the table.
(ii) Solve the system in Eq. (9.62) for k = 0 with u10 f1 (l ) and u1n = f 2 (l ) .
This gives the values of u11 , u12 , |, u .
1
n 1
u ( x, 0) f ( x), »
ut ( x, 0) G ( x) ¯¯
¼ (9.65)
u (0, t ) Z 1 (t ) ¯
u (1, t ) Z 2 (t )¯½
cl
Equations (9.70) and (9.71) hold good for all values of . The use of
h
formula given in Eq. (9.69) is demonstrated in the following examples.
Example 9.10 Solve the equation utt = uxx subject to the following conditions
u(0, t) = 0, u(1, t) = 0, t > 0
and
vu
( x, 0) 0, u ( x, 0) sin 3 (Q x), 0 c x c 1.
vt
This problem has an exact solution given by
3 1
u ( x, t ) = sin Q x cos Q t − sin 3Q x cos 3Q t.
4 4
Let h = 0.25 and l = 0.2. Then a = 0.8 < 1. The given conditions are
u0k 0, u4k 0, ui0 sin 3 (Q ih), i 1, 2, 3, 4.
Also,
vu ( x, 0)
0 À u1i ui1 0
vt
À ui1 u1i .
*A three level scheme for solving parabolic equations in one dimension may be
found in Sastry [1976].
SECTION 9.8: Wave Equation 371
Example 9.11 Solve the boundary value problem defined by utt = 4uxx
subject to the conditions.
u(0, t) = 0 = u(4, t), ut(x, 0) = 0, u(x, 0) = 4x x2.
Let
h = 1 and a = 1 so that l = 0.5.
We have
u0k = u4k = 0 for all k .
Since
ut(x, 0) = 0, we obtain ui−1 = ui1 .
Further,
u(x, 0) = 4x x2
Þ ui0 = 4i − i 2 , since h = 1.
Then,
Hence
1 0
u11 =
2
(
u0 + u20 = 2, ) u12 =
1
2
(3 + 3) = 3,
1
u13 = (4 + 0) = 2.
2
Similarly, we obtain
u12 = 0, u22 = 0, u32 = 0.
and the succeeding time rows can be built up.
EXERCISES
The function u(x, y) satisfies Laplaces equation at all points within the
squares given below and has the boundary values as indicated. Compute
a solution correct to two decimal places by the finite difference method
(Problems 9.19.6).
4 8 60 60
9.1 0 12 9.2 60 60
u3 u4
0 11 40 50
u1 u2
0 10 20 40
0 3 6 9 0 10 20 30
1 4
9.3 0 10 20 30 9.4 0 9
0 4
20 40
0 1
40 50
0 0 0 0
60 60 60 60
EXERCISES 373
9.5 10 20 20 20 10
10 10
10 10
10 10
10 20 20 20 10
9.6 40 30 20 10 0
30 10
20 20
10 30
0 10 20 30 40
9.7 Solve
∂ 2u ∂ 2u
+ =0
∂x 2 ∂y 2
for the temperature of the heated plate for the square region shown in
the figure below. Use successive over relaxation with w = 1.5 and
determine the temperatures at the internal mesh points upto the third
iteration. Give an estimate of the per cent error in the value of u22.
Y
80°C
4
3 u13 u23 u33
X
0 1 2 3 4
0°C
9.8 Solve Laplaces equation with h = 1/3 over the boundary of a square
of unit length with u(x, y) = 9x2y2 on the boundary.
374 CHAPTER 9: Numerical Solution of Partial Differential Equations
9.9 Write down the finite difference analogue of the equation uxx + uyy = 0 and
solve it for the square region given below.
1 1 4 9 16
u7 u8 u9
0 14
u4 u5 u6
0 12
u1 u2 u3
0 10
0 0.5 2 4.5 8
With h = k = 1.0, use the GaussSeidel method to compute, correct
two decimal places, values of u at the internal mesh points.
9.10 Solve Poissons equation
Ñ2u = 8x2y2
for the square grid shown below (h = 1).
u=0
u3 u4
u=0 u=0
u1 u2
u=0
9.11 Use the BenderSchmidt formula to solve the problem
ut = 5uxx,
u(0, t) = 0, u(5, t) = 60,
¬20 x, 0c xc3
and u(x, 0) =
® 60, 3 c xc5
With h = 1 and l = 0.5, compute the values of u(x, 0.5), u(x, 1.0) and
u(x, 1.5) for 1 £ x £ 4.
9.12 Solve the equation
∂u ∂ 2u
=
∂t ∂x 2
with the conditions
u(x, 0) = sin x, 0 £ x £ p
and u(0, t) = u(p, t) = 0, t > 0.
Compare the values obtained by BenderSchmidt, CrankNicolson and
⎛Q Q2 ⎞
Cubic Spline formulae for u ⎜ , .
⎜ 2 16 ⎟⎟
⎝ ⎠
EXERCISES 375
k k
1 2r 1 2r
l
where r = , is known as Du FortFrankel formula for the solution
h2
∂u ∂ 2u
of the one-dimensional heat equation = . It is a three level
∂t ∂x 2
376 CHAPTER 9: Numerical Solution of Partial Differential Equations
∂u ∂ 2u
is an approximation to the one-dimensional heat equation = .
∂t ∂x 2
Expanding both sides of this formula by Taylors series, we obtain
⎛ l 2 lh2 ⎞ ⎡ ∂ 2 u ⎤
( )
uik +1 − r uik−1 + uik+1 − (1 − 2r )uik = ⎜ −
⎜ 2 12 ⎟⎟ ⎢⎢ ∂t 2 ⎥⎥
+"
⎝ ⎠⎣ ⎦ i ,k
In such a case, we say that the local order of accuracy of the explicit
formula is O(l + h2). This is also called the local truncation error of
the formula. Show that the local truncation error of the CrankNicolson
formula is O(l2 + h2).
9.19 Show that the local truncation error of formula given in Eq. (9.69) is
given by
k 2 h2 2 v 4u k 2 h 4 4 v 6u
B 1
B 1
"
12 vx 4 360 vx 6
9.20 Solve the equation
v2u v2u
vt 2 vx 2
with the conditions u(0, t) = u(1, t) = 0, u(x, 0) = sin p x, and
∂u
(x, 0) = 0. Taking h = 0.25 and l = 0.2, compute u(0.5, 0.4) in two
∂t
time steps and compare your result with the exact solution given by
u(x, t) = sin px cos p t.
EXERCISES 377
Answers to Exercises
9.1 u1 = 3.33, u2 = 6.67, u3 = 3.67, u4 = 7.33.
9.2 u1 = 26.7, u2 = 33.3, u3 = 43.3, u4 = 46.7.
(2)
Second iteration values: Error in u22 65%
(3)
Third iteration: Error in u 22 13% .
9.8 See Problem 9.4.
9.11
60
1.5 17.5 35 45 55
60
1.0 20 35 50 55
t 60
0.5 20 40 50 60
20 40 60 60 60
0 1 2 3 4 5
x
378 CHAPTER 9: Numerical Solution of Partial Differential Equations
9.13 k i 0 1 2 3 4 5
0 0 24.0 84.0 144.0 144.0 0
1 0 42.0 78.0 78.0 57.0 0
2 0 39.0 60.0 67.5 39.0 0
Numerical Solution of
Integral Equations
10.1 INTRODUCTION
Any equation in which the unknown function appears under the integral sign
is known as an integral equation. Such equations arise in the formulation of
physical problems. A few examples are given below.
(a) Abels Integral Equation
x
f ( x ) ± K ( x, t ) G (t ) dt (10.1)
0
This equation arises in the problem of finding the path of a particle
which is constrained to move under gravity in a vertical plane. In Eq. (10.1),
f (t) is the unknown function, whereas, f (x) and K(x, t) are given functions.
(b) Loves Equation
1
y( x ) ± K ( x, s ) y( s) ds 1 (10.2)
1
This equation occurs in the problem of determining the capacity of a
circular plate condenser. In this case, the unknown function y(x) appears
both outside and inside the integral sign.
(c) Vandreys Equation
L
M
v( s ) G ( s ) ± K ( s, T )v(T ) dT , 0 c s c L (10.3)
Q
0
379
380 CHAPTER 10: Numerical Solution of Integral Equations
This equation occurs in fluid dynamics while calculating the pressure distribution
on the surface of a body of revolution moving in a fluid.
Integral equations are classified into two main types. Volterra integral
equations and Fredholm integral equations. Again, there are integral equations
of the first and second kinds. If the unknown function appears outside the
integral sign also, then it is called an integral equation of the second kind.
Equations (10.2) and (10.3) are Fredholm integral equations of the second
kind. On the other hand, Eq. (10.1), where the unknown function appears
only under the integral sign, is called Volterra integral equation of the first
kind.
If f (s) = 0 in Eq. (10.3), then the equation is said to be homogeneous;
otherwise it is non-homogeneous. For non-homogeneous equations, l is a
numerical parameter whereas for homogeneous equations, it is an eigenvalue
problem in which the objective is to determine those values of l, called the
eigenvalues, for which the integral equation possesses nontrival solutions
called eigenfunctions.
In Eq. (10.1), k(x, t) is called the kernel of the integral equation. If the
kernel is bounded and continuous, then the integral equation is said to be
nonsingular. If the range of integration is infinite, or if the kernel violates the
above conditions, then the integral equation is said to be singular.
A solution of the integral equation is a function which, when substituted
into the equation, reduces it to an identity.
∫
t = e(t −u ) y (u ) du
0
We have
t t
(t u )
±e y( u) du ± e ( t u ) (1 u) du
0 0
t
t
e t ± e u (1 u ) du e t © e u (1 u) ± e u ( 1)du ¸
« º0
0
t , on simplification.
Since integral equations occur in physical problems, it is usually difficult to
solve them analytically and hence it would be necessary to adopt a numerical
method of solution. Before presenting these methods, it would be instructive
to demonstrate the relationship between integral equations and initial value
problems. This is shown in the following examples.
SECTION 10.1: Introduction 381
x
or u ( x) = − x + ∫ (t − x) u(t ) dt ,
0
which is a Volterra integral equation.
In deriving Eq. (iii), we have used the formula
xx x x
1
± ± "± f ( x ) dx dx ! dx ( x t )n 1 f (t ) dt (iv)
( n 1)! ±
aa a n times a
b( x ) b( x )
d db da ∂
dx ∫ f ( x, t ) dt =
dx
f ( x, b) −
dx
f ( x, a ) + ∫ ∂x
f ( x, t ) dt. (ii)
a( x) a( x)
Using Eq. (ii) and differentiating both sides of Eq. (i), we obtain
x
y b( x ) 1 5 y( x ) ± 6 y(t ) dt
0
x
1 5 y( x ) 6 ± y(t ) dt (iii)
0
Therefore,
y¢(0) = 1, since y(0) = 0.
Differentiating Eq. (iii), we obtain
y¢¢(x) = 5y¢(x) 6y(x), on using Eq. (ii)
Hence we have
y¢¢(x) 5y¢(x) + 6y(x) = 0
which is the required differential equation satisfying the conditions y(0) = 0
and y¢(0) = 1.
There exist several methods for the numerical solution of Fredholm integral
equations of the second kind, e.g. method of degenerate kernels, method of
successive approximations, collocation and product-integration methods, etc.
We present a few of these methods, in a formal way, with simple examples.
For error estimates and other details, the reader is referred to Atkinson
[1967].
¥ u (x) v (t)
n
K ( x, t ) i i (10.5)
i 1
SECTION 10.2: Numerical Methods for Fredholm Equations 383
Setting
b
± vi (t ) f (t ) dt Ai (10.7)
a
Eq. (10.6) gives
¥ A u ( x ) G ( x)
n
f ( x) i i (10.8)
i 1
The constants Ai are still to be detemined, but substituting from Eq. (10.8)
in Eq. (10.7), we get
b ⎡ n ⎤
∫ vi (t ) ⎢ ∑
⎢⎣ j =1
A j u j (t ) + φ (t ) ⎥ dt = Ai
⎥⎦
a
or
¥ ± ± v (t) G (t) dt A ,
n b b
Aj vi (t ) u j (t ) dt i i (10.9)
a a
which represents a system of n equations in the n unknowns A1 , A2 ,…,
An . When the Ai are determined, Eq. (10.8) then gives f (x).
Although the method is important in the theory of integral equations, it
does not seem to be much useful in the numerical work, since the kernel is
unlikely to have the simple form (10.5) in practical problems. In general,
however, it is possible to take a partial sum of Taylors series for the kernel.
This is shown in Example 10.5.
∫ cos t f (t ) dt = A, (i)
0
± cos t (M A 1) sin t dt A,
0
which gives on simplification
1
A.
2M
Hence the solution of the integral equation is given by
2
f ( x) sin x (M y 2).
2M
By direct substitution the reader should verify that this is the solution of the
given integral equation.
Example 10.5 Solve the integral equation
1
1 2
f ( x) (e x 3x 1) ± (e xt 1) x f (t ) dt.
2
0
We have
2
K ( x, t ) = (e− xt − 1) x
⎛ x2t 4 ⎞
= ⎜1 − xt 2 + + " − 1⎟ x
⎜ 2 ⎟
⎝ ⎠
1 34
= − x 2t 2 +
x t ,
2
neglecting the other terms of the Taylors series.
Hence the given integral equation becomes
1
1 1 34
f ( x) = (e − x + 3 x − 1) + ∫ (− x t
2 2
+ x t ) f (t ) dt
2 2
0
1 1
1 1 3
= (e − x + 3 x − 1) − x 2 ∫ t 2 f (t ) dt + ∫t
4
x f (t ) dt
2 2
0 0
1 1
= (e − x + 3 x − 1) − k1 x 2 + k2 x3 , (i)
2 2
where
1
k1 ± t 2 f (t ) dt (ii)
0
SECTION 10.2: Numerical Methods for Fredholm Equations 385
and
1
k 2 ± t 4 f (t ) dt . (iii)
0
Substituting for f (t) from (i) in (ii), we obtain
1
2 ©1t 2 3 1 ¸
k1
± t ª« 2 (e 3t 1) k1t 2 k 2 t ¹º dt (iv)
0
Since
1
5
∫te
2 −t
dt = 2 − ,
e
0
Equation (iv) gives
6 k1 k2 5 29
. (v)
5 12 2e 24
Similarly, substituting for f (t) in (iii) and simplifying, we obtain
k1 15 65 243
k2 . (vi)
7 16 2e 20
Solution of (v) and (vi) is given by
k1 0.2522 and k 2 0.1685.
Hence the solution of the given integral equation is
1 1
f ( x) (e x 3x 1) 0.2522 x 2 (0.1685) x3 .
2 2
1
(2) ¦ 2µ ¦ 2µ
y ( x ) x ± xt t dt x x § ¶ x §1 ¶
¨ 3· ¨ 3·
1
1
¦ 2µ
y (3) ( x ) x ± xt t § 1 ¶ dt
¨ 3·
1
© 2¸
¦ 2µ 2 2 ¦ 2µ
x x §1 ¶ x ª1 § ¶ ¹.
¨ 3· 3 ª 3 ¨ 3· ¹
« º
SECTION 10.2: Numerical Methods for Fredholm Equations 387
1
© ¦ 2 4µ ¸
y (4) ( x ) x ± ª xt t § 1 ¶ ¹ dt
« ¨ 3 9· º
1
© 2 3¸
2 ¦ 2µ ¦ 2µ
x ª1 § ¶ § ¶ ¹
ª
«
3 ¨ 3· ¨ 3· ¹
º
Hence we obtain
⎡ ⎛ 2 ⎞ ⎛ 2 ⎞ 2 ⎛ 2 ⎞3 ⎤
y ( x) = x ⎢1 + ⎜ ⎟ + ⎜ ⎟ + ⎜ ⎟ + "⎥
⎢⎣ ⎝ 3 ⎠ ⎝ 3 ⎠ ⎝ 3⎠ ⎥⎦
= 3x.
It can be verified that y = 3x is the exact solution of the given integral
equation.
∫ F ( x) dx = ∑ Am F ( xm ), (10.16)
a m =1
¥ A K ( x, t ) f (t ) G (x),
n
f ( x) m m m (10.17)
m 1
|
where t1 , t2 , , tn are points in which the interval (a, b) is subdivided.
Further, Eq. (10.17) must hold for all values of x in the interval (a, b); in
|
particular, it must hold for x t1 , x t2 , , x tn . Hence we obtain
¥ A K (t , t ) f (t ) G (t ), |, n.
n
f (ti ) m i m m i i 1, 2, (10.18)
m 1
1© ¦ 1µ ¸ 3 5
f ( x) x f0 2§ x ¶ f1 ( x 1) f 2 ¹ x , where fi f ( xi ).
4 ª« ¨ 2· º 2 6
Setting x = ti , where t0 = 0, t1 = 1/2 and t2 =1, this gives the system of equations
12 f0 − 3 f1 − 3 f 2 = −10
−3 f0 + 12 f1 − 9 f 2 = −2
−3 f0 − 9 f1 + 6 f 2 = 8
The solution is
1 5 1
f0 = − , f1 = − , f2 = .
2 6 2
On the other hand, if we use Simpsons rule to approximate the integral
term in (i), we obtain
1© ¦ 1µ ¸ 3 5 (ii)
f ( x) x f0 4§ x ¶ f1 ( x 1) f 2 ¹ x
6 ª« ¨ 2· º 2 6
Setting x = ti, we get
6 f0 − 2 f1 − f 2 = −5
− f0 + 4 f1 − 3 f 2 = −1
− f0 − 6 f1 + 4 f 2 = 4.
The solution of which is
1
f 0 = −1, f1 = − , f 2 = 0.
2
SECTION 10.2: Numerical Methods for Fredholm Equations 389
1 ⎡ ⎛ 1 ⎞⎛ 1 ⎞ ⎤ 3 5
f ( x) = ⎢ − x + 4 ⎜ x + 2 ⎟⎜ − 2 ⎟ ⎥ + 2 x − 6
6 ⎣ ⎝ ⎠⎝ ⎠⎦
where
1 1 (ii)
K ( x, s )
Q 1 ( x s )2
occurs in an electrostatics problem considered by Love [1949], and is called
Loves equation. The analytical method of solution, suggested by Love, is
somewhat laborious and various numerical methods were proposed. The
simplest is to approximate the inegral term in (i) by the trapezoidal rule. For
this we divide the interval (1, 1) into n smaller intervals of width h, the ith
point of subdivision being denoted by si, such that
si = −1 + ih, i = 0, 1, 2, …, n
and nh = 2. Denoting y(xi) by yi, Eq. (i) gives
n −1 s j +1
yi + ∑ ∫ K ( xi , s) y ( s ) ds = 1.
j =0 sj
Approximating the integral term by the trapezoidal rule, the above equation
becomes
n −1
h
yi + ∑ 2⎣
⎡ K ( xi , s j ) y ( s j ) + K ( xi , s j +1 ) y (s j +1 ) ⎤ = 1,
⎦
j =0
we write
N
y ( x) = ∑ arTr ( x) (10.20)
r =0
and
N
f ( x) = ∑ f r Tr ( x) (10.21)
r =0
Where Tr(x) is the Chebyshev polynomial of degree r. Substituting Eqs. (10.20)
and (10.21) in Eq. (10.19), and interchanging the order of integration and
summation in the integral term, we obtain
N N 1 N
∑ ar Tr ( x) + ∑ aj ∫ K ( x, s ) T j (s ) ds = ∑ f rTr ( x). (10.22)
r =0 j =0 −1 r =0
When the ar are known, Eq. (10.20) provides the solution as a Chebyshev
series. This method is due to Elliott [1963], but a variant of this method, due
to El-Gendi [1969], gives better accuracy and is described below.
We consider the numerical quadrature of the definite integral
1
I ± f ( x) dx, (10.25)
1
where f ( x) is defined and well-behaved in [1, 1]. We can write
¥
N
f ( x) bb
ar Tr ( x), (10.26)
r 0
where
¥ jQ µ rjQ
N
2 bb ¦
ar f § cos ¶ cos . (10.27)
N j 0 ¨ N · N
Substituting Eqs. (10.26) and (10.27) in Eq. (10.25) and simplifying using
the well-known relation (see Jain [1971]):
1
2
∫ T2 j ( x) dx =
1 − 4 j2
, (10.28)
−1
we can write
1 N
∫ f ( x) dx = ∑ pNs f s , (10.29)
−1 s=0
where for even N,
N/2
2 jπ s
∑ ′′ 1 − 4 j 2 cos
4 1 (10.30a)
pNs = , s = 1, 2, …, N − 1
N j =0
N
and
1 (10.30b)
pN ,0 = pN , N = 2
N −1
392 CHAPTER 10: Numerical Solution of Integral Equations
The integral term in Eq. (10.19) can also be approximated in the sameway
to obtain the system of equations
[ I A][ y ] [ f ], (10.31)
where
aij = pNj Kij (10.32)
⎛ iπ jπ ⎞
K ij = K ⎜ − cos , − cos ⎟, i, j = 0, 1, …, N . (10.33)
⎝ N N ⎠
⎛ iπ ⎞
yi = y ⎜ − cos ⎟, (10.34)
⎝ N ⎠
pNj being given by Eq. (10.30). The system (10.31) can now be solved to
obtain directly the values of y (see Sastry [1975]).
where
1 d
K ( x, s ) (ii)
Q d 2 ( x s)2
and d is a positive real number, occurs in the problem of determining the
capacity of a circular plate condenser and was considered by Love [1949].
He showed, by analytical methods, that there exists a unique, continuous,
real and even solution, and that it can be expressed as a convergent series
of the form
∞ 1
y ( x) = 1 + ∑ ( −1) n ∫ K n ( x, s ) ds, (iii)
n =1 −1
d ⎫
K1 ( x, s ) = ⎪
π [ d + ( x − s )2 ]
2
⎪⎪
⎬ (iv)
1
⎪
K n ( x, s ) = ∫ K n−1 ( x, t ) K1 (t , s ) dt. ⎪
−1 ⎪⎭
SECTION 10.2: Numerical Methods for Fredholm Equations 393
0.0 0.65740981
0.38268 0.67248912
0.70711 0.70866017
0.92388 0.74265684
1.0 0.75571801
( x j x)3 ( x x j 1)3
s( x) M j 1 Mj
6h 6h
¦ h2 µ ( x j x) ¦ h2 µ ( x x j 1)
§ y j 1 M j 1¶ § yj M j¶ (10.35)
¨ 6 · h ¨ 6 · h
where M j = s′′( x j ), y j = y ( x j ), and x j = x0 + jh, j = 0, 1, …, N . If we now
approximate the integral term in Eq. (10.19) by using Eq. (10.35), we
obtain
sj
¥ ± ( s j s)3 (s s j 1 )3
N ©
y( xi ) K ( x, ª
s) M j 1 Mj
j 1 s j 1 ª 6h 6h
«
¦ h2 µ ( s j s) ¦ h2 µ (s s j 1 ) ¸
§ y j 1 M j 1 ¶ § yj M j¶ ¹ ds
¨ 6 · h ¨ 6 · h ¹º
f ( xi ), i 0, 1, 2, |, N (10.36)
394 CHAPTER 10: Numerical Solution of Integral Equations
⎛ h2 ⎞ ⎛ h2 ⎞ ⎤
+ ⎜ y j −1 − M j −1 ⎟ (1 − p) + ⎜ y j − M j ⎟ p ⎥ dp
⎜ 6 ⎟ ⎜ 6 ⎟ ⎥
⎝ ⎠ ⎝ ⎠ ⎦
= f ( xi ), i = 0, 1, 2, …, N (10.37)
± K xi , s j 1 ph
p dp,
m
m = 0, 1, 2 and 3, (10.38)
0
h 2h h y j −1 − 2 y j + y j +1 ⎫
M j −1 + M j + M j +1 = ⎪
6 3 6 h ⎪
⎪
j = 1, 2, …, N − 1 ⎬ (10.39)
⎪
⎪
and M0 = M N = 0 ⎪
⎭
will form a set of (2N + 2) linear algebraic equations in (2N + 2) unknowns,
| |
viz., y0 , y1 , , y N , M 0 , M1 , , M N . As an example, we consider again Loves
equation given in the previous example.
Example 10.10 In contrast with the previous methods, the spline method
can be applied when the values of d are small. For this particular example,
the integrals in Eq. (10.38) were calculated analytically. Thus for m = 0, we
have
1 1
1 d
X0 = ∫ K ( xi , s j −1 + ph) dp =
π ∫ d + ( xi − s j −1 − ph)2
2
dp
0 0
1 ⎡ h/d ⎤
X0 = tan −1 ⎢ ⎥
hπ 2 2
⎢⎣1 + (h /d )(i − j ) (i − j + 1) ⎥⎦
SECTION 10.2: Numerical Methods for Fredholm Equations 395
d © d 2 h 2 (i j ) 2 ¸
ª log ¹ (i j 1) X 0
2Q h 2 ª« d 2 h 2 (i j 1)2 ¹º
1
X 2 ± K ( xi , s j 1 ph) p 2 dp
0
d©d2 ¸
2 ª 2
(i j 1)2 ¹ X 0 2 X1 (i j 1)
Q h «ª h º¹
1
X 3 ± K ( xi , s j 1 ph) p3 dp
0
d © d2 ¸
[5 4(i j )] ª3(i j 1)2 ¹ X1
2Q h 2
ª« h2 ¹º
©d2 ¸
2(i j 1) ª 2 (i j 1) 2 ¹ X 0
ª« h ¹º
The system of equations was solved by the GaussSeidel iteration method
and a standard subroutine was used for this. The results are summarized in
the following table for different values of d, and agree closely well with
those obtained by Phillips [1972]. It was found that the method is unsuitable
for finding the solution for larger values of d as the convergence is rather
slow. Thus for d = 1.0 the value obtained with 500 iterations for x = 1.0 is
0.80692 compared to the true value 0.75572. For more computational results,
see the paper by Sastry [1975].
These results show that the spline method for the numerical solution of
Fredholm integral equations is potentially useful. Its application to more
complicated problems will have to be examined together with an estimation
of error in the method.
b
f ( x) ± K ( x, t ) f (t ) dt G ( x), a c x c b. (10.40)
a
n 1 t j 1
f ( x) ¥ ±
j 0 tj
K ( x, t ) f (t ) dt G ( x). (10.41)
n 1 t j 1
f ( x)
1
¥ ±
h j 0
tj
K ( x, t ) [(t j 1 t ) f (t j ) (t t j ) f (t j 1 )] dt G ( x).
n −1 1
f ( x) + h ∑ ∫ [(1 − p) f (t j ) + pf (t j +1 )] K ( x, t j + ph) dp = φ ( x).
j =0 0
SECTION 10.3: Singular Kernels 397
where
1 »
Bij h ± (1 p) K ( xi , t j ph) dp ¯
¯
0 ¯ (10.44)
1
¼
¯
Cij h ± pK ( xi , t j ph) dp ¯
0 ¯½
and
fi f ( xi ) f (a ih )
Equation (10.43) represents a system of (n + 1) linear equations in (n + 1)
unknowns f (t0 ), f (t1 ), …, f (tn ), and can therefore be solved. We illustrate
the use of generalized quadrature with two numerical examples.
1 ⎡ h ⎤
= tan −1 ⎢ ⎥
hπ 2
⎢⎣1 + h (i − j )(i − j − 1) ⎥⎦
and
1
X 1(i, j ) = ∫ pK ( xi , t j + ph) dp
0
1
1 p dp
=
π ∫ 1 + h (i − j − p) 2
2
0
1 ⎡1 + h 2 (i − j − 1) 2 ⎤
= log ⎢ 2 ⎥
+ (i − j ) X 0 (i, j )
2h 2π 2
⎣⎢ 1 + h (i − j ) ⎦⎥
398 CHAPTER 10: Numerical Solution of Integral Equations
then
α ij = h [ X 0(i, j ) − X 1(i, j )] and Cij hX 1(i, j ).
With n = 4, we obtain from Eq. (10.43) the equations
where
1 ⎧ x′y − y ′( x − ξ ) ⎫
K ( s, σ ) = ⎨ K (k ) ⎪
( x − ξ ) + ( y + η) ⎩
2 2 y ⎪
⎪
⎪
⎡ x′y − y ′( x − ξ ) x′( y − η ) − y ′( x − ξ ) ⎤ ⎫⎪ ⎪ (ii)
− E (k ) ⎢ + 2η ⎥⎬ ⎬
⎢⎣ y ( x − ξ )2 + ( y − η )2 ⎥⎦ ⎪⎭ ⎪
⎪
⎪
4 yη dx ⎪
K2 = , x′ =
( x − ξ ) + ( y + η)
2 2 ds ⎪⎭
and K(k) and E(k) are complete elliptic integrals of the first and second
kinds respectively with modulus k. In (i), v(s) denotes the velocity distribution
function on the body surface from which the pressure distribution can be
found by Bernoullis equation. Details of the problem and its reduction to a
system of equations are given in the papers by Kershaw [1971] and Sastry
[1973, 1976], where further references may be found. Using the expansions
of K(k) and E(k) given in Dwight [1934], the kernel K ( s, T ) in (ii) can be
split into the form:
K ( s, σ ) = P (s, σ ) log s − σ + Q( s, σ ) (iii)
where
1 ¬ x by y b( x Y) 2 »
P ( s, T ) E (k1 ) ¯
( x Y) ( y I) ®
2 2 y Q ¯
¯
¯ (iv)
x b( y I) y b ( x Y) 2 »
¯ ¼
2I [ K (k1 ) E (k1 )]¼ ¯
( x Y)2 ( y I)2 Q ¯
½ ¯
¯
Q(s, T ) K (s, T ) P(s, T ) log s T ¯
½
and
( x − ξ )2 + ( y − η )2
k 12 = 1 − k 2 = .
( x − ξ )2 + ( y + η ) 2
When T s, it is found that
x′ ⎫
P( s, s ) = − ⎪
2y
⎪ (v)
⎬
1 ⎪⎧ ⎡ 1 1 ⎤ x′′y ′ − y ′′x′ ⎪⎫⎪
Q( s, s ) = ⎨ x′ ⎢ − log ( x′ + y ′ ) + log 4 y + log 4 −1⎥ − y 2
2 2 2
⎬
2 y ⎪⎩ ⎣ 2 2 ⎦ x′ + y ′2 ⎪⎭⎪⎭
400 CHAPTER 10: Numerical Solution of Integral Equations
For a numerical solution of this problem using Everetts formula, see Kershaw
[1961].
This is a method of recent origin, being mainly due to the efforts of Kalaba
and Ruspini [1969], and is applicable to Fredholm integral equations of the
second kind
a
y ( x) g ( x) ± K ( x, s ) y (s ) ds (10.45a)
0
where
∞
K ( x, s ) = ∫ f ( xz ) f ( sz ) w( z ) dz (10.45b)
0
In the method of invariant imbedding, Eq. (10.45) is first rewritten as a
Volterra integral equation in the form
t
y ( x, t ) g ( x) ± K ( x, s ) y ( s, t ) ds; 0 ≤ x ≤ t; 0 c t c a. (10.46)
0
the interested reader is referred to the original paper by Kalaba and Ruspini
[1969]. We, however, demonstrate its applicability to a practical situation.
»
dRik (t ) ©
¥
N
2 ¸
ª cos (tAk ) F W ( A ) cos (tA ) R (t ) ¹ ¯
2 m m m mk
¯
dt ª« m 1 (1 am ) ¹º
¯
¯
¼ (iii)
¥
© N
2 ¸
t ª cos (tAi ) 2
FmW ( Am ) cos (tAm ) Rim (t ) ¹ ¯
ª« m 1 (1 a m ) ¹º ¯
¯
Rik (0) 0 ¯
½
402 CHAPTER 10: Numerical Solution of Integral Equations
and
»
dei (t ) ©
¥
N
2 ¸
ª g (t ) FmW ( Am ) cos (tAm ) em ( t ) ¹ ¯
dt ª« m 1 (1 a m ) 2
¹º ¯
¯
¯
(iv)
¥
© N
2 ¸ ¼
t ª cos tAi 2
FmW ( Am ) cos (tAm ) Rim (t ) ¹ ¯
ª« m 1 (1 am ) ¹º ¯
¯
ei (0) 0, 1 c i c N, 0 c t c 1. ¯
½
where
ei (t ) e( Ai , t )
and finally,
N
2 Fm
y ( x, t ) = g ( x) + ∑ (1 + am )2
W ( Am ) cos xAm em (t ), 0 c x c t c 1. (v)
m =1
± ¥ F f (a )
1 N
f ( x) dx m m
1 m 1
The Eqs. (iii) and (iv) have been solved using the fourth-order RungeKutta
method, and the five-point Gaussian formula. The results are obtained on
a digital computer and are given in the following table for different values
of H:
H x y(x)
1.05 0.0 –1.7718
1.0 –1.7013
1.1 0.0 –1.7450
1.0 –1.6813
1.2 0.0 –1.6898
1.0 –1.6464
1.3 0.0 –1.6599
1.0 –1.6169
1.6667 0.0 –1.5618
1.0 –1.5397
EXERCISES 403
Although the method produces results which agree quite well with those
obtained by Srivastava and Palaiya, it suffers with the serious disadvantage
of being a complicated process and requiring an enormous amount of computing
time.
A central idea of the method is to take full advantage of the ability of
the modern highspeed digital computer to solve systems of ordinary differential
equations with given initial conditions, and it therefore finds important
applications in the numerical solution of integral equations occurring in radiative
transfer, optimal filtering and multiple scattering.
EXERCISES
Verify whether the functions given below are solutions of the integral equations
indicated against them (Problems 10.110.5):
1
∫
xt x
10.1 f (x) = 1: f ( x) + x(e − 1) f (t ) dt = e − x.
0
1
10.2 f (t) = et: f (t ) + λ ∫ sin (tx) f ( x) dx = 1.
0
x
10.3 f (x) = xex: f ( x) = e x sin x + 2 ∫ cos ( x − t ) f (t ) dt.
0
3
15 x − 2
10.4 f (x) = x: G ( x) =
18 ∫
+ ( x + t ) G (t ) dt.
1
1
3 5
∫
10.5 f (x) = x 1: f ( x) = ( x + t ) f (t ) dt +
2
x− .
6
0
Transform the following initial value problems into equivalent integral equations
(Problems 10.610.8):
10.6 y¢¢ + y = cos x, y(0) = 0, y¢(0) = 0.
2 2
10.7 x y¢¢ xy¢ + y = x , y(1) = 1, y¢(1) = 0.
10.8 y¢¢ = 1 xy, y(0) = y¢(0) = 0.
Solve the following integral equations with degenerate kernels
(Problems 10.910.12):
Q /4
10.9 f (x) l ± tan s f (s) ds = cot x.
Q /4
Q /2
10.10 f (x) l ∫ sin x cos t f (t) dt = sin x.
0
404 CHAPTER 10: Numerical Solution of Integral Equations
Q
10.11 f (x) l ± sin (x u) f (u) du = cos x.
0
2Q
10.12 f (x) = l ± sin (x + t) f (t) dt + x.
0
10.13 Solve the integral equations in Problems 10.4 and 10.5 by Simpsons
1/3-rule. In each case, divide the range into two equal subintervals
and approximate to the solution. Compare your results with the exact
solution.
Answers to Exercises
10.1 Satisfies
10.2 Does not satisfy
10.3 Satisfies
10.4 Satisfies
10.5 f (x) = x 1 satisfies the integral equation
x
10.6 ∫
y (x) = ( x – t ) y(t) dt cos x + 1
0
x
1 1
10.7 G( x) 1 ± t G (t ) dt
x2 x2 1
x
x2
10.8 y ( x) =
2 ∫
− ( x − t ) y (t ) dt
0
Q
10.9 f (x) = l + cot x
2
2 sin x
10.10 f ( x )
2M
2QM sin x 4cos x
10.11 f ( x) = +
4+Q M 2 2
4 + Q 2M 2
© Q sin x cos x ¸
10.12 f ( x ) 2QM ª 2 2 ¹ x, M 2Q 2 y 1.
ªM Q 1 M Q
2 2
« 1º
¹
1 1
10.13 (a) f0 = 0, f1 = , f2 = 1, (b) f0 = 1, f1 = , f2 = 0.
2 2
Chapter
11.1 INTRODUCTION
Nodal Line
Node
11.1.1 Functionals
The concept of a functional is required to understand the RayleighRitz
method, which will be discussed in the next section. This concept arises in
the study of variational principles, which occur widely in physical and other
problems. Mathematically, a variational principle consists in determining the
extreme value of the integral of a typical function, say f ( x, y, y ′). Here the
integrand is a function of the coordinates and their derivatives and the
SECTION 11.1: Introduction 407
The EulerLagrange equation (11.2) has several solutions and the one which
satisfies the given boundary conditions is selected. Thus, one determines the
functional so that it takes on an extremum value from a set of permissible
functions. This is the central problem of a variational principle. An important
point here is that an extremum may not exist. In other words, a variational
principle may exist, but an extremum may not exist. Furthermore, not all
differential equations have a variational principle. These difficulties are serious
and therefore impose limitations on the application of the variational principle
to the solution of engineering problems.
Many problems arising in physics and engineering are modelled by boundary-
value problems and initial boundary-value problems. Frequently, these equations
are equivalent to the problem of the minimization of a functional which can
be interpreted in terms of the total energy of the given system. In any
physical situation, therefore, the functional is obtained from a consideration
of the total energy explicitly. Mathematically, however, it would be useful to
be able to determine the functional from the governing differential equation
itself. This is illustrated below with an example.
Example 11.1 Find the functional for the boundary-value problem defined by
d2y
= f ( x) (i)
dx 2
and
y (a) = y (b) = 0. (ii)
We have
b b
E ± f y dx ± f E y dx
a a
b
d2y d2y
± E y dx, since f ( x)
a
dx 2 dx 2
b b
© dy ¸ dy d
ª E y¹ ± (E y ) dx, on integrating by parts
« dx º a a dx dx
b
dy d
± (E y ) dx, since E y (a) E y (b) 0
dx dx
a
b
dy ¦ dy µ d ¦ dy µ
± E § ¶ dx, since (E y ) E § ¶
dx ¨ dx · dx ¨ dx ·
a
b 2
1 ¦ dy µ
± E § ¶ dx
2 ¨ dx ·
a
b 2
1 ¦ dy µ
E ± § ¶ dx.
2 ¨ dx ·
a
Hence
b
⎡ 1 ⎛ dy ⎞ ⎤
2
δ ∫ ⎢ fy + ⎜ ⎟ ⎥ dx = 0.
⎢⎣ 2 ⎝ dx ⎠ ⎥⎦
a
It follows that a unique solution of the problem (i) to (ii) exists at a minimum
value of the integral defined by
b ⎡ 1 ⎛ dv ⎞ ⎤
2
I (v ) = ∫a ⎢ fv + ⎜ ⎟ ⎥ dx.
⎢⎣ 2 ⎝ dx ⎠ ⎥⎦
(iii)
SECTION 11.1: Introduction 409
∫
0 = – vy ′′ dx + vf dx ∫
a a
b b
= [– vy ′] + v′y ′ dx + vf dx
∫ ∫
b
a
a a
b
∫
= (v′y ′ + vf ) dx
a
Finally, substitute y = v in the above and multiply the bilinear terms by 1/2.
We then obtain the required functional
b
©1 2 ¸
I (v ) ± v
ª2 b
vf ¹ dx,
« º
a
which is the same as Eq. (iii) obtained earlier.
By definition, therefore, the integral in (iii) represents the required functional
of the problem. In a similar way, functionals of other boundary-value and initial
boundary-value problems can be derived.
It is outside the scope of this book to deal extensively with the determination
of functionals corresponding to boundary-value problems. We list below
some familiar boundary-value problems with their associated functionals and
these would be useful in understanding the problems discussed in this chapter.
d2y
(i) = f ( x), y (a ) = y (b) = 0 (11.5)
dx 2
b
I (v ) = ∫ v (2 f − v′′) dx. (11.6)
a
d2y ⎛ dy ⎞
(ii) + ky = x 2 , 0 < x < 1; y (0) = 0, ⎜ ⎟ = 1 (11.7)
2
dx ⎝ dx ⎠ x =1
1
1 ⎡⎛ dv ⎞2 ⎤
I (v ) =
2 ∫ ⎢⎜ ⎟ − kv 2 + 2vx 2 ⎥ dx − v(1).
⎢⎣⎝ dx ⎠ ⎥⎦
(11.8)
0
410 CHAPTER 11: The Finite Element Method
⎡ ∂u 2 ⎛ ∂u ⎞2 ⎤
⎢⎜⎛ ⎟⎞ + ⎜ ⎟ ⎥ dx dy.
1
I (v ) = ∫∫ 2 ⎢⎝ ∂x ⎠ ⎝ ∂y ⎠ ⎥
(11.12)
R ⎣ ⎦
⎧1 ⎡⎛ ∂u ⎞ 2 ⎛ ∂u ⎞ 2 ⎤ ⎫
⎪ ⎢⎜ ⎟ + ⎜ ⎟ ⎥ − uf ⎪⎬ dx dy.
I (v ) = ∫∫ ⎨
⎪⎩ 2 ⎢⎝ ∂x ⎠ ⎝ ∂y ⎠ ⎥ ⎪⎭
(11.14)
R ⎣ ⎦
d4y ⎫
(vi) EI + ky = f ( x), 0 < x < l ⎪
dx 4
⎪
⎬ (11.15)
2
d y ⎪
y = 0 = 2 at x = 0, l ⎪
dx ⎭
l ⎡ ⎛ d 2v ⎞
2 ⎤
1 ⎢ EI
∫ ⎜⎜ 2 ⎟⎟ + k v − 2vf ⎥ dx. (11.16)
2
I (v ) =
2 ⎢ ⎝ dx ⎠ ⎥
0 ⎣ ⎦
where
⎧⎪( x1 − x)/ h0 x0 ≤ x ≤ x1 ⎫
G0 ( x ) = ⎨ ⎪
⎪⎩0, x1 ≤ x ≤ xn ⎪
⎪
⎧( x − xi −1 )/ hi −1 , xi −1 ≤ x ≤ xi ⎪
⎪ ⎪⎪
Gi ( x) = ⎨( xi +1 − x)/ hi , xi ≤ x ≤ xi +1 ⎬ (11.19)
⎪ ⎪
⎩0, x ≥ xi +1 ⎪
⎪
⎧⎪0, x0 ≤ x ≤ xn −1 ⎪
Gn ( x) = ⎨ ⎪
⎩⎪( x − xn −1 )/ hn −1 xn −1 ≤ x ≤ xn ⎪⎭
From the definition of the functional we know that if y(x), the solution of
Eq. (11.20), is substituted in Eq. (11.21), then the integral I will be minimum.
Since we do not know the solution of Eq. (11.20), we try with an approximate
solution and determine the parameters of the approximation so that the
integral is minimum. This is the central idea of the RayleighRitz method.
Now, let
n
v( x) = ∑ B i Gi ( x ) (11.22)
i =1
∫
= − Gi′ ( x) G ′j ( x) dx, (vii)
0
using boundary conditions (iv).
Then Eq. (v) becomes
n n n
I (v) = −2 ∑ Bi pi − ∑ ∑ BiB j qij
i =1 i =1 j =1
Hence ∂I /∂B i = 0 gives
n
2 pi + 2 ∑ B j qij = 0, (i = 1, 2, …, n). (viii)
j =1
1
1
∫ (1 − 2 x
2
q11 = − ) dx = −
3
0
1
1
∫ (1 − 2 x) (2x − 3x
2
q12 = − ) dx = − = q21 , by symmetry
6
0
1
2
∫ (2 x − 3x
2 2
q22 = − ) dx = − .
15
0
∫ (vv′′ + v
2
I (v) = + 2vx) dx. (iv)
0
SECTION 11.2: Methods of Approximation 415
where
Gi (0) = Gi (1) = 0 for all i. (vi)
Substituting for v in (iv), we obtain
1 ⎡ n n n n n ⎤
I (v) = ∫ ∑ ⎢ BiGi ( x)
⎢⎣ i =1
∑
j =1
B jG ′′j ( x) + ∑
i =1
BiGi ( x) ∑
j =1
B j G j ( x) + 2 x ∑
i =1
BiGi ( x) ⎥ dx
⎥⎦
0
(vii)
As in the previous example, we let
1
pi = ∫ xGi ( x) dx (viii)
0
and
1 1
qij = ∫ Gi ( x) G ′′j ( x) dx = − ∫ Gi′( x) G ′j ( x) dx. (ix)
0 0
Further, let
1
rij = ∫ Gi ( x) G j ( x) dx. (x)
0
Equation (vii) now becomes
n n n n n
I (v) = ∑ ∑ BiB j qij + ∑ ∑ BiB j rij + 2 ∑ Bi pi (xi)
i =1 j =1 i =1 j =1 i =1
In this case, one of the boundary conditions is essential and the other
natural. Also, the exact solution of the problem is given by
x3 (iii)
y ( x) = − x.
6
The functional for this problem is given by
1
∫ (v′ (iv)
2
I (v ) = + 2vx) dx + v(1).
0
Let
v( x) = B1 x + B 2 x 2 (v)
∫ [(B1 + 2B 2 x) + 2 x (B1 x + B 2 x 2 )] dx + B1 + B 2
2
I (v ) = (vi)
0
Hence,
∂I
1 ⎫
=0= ∫ [2 (B1 + 2B 2 x) + 2 x 2 ] dx + 1
⎪
∂B1 ⎪
0 ⎪
⎬ (vii)
∂I
1
⎪
= 0 = [2 (B1 + 2B 2 x) 2 x + 2 x3 ] dx + 1. ⎪
∫
∂B 2 ⎪
0 ⎭
Simplification gives the two equations
B1 + B 2 = − 5 and B1 + 4 B 2 = − 3 , (viii)
6 3 4
whose solution is B1 = −13/12 and B 2 = 1/4.
The approximate solution is given by
13 1
y (1) = − x + x2 .
12 4
The student should compare this with the exact solution.
⎛ ∂2v ∂ 2v ⎞
I (v ) = ∫∫ v ⎜ 2k − 2 − 2 ⎟ dx dy,
⎜
⎝ ∂x ∂y ⎟⎠
(ii)
S
v ( x, y ) = B xy ( x − 1) ( y − 1) (iii)
be a first approximation to u. Clearly, v satisfies the boundary conditions,
i.e. v = 0 on the boundary C. The derivatives are given by
∂v ∂v ⎫
= B y ( y − 1) (2 x − 1); = B x ( x − 1) (2 y − 1); ⎪
∂x ∂ y ⎪
⎬ (iv)
2
2
∂ v ∂ v ⎪
= 2B y ( y − 1); = 2B x ( x − 1).
∂x 2 ∂y 2 ⎪
⎭
SECTION 11.4: Finite Element Method 419
d2y
= − f ( x), 0 < x <1 (11.27)
dx 2
with the boundary conditions
© dy ¸
y (0) = 0, 0 (11.28)
ª dx ¹
« º x 1
The basic steps involved in the finite element method are now elaborated and
explained (see Reddy [1985]):
Step 1 (Discretization of the region): In the present problem, the region
of interest is the x-axis from x = 0 to x = 1. Suppose that this is divided into
a set of subintervals, called elements, of unequal length, in general. The
intersection points are called nodes. Let these be given by x0 , x1 , x2 , …, xn −1 ,
xn , where x0 = 0 and xn = 1. The elements are numbered as À, Á, Â,
, n ,
a typical element being the eth element of length he from node e 1 to node e.
Let xe −1 and xe be the values of x at the nodes e 1 and e, and let y ( e−1) and
y(e) be the values of y at these nodes, respectively. In general, y(e) satisfies
the condition that outside e.
y (e ) ( x) = 0 for all elements e. (11.29)
(e)
For example, in Fig. 11.2 y ( x3 ) is nonzero whereas y (e )
( x4 ) = 0.
x3 x4
e–1 3 e 4
Figure 11.2 Typical eth element.
Using Eq. (11.29), it follows that the global approximate solution, y (x), can
be written as
which is written as
xe
⎡ d2y ⎤
0= ∫ ⎢v 2 + vf ⎥ dx
⎢⎣ dx ⎥⎦
xe −1
x xe xe
⎡ dy ⎤ e dy
= ⎢v ⎥
⎣ dx ⎦ xe −1
− ∫ v′
dx
dx + ∫ vf dx
xe −1 xe −1
xe
=− ∫ [v′y ′ − vf ] dx + v ( xe ) D 2(e) + v( xe −1 ) D 1( e) , (11.31)
xe −1
where
⎡ dy ⎤ and ⎡ dy ⎤ (11.32)
D1(e ) = ⎢ − ⎥ D 2( e) = ⎢ ⎥ .
⎣ dx ⎦ xe −1 ⎣ dx ⎦ xe
n ⎡ xe ⎤
∑B ( e)
j
⎢
⎢ ∫ G ′j ( x) Gi′( x) dx ⎥
⎥
j =1 ⎣ xe −1 ⎦
xe
= ∫ f Gi ( x) dx + Gi ( xe ) D 2(e) + Gi ( xe −1 ) D 1( e) , i = 1, 2, …, n. (11.34)
xe −1
where Kij and Fi are called the stiffness matrix and force vector respectively, and
are given by
xe
K ij ± Gib ( x) G bj ( x) dx
( e)
(11.36)
xe 1
SECTION 11.4: Finite Element Method 423
and
xe
F i( e ) = ∫ f Gi ( x) dx + Gi ( xe ) D 2(e) + Gi ( xe−1 ) D1(e). (11.37)
xe −1
y ( xe−1 ) = B1 + B 2 xe−1 = y 1( e) ⎫⎪
⎬ (11.39)
y ( xe ) = B1 + B 2 xe = y 2( e) . ⎪
⎭
Solving the equations given in Eq. (11.39), we obtain
y 1(e) xe − y 2( e) xe−1
B1 = (11.40)
xe − xe−1
and
y 2(e) − y 1(e)
B2 = . (11.41)
xe − xe −1
Equation (11.38) now becomes
y 1(e) xe − y 2( e) xe −1 y 2(e) − y 1( e)
y ( x) = + x
xe − xe−1 xe − xe−1
xe − x (e) x − xe −1 (e)
= y + y
xe − xe−1 1 xe − xe −1 2
(11.42)
2
= ∑ y i(e)G i(e) ( x)
i =1
where
xe − x x − xe−1
G 1( e) ( x) = and G 2( e) ( x) = . (11.43)
xe − xe−1 xe − xe−1
⎧⎪ 0, i ≠ j
G i(e) ( x j ) = ⎨ (11.44)
⎪⎩ 1, i = j.
424 CHAPTER 11: The Finite Element Method
d G 1(e)1 d G 1( e) 1
=− and =− (11.46)
dx he dx he
where
xe 2 ⎫
⎛ 1⎞ 1 ⎪
K11 = ∫
⎜ − ⎟ dx =
he ⎠ he ⎪
xe −1 ⎝ ⎪
⎪
xe
1 1 ⎪⎪
K12 = ∫ −
h e2
dx = −
he
= K 21 ⎬
⎪
(11.47)
xe −1
⎪
xe ⎪
1 1 ⎪
K 22 = ∫h2
dx =
he ⎪
⎪⎭
xe −1 e
and
xe
xe − x ⎫
F1( e) =2 ∫ he
dx + D1(e) = he + D1( e) ⎪
⎪
xe −1 ⎪
⎬ (11.48)
xe
x − xe −1 ⎪
F 2( e) = 2 ∫ dx + D 2( e) (e )
= he + D 2 . ⎪
he ⎪
xe −1 ⎭
As a particular case, we consider the following example.
Example 11.6 We consider the following problem defined by
d2y
= −2, 0 < x < 1, y (0) = 0, y ′(1) = 0. (i)
dx 2
The exact solution of the above problem is given by
y ( x) = 2 x − x 2 (ii)
© 2 2 ¸ ©1 (2) ¸
ª ¹ ª 2 D1 ¹
K (2) ª ¹, F (2) ª ¹.
ª ¹ ª 1 D (2) ¹
«ª 2 2º¹ «ª 2 2 ¹
º
Having determined the equations for each element, these have to be assembled
now to determine the global approximations. This will be the next step in the
finite element solution.
Step 4 (Assembly of element equations): We shall explain this step with
reference to the two elements obtained in Example 11.6. In this case, the
two elements are connected at the node 2. Since the function y (x) is continuous,
it follows that y2 of element 1 should be the same as y1 of element 2. For
the two elements of Example 11.6, the correspondence can be expressed
mathematically as follows:
y 1(1) = Y1 , y 2(1) = Y2 = y 1(2) , y (2)
2 = Y3 .
In the finite element analysis, such relations are usually called interelement
continuity conditions.
Using the above relations, the global finite element model of the given
boundary value problem is
(1)
© 2 2 0 ¸ © Y1 ¸ © 1/2 D 1 ¸
ª ¹ ª ¹ ª ¹
ª 2 22 2 ¹ ªY ¹ ª1 D (1) D (2) ¹ .
ª ¹ ª
2 2 2 ¹
ª ¹
ª ¹ ª ¹ ª ¹
« 0 2 2 º «Y3 º ª 1/2 D 2(2) ¹
« º
The next step is the imposition of boundary conditions.
Step 5 (Imposition of boundary conditions): The homogeneous boundary
condition gives Y1 = 0. Then, we obtain the equations:
1
4Y2 − 2Y3 = 1, −2Y2 + 2Y3 =
2
since D 2(1) and D 2(2) cancel each other and D 2(2) = 0 is the natural boundary
condition.
426 CHAPTER 11: The Finite Element Method
⎡ 4 −4 ⎤ ⎡1/4 + D (2) ⎤
=⎢ ⎥
1
K (2) = ⎢ , (2)
4 ⎥⎦
F
⎣ −4 ⎢1/4 + D (2) ⎥
⎣ 2 ⎦
(iii) e = 3 : xe −1 = 1/ 2, xe = 3/4
−4 ⎤ ⎡1/4 + D (3) ⎤
⎡ 4
=⎢ ⎥
(3) (3) 1
K =⎢ , F
⎣ −4 4 ⎥⎦ ⎢1/4 + D (3) ⎥
⎣ 2 ⎦
(iv) e = 4 : xe −1 = 3/4, xe = 1
⎡ 4 −4 ⎤ ⎡1/4 + D (4) ⎤
=⎢ ⎥
(4) 1
K =⎢ , (4)
4 ⎥⎦
F
⎣ −4 ⎢1/4 + D (4) ⎥
⎣ 2 ⎦
SECTION 11.4: Finite Element Method 427
To avoid confusion, we now write down the complete system for each element
© 4 4 0 0 0¸ © Y1 ¸ ©1/4 D1(1) ¸
ª ¹ª ¹ ª ¹
ª 4 4 0 0 0¹ ª Y2 ¹ ª
1/4 D 2 ¹
(1)
ª ¹ª ¹ ª ¹
e 1 ª 0 0 0 0 0¹ ª Y3 ¹ ª ¹
0
ª 0 0 0 0 0¹¹ ªª Y4 ¹ ª ¹
ª ¹ ª 0 ¹
ª« 0 0¹º ª« ¹
Y5 º « ª ¹
0 0 0 0 º
©0 0 0 0 0¸ © Y1 ¸ © 0 ¸
ª ¹ ª ¹ ª (2) ¹
ª0 4 4 0 0¹ ª Y2 ¹ ª1/4 D 1 ¹
ª ¹ ª ¹ ª ¹
e2 ª0 4 4 0 0¹ ª Y3 ¹ ª1/4 D 2 ¹
(2)
ª ª ¹ ª ¹
ª
0 0 0 0 0¹¹ ª
Y4
¹ ª 0 ¹
ª0 0 0 0 0¹º ª Y5 ¹ ª 0 ¹
« « º « º
©0 0 0 0 0¸ © Y1 ¸ © 0 ¸
ª ¹ ª ¹ ª ¹
Y2 0
ª0 0 0 0 0¹ ª ¹ ª ¹
ª ¹ ª ¹ ª1/4 D (3) ¹
e3 ª0 0 4 4 0¹ ª Y3 ¹ª 1 ¹
ª ª ¹ ª ¹
ª
0 0 4 4 0¹¹ ª
Y4
¹ ª
1/4 D 2(3) ¹
ª0 0 0 0 0¹º ª Y5 ¹ ª 0 ¹
« « º « º
©0 0 0 0 0¸ © Y1 ¸ © 0 ¸
¹ ª
ª ¹ ª
Y2 0 ¹¹
ª0 0 0 0 0¹ ª ¹ ª
ª ¹ ª ¹ ª 0 ¹
e4 ª0 0 0 0 0¹ ª Y3 ¹ª ¹
(4)
ª ¹ ª ¹ ª D1 ¹
0 0 0 4 4 Y4
ª ¹ ª ¹ ª ¹
ª0 0 0 4 4¹º ª Y5 ¹ ª D (4) ¹
« « º « 2 º
ª ¹ª ¹ ª ¹
¹º ª«1/4 D 2
(4)
ª« 0 0 0 4 4 ¹º ª« Y5 ¹º
⎧ 7x 1
⎪ , 0≤ x≤
4
⎪ 4
⎪ 10 x + 1 1 1
⎪ ≤x≤
⎪ 4 2
y ( x) = ⎨ 8
⎪ 6x + 3 1 3
⎪ 8 , ≤x≤
⎪ 2 4
⎪ x+3 3
⎪ 4 , ≤ x ≤1 .
⎩ 4
From the above, we obtain y (1/4) = 7/16, which is the same as the exact
solution.
We have attempted, in this book, to supply to the reader some basic numerical
methods which are indispensable for current scientific research. Many methods
have been excluded since we do not intend to be exhaustive. There is indeed
much more to include. Unfortunately, the limitations of space and our own
experience have forced us to exclude many important topics such as eigenvalue
problems in differential equations, linear and non-linear programming,
convergence and stability criteria for partial differential equations and numerical
solution of singular integral equations. Our motivation throughout has been
to present the various methods in a very simple way so as to enable the
reader to understand and apply them to solve the specific problems arising
in his work. The book is, therefore, intended to be an introductory text only.*
*The reader who wishes to pursue the subject and understand the analysis of
these methods is recommended to refer to: Isaacson and Keller, Analysis of
Numerical Methods, and other references cited in the Bibliography.
EXERCISES 429
EXERCISES
11.1 Explain the difference between a function and a functional. Prove that
(a) d (dx) = d(d x).
Answers to Exercises
1 © 2 ¸
1¦
dv µ
11.3 I (v ) ± ª § ¶ gv ¹ dx
0 ª
«
2 dx ·
¨ ¹
º
b © 2 ¸
¦ dv µ
11.4 I (v ) ± ª§ ¶ kv 2 2vx3 ¹ dx v(b)
ª ¨ dx ·
a « ¹
º
b
© d ¦ 2 dv µ ¸
11.5 I (v ) ± v ª 2 g §x ¶ dx
« dx ¨ dx · ¹º
a
b 2
©¦ dv µ ¸
11.6 I (v ) ± ª§ ¶ pv 2 2 qv ¹ dx
¨ dx ·
a ª
« ¹º
1 © 2 ¸
¦ d 2v µ
11.7 ª kv 2 2 f v¹ dx
I (v ) ± ª§ 2 ¶
¹
¨ dx ·
0 « º
1 2
©¦ dv µ ¸
11.8 I (v ) ± ª§ ¶ v2 2vx 2 ¹ dx;
¨ dx ·
0 ª
« º¹
10 7 2
y ( x) { v( x) – x(1 x) x (1 x)
121 41
1 2
©¦ dv µ ¸ 1
11.9 I (v ) ± ª§ ¶ 4 v x¹ dx; y ( x) { v( x) ( x x3 ) .
¨ dx · 3
0 ª
« ¹º
25
11.10 v ( x) x (1 x )
37
10 7
11.11 v( x) x(1 x) x 2 (1 x)
123 41
25
11.12 v( x) x(1 x)
37
Bibliography
BOOKS
Ahlberg, J.H., E.N. Nilson and J.L. Walsh, The Theory of Splines and their
Applications, Academic Press, New York, 1967.
Allaire, P.E., Basics of the Finite Element Method, William C Brown, Dubuque,
IA, 1985.
Atkinson, K.E., An Introduction to Numerical Analysis, John Wiley & Sons,
New York, 1978.
Bathe, K.J. and E.L. Wilson, Numerical Methods in Finite Element Analysis,
Prentice-Hall, New Jersey, 1976.
Berndt, R. (Ed.), Ramanujans Note Books, Part I, Springer-Verlag, New York,
1985.
Booth, A.D., Numerical Methods, Academic Press, New York, 1958.
Brebbia, C.A. and J.J. Connor, Fundamentals of Finite Element Techniques for
Structural Engineers, Butterworths, London, 1975.
Brigham, E.O., The Fast Fourier Transform, Prentice-Hall, New Jersey, 1974.
Carnahan, B., H.A. Luther and J.O. Wilkes, Applied Numerical Methods, Wiley,
New York, 1969.
Conte, S.D., Elementary Numerical Analysis, McGraw Hill, New York, 1965.
Chapra, S.C. and Raymond P. Canale, Numerical Methods for Engineers, 3ed.,
Tata McGraw-Hill, New Delhi, 2000.
Davies, A.J., The Finite Element Method: A First Approach, Clarendon Press,
Oxford, 1980.
Davis, P.J. and P. Rabinowitz, Methods of Numerical Integration, Academic
Press, New York, 1984.
De Boor, C., A Practical Guide to Splines, Springer-Verlag, New York, 1978.
Fox, L. and I.B. Parker, Chebyshev Polynomials in Numerical Analysis, Oxford
University Press, 1968.
431
432 Bibliography
TABLES
Interpolation and Allied Tables, Nautical Almanac Office, HMSO, London,
1956.
Handbook of Mathematical Functions, by Milton Abramovitz and I.A. Stegun,
US Department of Commerce, Washington, 1965.
Orthogonal Polynomials, by Milton Abramovitz and I.A Stegun, US Department
of Commerce, Washington, 1965.
Tables of Integrals and Other Mathematical Data, by H.M. Dwight, Macmillan,
& Co., London, 1934.
RESEARCH PAPERS
Allasiny, E.L. and W.D. Hoskins, Cubic spline solutions to two-point boundary
value problems, Computer Journal, Vol. 12, p. 151, 1969.
Atkinson, K.E., The numerical solution of Fredholm integral equations of the
second kind, SIAM J. Num. Anal., Vol. 4, p. 337, 1967.
Bauer, W.F., J. SIAM, Vol. 6, p. 438, 1958.
Bickley, W.G., Piecewise cubic interpolation and two-points boundary value
problems, Computer Journal, Vol. 11, p. 206, 1968.
Clenshaw, C.W. and A.R. Curtis, A method for numerical integration in an
automatic computer, Numer. Math., Vol. 2, p. 197, 1960.
Cox, M.G., The numerical evaluation of B-splines, J. Inst. Maths. Applics.
Vol. 10, p. 134, 1972.
, The numerical evaluation of a spline from its B-spline representation,
J. Inst. Maths. Applics., Vol. 15, p. 95, 1975.
, The numerical evaluation of a spline from its B-spline representation,
J. Inst. Maths. Applics., Vol. 21, p. 135, 1978.
434 Bibliography
Curtis, A.R. and M.J.D. Powell, Using cubic splines to approximate functions
of one variable to prescribed accuracy, AERE Harwell Report No. AERE-
R5602-(HMSO), 1967.
de Boor, C., On calculation with B-splines, J. Approx. Theory, Vol. 6, p. 50,
1972.
Delves, L.M., The numerical evaluation of principal value integrals, Computer
Journal, Vol. 10, p. 389, 1968.
Einarsson, Bo, Numerical calculation of Fourier integrals with cubic splines,
BIT, Vol. 8, p. 279, 1968.
Einarsson, Bo, On the calculation of Fourier integrals, Information Processing,
Vol. 71, p. 1346, 1972.
El-Gendi, S.E., Chebyshev solution of differential, integrals and integro-
differential equations, Computer Journal, Vol. 12, p. 282, 1969.
Elliott, D., A Chebyshev series for the numerical solution of Fredholm integral
equations, Computer Journal, Vol. 6, p. 102, 1963.
Filon, L.N.G., On a quadrature formula for trigonometric integrals, Proc. Roy.
Soc. Edin., Vol. 49, p. 38, 1928.
Fox, L. and E.T. Goodwin, The numerical solution of nonsingular linear integral
equations, Phil. Trans. Roy. Soc., A, Vol. 245, p. 501, 1953.
Fyfe, D.J., The use of cubic splines in the solution of two point boundary
value problems, Computer Journal, Vol. 12, p. 188, 1969.
,The use of cubic splines in the solution of two point boundary value
problems, Computer Journal, Vol. 13, p. 204, 1970.
Greville, T.N.E., Data fitting by spline functions, M.R.C. Tech. Sum. Report,
893, Maths. Res. Center, US Army, University of Wisconsin, Madison,
Wisconsin, 1968.
Henrici, P., The quotient difference algorithm, App. Math. Series, U.S. Bureau
of Standards, 49, p. 23, 1958.
Ichida and Kiyono, Int. J. Comp. Maths., Vol. 4, p. 111, 1974.
Kalaba, R.E. and E.H. Ruspini, Theory of invariant imbedding, Int. J. Engg.
Sc., Vol. 7, p. 1091, 1969.
Kershaw, D., A note on the convergence of natural cubic splines, SIAM J.
Num. Anal., Vol. 8, 67, 1971.
, Two interpolatory cubic splines, Tech. Rep., Dept. of Maths, University
of Lancaster, 1972.
, A numerical solution of an integral equation satisfied by the velocity
distribution around a body of revolution in axial flow, ARC. Rep.
No. 3308, 1961.
Bibliography 435
Love, E.R., The electrostatic field of two equal circular coaxial conducting
disks, Quar. J. Mech. App. Math., Vol. 2, p. 428, 1949.
Moore, E., Exponential fitting using integral equations, Int. J. Num. Meth. in
Engg., Vol. 8, p. 271, 1974.
Muller, D.E., A method for solving algebraic equations using an automatic
computer, Math. Tables, Aids Comp., Vol. 10, p. 208, 1956.
Patricio, F., Cubic spline functions and initial-value problems, BIT, Vol. 18,
p. 342, 1978.
Phillips, J.L., The use of collocation as a projection method for solving linear
operator equations, SIAM J. Num. Anal., Vol. 9, p. 14, 1972.
Poornachandra, et al., An efficient algorithm for noise elimination using
B-splines in wavelet domain, Biosignal, pp. 9496, 2004.
Rutishauser, H., Z. Angew, Math. Phys., Vol. 5, p. 233, 1954.
Sastry, S.S., A numerical solution of an integral equation of the second kind
occurring in aerodynamics, Ind. J. Pure and App. Math., Vol. 4,
p. 838, 1973.
Sastry, S.S., Numerical solution of nonsingular Fredholm integral equations of
the second kind, Ind. J. Pure and App. Math., Vol. 6, p. 773, 1975.
, Numerical solution of Fredholm integral equations with a logarithmic
singularity, Int. J. Num. Meth. in Engg., Vol. 10, p. 1202, 1976.
Sastry, S.S., Finite difference approximations to one-dimensional parabolic
equations using a cubic spline technique, J. Comp. and App. Math.,
Vol. 2, p. 23, 1976.
Schoenberg, I.J., Contributions to the problem of approximation of equidistant
data by Analytical functions, Quart. App. Maths., Vol. 4, p. 45, 1946.
Srivastava, K.N. and R.M. Palaiya, The distribution of thermal stress in a semi-
infinite elastic solid containing a pennyshaped crack, Int. J. Engg. Sc.,
Vol. 7, p. 641, 1969.
Vandrey, F., A direct iteration method for the calculation of velocity distribution
of bodies of revolution and symmetrical profiles, ARC R&M, 1951,
No. 3374.
Wilkinson, J.H., Householders method for the solution of the Algebraic
Eigenvalue Problem, Comp. J., April 1960.
Wolfe, M.A., The numerical solution of nonsingular integral and integro-
differential equations by iteration with Chebyshev series, Computer Journal,
Vol. 12, p. 193, 1969.
Wynn, P., A sufficient condition for the instability of q-d algorithm, Num.
Math., Vol. 1, p. 203, 1959.
Young, A., The application of approximate product integration to the numerical
solution of integral equations, Proc. Roy. Soc. A, Vol. 224, p. 561, 1954.
Model Test Paper 1
B.E./B.Tech. Degree Examination (Numerical Methods)
Answer All Questions
Section B (5 ´ 16 = 80 marks)
437
438 Model Test Paper 1 Bibliography
¦ hi2 µ ¦ hi2 µ ¸
§ yi 1 M i 1 ¶ ( xi x) § yi M i ¶ ( x xi 1 ) ¹
¨ 6 · ¨ 6 · ¹
º
and
hi 1 h
M i −1 + (hi + hi +1 ) M i + i +1 M i +1
6 3 6
yi +1 − yi yi − yi −1
= − , hi = xi − xi −1. [10]
hi +1 hi
(b) The function y = f (x) is satisfied by the points (1, 1), (2, 5),
(3, 11), (4, 8). Fit a natural cubic spline approximation to this data
and find an approximate value of y (1.5). [6]
15. Evaluate
1
1
I ± dx
0
1 x 2
using trapezoidal rule with h = 0.5, 0.25 and 0.125. Then obtain a
better estimate by Rombergs method. Give the errors in the solutions
obtained. [16]
OR
Find y(0.2) given that
dy y
= 3 x + , y (0) = 1,
dx 2
using the Euler, the modified Euler and the fourth order RungeKutta
methods with h = 0.05. [16]
Model Test Paper 2
B.E./B.Tech. Degree Examination (Numerical Methods)
Answer All Questions
1. List any three sources of errors which you encounter while solving a
methematical problem.
2. State sufficient conditions for the convergence of the iteration method
to find the roots of the system x = F(x, y) and y = G(x, y).
3. Evaluate D4(x4).
4. Form the divided difference table for the data:
x 2 5 10
y 5 29 139
Section B (5 ´ 16 = 80 marks)
11. (a) Prove that NewtonRaphson method has quadratic convergence.
[6]
(b) Use Bessels formula to estimate the value of y when x = 5.0 from
the following data:
(0, 14.27), (4, 15.81), (8, 17.72), (12, 19.96) [6]
439
440 Model Test Paper 2 Bibliography
(c) If the straight line y = a0 + a1x is fitted to the data points (xi, yi),
i = 1, 2,
, n, show that
x y 1
6xi 6yi n 0, i 1, 2, |, n. [4]
6xi2 6xi yi 6xi
12. (a) Using the CooleyTukey algorithm, compute the DFT of the sequence
fk = {1, 1, 1, 1}. [10]
(b) Given the data
x –2 –1 2 3
y –12 –8 3 5
compute y¢(1.0) using cubic spline approximation. [6]
13. (a) Evaluate
1
1
± 1 x dx
0
using the 4-point Gauss quadrature formula. [6]
OR
2
If y = A + Bx + Cx and y0, y1, y2 are the values of y corresponding
to x = a, a + h and a + 2h, respectively, prove that
a 2h
h
± ydx 3 y1 4 y1 y2
. [6]
a
(b) Solve the following equations by triangularisation method:
8x 3y + 2z = 20, 4x + 11y z = 33, 6x + 3y + 12z = 36 [10]
14. Solve the following equations by GaussSeidel method correct to
3 decimal places:
10x 5y 2z = 3, 4x 10y + 3z = 3, x + 6y + 10z = 3 [16]
OR
Using Taylors series, find the values of y (0.1), y (0.2), y (0.3) for the
initial value problem
dy
= xy + y 2 , y (0) = 1.
dx
Hence find the value of y (0.4) using Milnes method. [16]
15. Solve the heat equation
∂u ∂ 2u
=4 2 [16]
∂t ∂x
Model Test Paper 2 441
Model Test Paper 3
B.E./B.Tech. Degree Examination (Numerical Methods)
Answer All Questions
1. State the formula for finding the absolute error in the function
u = f (x1, x2) if Dx1 and Dx2 are the errors in x1 and x2, respectively.
2. Explain how you can find the reciprocal of a number N by Newton
Raphson method.
3. Explain Graeffes root-squaring method for finding the zeros of a
polynomial pn(x) of degree n.
4. What is inverse interpolation? State any formula for it.
5. What are radix-2 algorithms?
6. Define a cubic B-spline and state Cox, de-Boor formula.
7. Explain how you will compute a double integral numerically.
8. Define eigenvalue and eigenvector of a matrix. Explain briefly the power
method for finding the smallest eigenvalue of a matrix.
9. Write down the finite difference analogue of the equation
y¢¢ + f (x)y¢ + g (x)y = h(x) at x = xi.
10. State the explicit and implicit formulae for the solution of the equation
∂u ∂ 2u
= .
∂t ∂x 2
Section B (5 ´ 16 = 80 marks)
11. (a) Explain briefly the regulafalsi method to find an approximate root,
correct to 3 decimal places, of the equation x3 3x 5 = 0 that
lives between 2 and 3. [8]
(b) Establish Newtons divided difference formula and give an estimate
of the remainder term in terms of the appropriate derivative. Deduce
Newtons forward and backward interpolation formulae as particular
cases.
1
If f (x) = 2 , find the divided differences [a, b] and [a, b, c] [8]
x
442
Model Test Paper 3 443
12. (a) Find the values of a, b, c such that the parabola y = a + bx + cx2
fits the following data (xi, yi) in the least squares sense:
(0, 1), (1, 5), (2, 10), (3, 22), (4, 38). [8]
(b) Given the points, viz.
(1, 8), (2, 1), and (3, 18)
satisfying the function y = f (x), find the linear and quadratic splines
approximating the function f (x) and determine the value of y (2.5) in
each case. [8]
Q /2
Q
13. (a) Find the value of ∫ sin x dx with h =
20
using both the trapezoidal
0
1
rule and Simpsons -rule. [8]
3
(b) Use Householders method to reduce the matrix
⎡4 2 2⎤
A = ⎢⎢ 2 5 1 ⎥⎥
⎢⎣ 2 1 6 ⎥⎦
to a tridiagonal form. [8]
14. Using the fourth order RungeKutta formula, find y (0.2) and y (0.4)
given that
dy y 2 − x 2
= , y (0) = 1 . [16]
dx y 2 + x 2
OR
Solve Laplaces equation at the interior points of the square region
given below. Use GaussSeidel method upto 7 iterations:
0 u7 u8 u9 0
0 0
u4 u5 u6
0 u1 u2 u3 0
0 0 0 0 0 [16]
444 Model Test Paper 3 Bibliography
15. Derive the explicit scheme for the solution of the wave equation
∂ 2u ∂ 2u
= a2
∂t 2 ∂x 2
Solve this equation with a 2 = 4 and the boundary conditions
∂u
u(0, t) = u(4, t) = 0, ( x, 0) = 0 and u(x, 0) = 4x x2. With h = 1
∂t
and k = 0.5, find the values of u(x, t) upto 3 time steps.
Model Test Paper 4
B.E./B.Tech. Degree Examination (Numerical Methods)
Answer All Questions
'2
4. Show that E = .
E2
x
5. Transform the equation y = to a linear form.
a + bx
6. Explain the terms Decimation in Time and Decimation in Frequency.
7. State the cubic spline formula for approximating the data (xi, yi),
i = 0, 1,
, n, in terms of the spline second derivatives.
1
8. Give the error in Simpsons -rule.
3
9. What is meant by saying that the RungeKutta formula is of the fourth
order?
10. State the local truncation error of the CrankNicolson formula.
Section B (5 ´ 16 = 80 marks)
11. (a) Explain the underlying principle of Mullers method and give the
computational steps to compute a root of the equation cos x = xex
by Mullers method. Find the root which lies between 0 and 1,
correct to 4 decimal places. [10]
(b) Using Lagranges formula, estimate the value of y(10) from the
following data (x, y):
(5, 12), (6, 13), (9, 14), (11, 16) [6]
12. (a) Obtain the first four orthogonal polynomials fn(x) on [1, 1]
with respect to the weight function W(x) = 1. [6]
445
446 Model Test Paper 4 Bibliography
(b) using the CooleyTukey algorithm, compute the DFT of the sequence
{1, 1, 1, 1}. Draw the flow-graph of the computations. [10]
13. (a) Fit natural and D1 cubic splines for the following data satisfying
the function y = ex:
(0.10, 1.1052), (0.20, 1.2214), (0.30, 1.3499).
Approximate e0.15 in each case and state which of these is the
best fit. [10]
(b) Prove the minimization property of natural cubic splines. [6]
dy
14. (a) Write down the formulae for computing the values of and
d2y dx
at any point, obtained from Newtons forward difference
dx 2 dy
interpolation formula. Obtain the approximate values of and
dx
d2y
for x = 1.2 from the following data:
dx 2
(1.0, 2.7183), (1.2, 3.3201), (1.4, 4.0552), (1.6, 4.9530),
(1.8, 6.0496), (2.0, 7.3891), (2.2, 9.0250). [8]
(b) Derive the trapezoidal rule
b
h
± y dx 2 < y0 2( y1 y2 " yn 1 ) yn >
a
and find an expression for the error in this formula. [8]
15. (a) Using GaussSeidel method upto 5 iterations, solve the system:
30x 2y + 3z = 75, 2x + 2y + 18z = 30, x + 17y 2z = 48
(b) Solve the boundary value problem
d2y
y = 0, y(0) = 0, y(2) = 3.62686
dx 2
by finite difference method with h = 0.5. Find the value of y(1.0)
and state the absolute error in the solution. [8]
OR
vu v 2 u
Use CrankNicolson method to solve the equation with
vt v x 2
the boundary conditions u(x, 0) = 0, u(0, t) = 0, u(1, t) = 200t.
1
Find the values of u(x, t) for two time steps taking h = and
4
1
k = . [16]
8
Index
447
448 Index
THE AUTHOR
S.S. SASTRY, Ph.D., is Formerly, Scientist/Engineer SF in the Applied Mathematics Division
of Vikram Sarabhai Space Centre, Trivandrum. Earlier, he taught both undergraduate and
postgraduate students of engineering at Birla Institute of Technology, Ranchi.
A renowned mathematical scientist and the author of the books on Engineering Mathematics
(all published by PHI Learning), Dr. Sastry has a number of research publications in numerous
journals of national and international repute.
ISBN:978-81-203-4592-8
` 250.00