Professional Documents
Culture Documents
Scientific Computing 2
Lecture Notes in Scientific Computing
MA311-M
Animesh Renanse
January 2, 2021
Contents
1 Introduction 7
1.1 Lecture 0 : Course Introduction . . . . . . . . . . . . . . . . . 7
1.1.1 Course Overview and References . . . . . . . . . . . . 7
1.1.2 Evaluation Policy . . . . . . . . . . . . . . . . . . . . . 7
4 Newton-Raphson Method 19
4.1 Geometric Interpretation . . . . . . . . . . . . . . . . . . . . . 20
4.2 Error Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
8 Interpolation 37
8.1 Lagrange’s Interpolating Polynomial . . . . . . . . . . . . . . 38
8.1.1 Construction of Lagrange’s Interpolating Polynomial 39
8.2 Error in Lagrange’s Interpolation . . . . . . . . . . . . . . . . 41
3
Scientific Computing 4
9 Numerical Differentiation 65
9.1 Differentiation via Polynomial Interpolation . . . . . . . . . 66
9.1.1 Simplification of Error Eq. 9.3 . . . . . . . . . . . . . . 67
9.1.2 Discretization . . . . . . . . . . . . . . . . . . . . . . . 70
9.2 Approximation of Derivatives via Taylor’s Theorem . . . . . 72
10 Numerical Integration 75
10.1 Many rules of choosing the interpolating points . . . . . . . 76
10.1.1 Rectangle Rule . . . . . . . . . . . . . . . . . . . . . . 76
10.1.2 Mid-point Rule . . . . . . . . . . . . . . . . . . . . . . 77
10.1.3 Trapezoidal Rule . . . . . . . . . . . . . . . . . . . . . 77
10.1.4 Simpson’s Rule . . . . . . . . . . . . . . . . . . . . . . 78
10.1.5 Corrected Trapezoidal Rule . . . . . . . . . . . . . . . 79
10.2 Error Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
10.2.1 Error in Rectangle Rule . . . . . . . . . . . . . . . . . 81
10.2.2 Error in Mid-Point Rule . . . . . . . . . . . . . . . . . 82
10.2.3 Error in Trapezoidal Rule . . . . . . . . . . . . . . . . 82
10.2.4 Error in Simpson’s Rule . . . . . . . . . . . . . . . . . 82
10.2.5 Error in Corrected Trapezoidal Rule . . . . . . . . . . 83
10.3 Composite Methods . . . . . . . . . . . . . . . . . . . . . . . 83
10.3.1 Composite Rectangle Rule . . . . . . . . . . . . . . . . 84
10.3.2 Composite Mid-Point Rule . . . . . . . . . . . . . . . 85
CONTENTS
5 Scientific Computing
CONTENTS
Scientific Computing 6
CONTENTS
Chapter 1
Introduction
7
Scientific Computing 8
CHAPTER 1. INTRODUCTION
Chapter 2
x∈R
x = ± bn 2 n + bn − 1 2 n − 1 + · · ·
where n is some integer and the binary digits bi takes the value either 0 or
1. Hence we can write in general that,
Remark: It’s not true that a finite decimal number will have a finite repre-
sentation in a binary computer. However, to a finite binary number there
always corresponds a finite decimal representation.
9
Scientific Computing 10
• Floating-point number
• Fixed-point number
where,
f = ± ( b− 1 b− 2 · · · b− t ) 2 , e = ± ( c s − 1 c s − 2 · · · c 0 ) 2
Here, t is the number of binary digits allowed by the computer in the frac-
tional part and s is the number of binary digits in the exponent. f is re-
ferred as the mantissa and e is referred to as the exponent of x.
The trivially used terms overflow and underflow refers to the respective
cases when during the course of the computation the number produced
have a modulus greater than f Lmax and less than f lmin .
However, we can still increase the precsion of the computation by intro-
ducing twice the number of allowed digits in the mantissa, i.e. R (2t, s),
this is called double-precision number.
2.1.1 Rounding
Let,
∞
!
x ∈ R, x = ± ∑ b− k 2 − k 2e
k =1
be the exact real number in floating point form, thus the rounded number
is,
!
t
∗
x ∈ R, ± ∑ ∗ −k
b− k2 2e (2.2)
k =1
e∗ = e
∗
b− k = b− k
for all k = 1, 2, · · · , t.
More concretely, we can write the chop and rd operation as the following,
x = rd ( x )
1 −t e (2.3)
rd ( x ) = chop x + .2 .2
2
| {z }
1
adds 2 to make it compatible
∞
| x − chop ( x )| = ± ∑ b−k 2 2
−k e
k = t +1
∞
(2.4)
≤ ∑ 2− k . 2e = 2− t . 2e
k = t +1
Similarly, we can calculate the relative error in the case of chopping as,
2− t 2e
x − chop ( x )
≤
± ∑ ∞ b− k 2 − k 2 e
x
k =1
2− t 2e
≤
1 (2.5)
. 2e
|2 {z }
this is minimized
≤ 2 . 2− t
? Note that the upper bound on the relative error is not dependent on e.
??Remark: The machine dependent term eps = 2−t is also called the ma-
chine precision .
Similarly, for the rounding, we can find the relative error to be upper
bounded by the following inequality,
x − rd ( x )
≤ 2− t (2.6)
x
Multiplication
Consider values x (1 + ε x ) and y 1 + ε y of x and y contaminated by rel-
ative errors ε x and ε y respectively, in this case, the relative error in the
product is,
rd ( x.y) ≈ xy 1 + ε x + ε y
xy − rd ( xy)
=⇒ ≈ εx + εy
xy
ε x.y = ε x + ε y
Division
x (1 + ε x ) x
= (1 + ε x ) 1 − ε y + ε2y − . . .
y 1 + εy y
x
≈ 1 + εx − εy
y
therefore,
ε yx = ε x − ε y
Therefore, now the relative error also depends on the inputs! Thus the
addition is a benign operation. The error in Eq. 2.9 is called cancellation
error. This type of cancellation error should be avoided in the calcula-
tions as much as possible, thus try to avoid addition and subtraction
directly as much as possible.
√ √
Example 2: If y = x + δ − x, x > 0, |δ| is very small. To avoid can-
cellation error, one should write
δ
y= √ √
x+δ+ x
Thus finding equivalent representations is an important concept for direct Addi-
tion and Subtraction as concretely shown in above example (and in slides).
Note that before asking the question that what are the solutions of f ( x ),
we should first answer the question that whether there exists solutions of
f ( x ) = 0 or not. In that extent, we have the following theorem,
15
Scientific Computing 16
Algorithm
a0 ≤ a1 ≤ · · · ≤ b0 and b0 ≥ b1 ≥ · · · ≥ a0
We thus have,
1
bn + 1 − a n + 1 = ( bn − a n )
2
Note that the sequence { an } is bounded above and hence converges (in-
creasing or decreasing sequence which is bounded) . Similarly, {bn } also con-
verges.
Since,
1 1
bn − a n = (bn−1 − an−1 ) = · · · = n (b0 − a0 )
2 2
it thus follows that,
1
lim bn − lim an = lim (b0 − a0 )
n→∞ n→∞ n → ∞ 2n
lim f ( an ) f (bn ) ≤ 0 =⇒ f 2 (r ) ≤ 0 =⇒ f (r ) = 0
n→∞
But suppose we stop the process at the timestep n, thus we’ll have the
interval [ an , bn ]. Then the best estimate of the root will clearly be cn = an +2 bn .
The error at this timestep en will then be,
1 1
en = |r − c n | ≤ (bn − an ) = n+1 (b0 − a0 )
|2 {z } 2
len of half inter.
|r − cn | ≤ 2−(n+1) (b0 − a0 )
Newton-Raphson Method
We will first introduce the method for single variable function and then
we will extend it to non-linear functions.
Neglecting the higher order terms for sufficiently small h (note that we are
hence linearizing the original equation), we simply get
f ( x0 )
h=−
f 0 ( x0 )
f ( x0 )
x1 = x0 −
f 0 ( x0 )
19
Scientific Computing 20
f ( xn )
x n +1 = x n − , n≥0
f 0 ( xn )
y − f ( x0 ) = f 0 ( x0 )( x − x0 )
Now the above tangent line meets the x-axis at y = 0, which gives us,
f ( x0 )
x1 ≈ x = x0 −
f 0 ( x0 )
which is just the first approximation.
(r − xn )2 00
0 = f (r ) = f ( xn + (r − xn )) = f ( xn ) + (r − xn ) f 0 ( xn ) + f ( ηn )
2
where ηn lies between r and xn . Now solving for r from the above equa-
tions gives us
f ( xn ) (r − xn )2 f 00 ( xn )
r = xn − − . 0
f 0 ( xn ) 2 f ( xn )
(r − xn )2 f 00 ( xn )
= x n +1 − . 0
2 f ( xn )
hence the r − xn+1 = en+1 is given by,
e2n f 00 ( xn ) 1 f 00 (r )
e n +1 = − . 0 ≈ − 0 e2n = Ce2n
2 f ( xn ) 2 f (r )
Hence, the Newtons’s method converges quadratically.
2. f 0 ( x ) 6= 0 ∀ x ∈ [ a, b].
| f ( a)| | f (b)|
0
< b − a and 0 < b−a
| f ( a)| | f (b)|
• To make sure the step size isn’t more than the size of the interval
itself.
Let ( x10 , x20 ) be the initial approximation to the exact solution and let the
h01 and h02 be the corrections given to x10 and x20 respectively so that,
∂ f1 ∂f
f 1 ( x10 + h01 , x20 + h02 ) ≈ f 1 ( x10 , x20 ) + h01 0
+ h02 10
∂x1 ∂x2
∂f ∂f
f 2 ( x10 + h01 , x20 + h02 ) ≈ f 2 ( x10 , x20 ) + h01 10 + h02 10
∂x1 ∂x2
Jh = −f
23
Scientific Computing 24
h = − J −1 f
and then we can repeat the whole method to get even finer approxima-
tions. Hence, more generally, we get,
n +1 n n
x1 x1 h1
n +1 = x n + h n
x2 2 2
h = − J −1 f ( x ) (5.2)
x n +1 = x n + h n
(5.3)
h n = − J −1 f ( x n )
Retrieve the initial point for the current timestep, then calculate the cor-
rection vector for this timestep by solving the 5.2, add this correction to
the initial point to get the new approximation, substitute the new approx-
imation as the initial approximation for the next timestep. Stop when the
nth power of ln norm of correction vector is less than the tolerance tol hy-
perparameter.
x = g( x )
with which, we can thus conclude that any fixed-point of g above is a so-
lution of f ( x ) = 0.
• g( x ) = x2 − 2
√
• g( x ) = x + 2
2
• g( x ) = 1 + x
x 2 − x −2
• g( x ) = x − m , m 6= 0
27
Scientific Computing 28
g( x ) = x
implies f ( x ) = 0.
Algorithm :-
x n +1 = g ( x n ) , n = 0, 1, 2, . . .
Note that to implement the above algorithm, one needs to ensure the fol-
lowing,
• Sequence { xn } → r.
A natural question which thus arises is that whether the above algorithm
will guarantee to find the fixed point of g (thus, finding solution of f ( x ) =
0 in the process), for that purpose, we have the following theorem.
1. g : I → I.
2. g : I → I is continuous.
h( x ) = g( x ) − x
Clearly, h( x ) ∈ [0, b − a], therefore h( a) > 0 and h(b) < 0 and since h is
continuous, thus by Bolzano’s theorem, there is a point r ∈ I such that
h(r ) = 0 which simply means that g(r ) = r. Hence, there exists a fixed
point of g in I.
r − xn = e
If we now calculate e,
e = r − x n = g ( r ) − g ( x n −1 )
| e n | ≤ K | e n −1 |
≤ K 2 | e n −2 |
≤ K n | e0 |
Therefore, in the limit n → ∞, since K < 1, en → 0. Which thus implies
that { xn } → r.
Note that we also have to prove the uniqueness of the fixed point, for
that simply consider two points r, r1 ∈ I which are also fixed points, so,
g(r ) = r and g(r1 ) = r1 . If we set x0 = r, then from the iteration,
x1 = g ( x0 ) = g (r ) = r
e1 ≤ Ke0
g 0 ( r ) = · · · = g ( m −1) ( r ) = 0
x n +1 = g ( x n ) , n≥0
( r − x n +1 ) (m ) (r )
m −1 g
lim = (− 1 ) .
n → ∞ (r − x n ) m
| {z m! }
finite value !
x n +1 = g ( x n )
m −1
( x n − r ) k g ( k ) (r ) ( x n − r ) m g ( m ) ( ηn )
x n +1 = g ( x n ) = ∑ k!
+
m!
k =0
( x n − r ) m g ( m ) ( ηn )
x n +1 = r +
m!
therefore,
xn − r g ( m ) ( ηn )
=
( xn − r )m m!
finally, we get,
r − xn (m) ( η )
m −1 g n
m
= (− 1 )
(r − x n ) m!
We know that the fixed point iteration algorithm for the iteration func-
tion of f converges with order m to a fixed point of the iteration function
(refer to previous Theorem 6.4).
33
Scientific Computing 34
For this task, we would need to check derivative of the iteration function
g, thus,
( f 0 ( x ))2 − f ( x ) f 00 ( x ) f ( x ) f 00 ( x )
g0 ( x ) = 1 − =
( f 0 ( x ))2 ( f 0 ( x ))2
Again, for x = r, we get g0 as,
g0 ( x ) = 0
f 00 (r )
g(r ) = r , g0 (r ) = 0 , g00 (r ) = 6= 0
f 0 (r )
Therefore from Theorem 6.4, Newton’s method has second order conver-
gence.
f ( x ) = ( x − r )m h( x ) , where h( x ) 6= 0
f (r ) = f 0 (r ) = · · · = f (m−1) = 0 and f m (r ) 6= 0
f 0 ( x ) = ( x − r ) m h 0 ( x ) + m ( x − r ) m −1 h ( x )
thus, we get the iteration function (discussed previously for Newton’s It-
eration) g( x ) simply as,
f (x) ( x − r )m h( x ) ( x − r )h( x )
g( x ) = x − 0
= x − =
f (x) m 0
( x − r ) h ( x ) + m( x − r ) m − 1 h( x ) ( x − r )h0 ( x ) + mh( x )
Again, you can check that g( x ) has the fixed point as r, g(r ) = r.
1
g 0 (r ) = 1 − 6= 0
m
Hence the convergence of Newton’s method for functions with multiple
roots is Linear (1st Order).
Now a natural question to ask is whether we can make the convergence bet-
ter?
Now, To regain the 2nd order convergence, notice in the above equation
that g0 ( x ) can become 0 if we had m (the multiplicity of the root r) multi-
plied with 2nd term of g0 ( x ). So, we can now simply modify the Newton’s
Iteration formula to the following,
f (x)
x n +1 = x n − m (7.1)
f 0 (x)
which thus implies that we have the modified iteration function g( x ) as,
f (x)
g( x ) = x − m
f 0 (x)
g (r ) = g 0 (r ) = 0
Thus, using Theorem 6.4, we can certainly claim that the modified New-
ton’s Iteration formula Eq. 7.1 for functions with multiple roots has sec-
ond order convergence.
Interpolation
f ( x1 ) − f ( x0 )
y − f ( x0 ) = ( x − x0 )
x1 − x0
If we set y = p( x ), then the above equation can be re-arranged to,
f ( x0 )( x − x1 ) − f ( x1 )( x − x0 )
p( x ) =
x0 − x1
= f ( x0 ) L0 ( x ) + f ( x1 ) L1 ( x )
x − x1 x − x0
where L0 ( x ) = x0 − x1 and L1 ( x ) = x0 − x1 .
p ( xi ) = f ( xi ) , i = 0, 1, . . . , n
37
Scientific Computing 38
Interpolating Polynomial.
? Clearly, such a definition raises the following three questions which are
important to answer,
1. Does such a p( x ) exists?
2. If p( x ) exists, then is it unique?
3. And if p( x ) exists, then how to construct it?
To answer the Question 1, we present the following theorem.
Theorem 8.5 : (The WAT) Let f ∈ C [ a, b]. Then for every e > 0, there is a
polynomial p( x ) such that
| p( x ) − f ( x )| < e ∀ x ∈ [ a, b]
This theorem thus guarantees the existence of a polynomial function p for
approximating any continuous function f in a bounded interval. Hence
the Question 1 is now answered in an affirmative manner.
CHAPTER 8. INTERPOLATION
39 Scientific Computing
Xa = F
where,
x0 x02 . . . x0n
x x2 . . . x n
1 1 1
X = .. .. ..
. . ... .
xn xn2 . . . xnn
T
a = a0 a1 . . . a n
T
F = f ( x0 ) f ( x1 ) . . . f ( x n )
Therefore, we can find the vector a quite easily. But, it can oly be the case
if X is invertible (or non-singular), to that extent, we have the following
definition.
CHAPTER 8. INTERPOLATION
Scientific Computing 40
As shown in the opening example of this chapter, we can define the fol-
lowing,
Li ( x ) = c( x − x0 ) . . . ( x − xi−1 )( x − xi+1 ) . . . ( x − xn )
x − xj
Li ( x ) = ∏ xi − x j i = 0, 1, . . . , n (8.1)
j 6 =i
We can thus construct the Lagrange Interpolating Polynomial for any gen-
eral problem now as,
n
p( x ) = ∑ f ( xi ) Li ( x ) (8.3)
i =0
= f ( x0 ) L0 ( x ) + · · · + f ( x n ) L n ( x )
q( xi ) = f ( xi ) , i = 0, 1, . . . , n
CHAPTER 8. INTERPOLATION
41 Scientific Computing
n
f ( n +1) ( ζ ) n
E(t) = f (t) − pn (t) = f (t) − ∑ f ( x j ) L j (t) =
( n + 1) ! ∏
(t − x j )
j =0 j =0
E( x ) = f ( x ) − pn ( x )
where pn ( x ) = ∑nj=0 f ( x j ) L j ( x ).
Now set,
n
ψ( x )
G ( x ) = E( x ) −
ψ(t)
E(t) where ψ( x ) = ∏( x − x j )
j =0
and
G (t) = E(t) − E(t) = 0
Therefore, G has n + 2 zeros on [ a, b]. By Mean Value Theorem, the G 0
has n + 1 distinct zeros in [ a, b], G 00 has n distinct zeros in [ a, b] and so on.
CHAPTER 8. INTERPOLATION
Scientific Computing 42
Hence the G (n+1) ( x ) has only one zero in [ a, b]. Therefore this implies that
there exists ζ ∈ [ a, b] such that G (n+1) (ζ ) = 0. Thus,
ψ ( n +1) ( x ) ( n + 1) !
G ( n +1) ( x ) = E ( n +1) ( x ) − E ( t ) = f ( n +1) ( x ) − E(t)
ψ(t) ψ(t)
( n + 1) !
G ( n +1) ( ζ ) = 0 = f ( n +1) ( ζ ) − E(t)
ψ(t)
which implies,
f ( n +1) ( ζ ) f ( n +1) ( ζ ) n
( n + 1) ! ∏
E(t) = ψ(t) = (t − x j )
( n + 1) ! j =0
With this, we can now form the bound on the error f (t) − p1 (t) as follows,
00
f (ζ )
| f (t) − p1 (t)| ≤ (t − x0 )(t − x1 )
2!
M
≤ |(t − x0 )(t − x1 )|
2
Now, to convert the bound in terms of x0 and x1 only, we should maximize
it. In doing so, we would need to find the maximum value of |(t − x0 )(t −
CHAPTER 8. INTERPOLATION
43 Scientific Computing
M
| f (t) − p1 (t)| ≤ ( x0 − x1 )2 (8.5)
8
Thus the Eq. 8.5 gives us the bound on the error that can be incurred in
Linear Interpolation over [ x0 , x1 ] when the f 00 ≤ M.
CHAPTER 8. INTERPOLATION
Scientific Computing 44
CHAPTER 8. INTERPOLATION
45 Scientific Computing
Ac = F (8.11)
T T
where Aij = q j ( xi ), c = c0 c1 . . . cn and F = f ( x0 ) f ( x1 ) . . . f ( xn ) .
p2 ( x ) = c0 + c1 ( x − x0 ) + c2 ( x − x0 )( x − x1 )
p2 ( x0 ) = c0
(8.13)
p2 ( x1 ) = c0 + c1 ( x1 − x0 )
p2 ( x2 ) = c0 + c1 ( x2 − x0 ) + c2 ( x2 − x0 )( x2 − x1 )
and for this case, the equivalent matrix form for interpolation condition
is,
1 0 0 c0 f ( x0 )
1 ( x1 − x0 ) 0 c1 = f ( x1 ) (8.14)
1 ( x2 − x0 ) ( x2 − x0 )( x2 − x1 ) c2 f ( x2 )
c n = f [ x0 , . . . , x n ] (8.15)
pn ( x ) = f [ x0 ] + f [ x0 , x1 ]( x − x0) + f [ x0 , x1 , x2 ]( x − x0 )( x − x1 ) + . . .
+ f [ x0 , . . . , xn ]( x − x0 )( x − x1 ) . . . ( x − xn−1 )
(8.16)
CHAPTER 8. INTERPOLATION
Scientific Computing 46
n k −1
pn ( x ) = ∑ f [ x0 , . . . , x k ] ∏ ( x − x j )
k =0 j =0 (8.17)
| {z }
qk ( x )
And now it should be clear how the Eq. 8.17 does not changes the pk ’s
when new point is added. Note that when indeed a new point (n + 2) is
added, then all we need to calculate is f [ x0 , . . . , xn+1 ]( x − x0 ) . . . ( x − xn )
and add it to the pn ( x ), to yield us the required pn+1 ( x ).
Now the next question that arises, is how can we find f [ x0 , . . . , xk ] which
is the coefficient of qk ( x ) in Eq. 8.17? Note that this coefficient is called
divided differences, as explained next.
pn ( x1 ) = f ( x1 ) = c0 + c1 ( x1 − x0 ) = f ( x0 ) + f [ x0 , x1 ]( x1 − x0 )
f ( x1 ) − f ( x0 )
f [ x0 , x1 ] =
x1 − x0
Hopefully, now the motivation behind the name divided differences would
be clear in reader’s mind.
f [ x 1 , x 2 , . . . , x n ] − f [ x 0 , x 1 , . . . , x n −1 ]
f [ x0 , x1 , . . . , x n ] = (8.18)
x n − x0
pk ( xi ) = f ( xi ) , i = 0, 1, . . . , k
CHAPTER 8. INTERPOLATION
47 Scientific Computing
So, we have pn which obeys the interpolating condition. Thus LHS and
RHS of Eq. 8.20 can be compared componentwise.
Now, in Eq. 8.19, consider the coefficients of x n in LHS and both parts
of RHS. Since both sides are equal, then so would be the coefficients,
Coefficient of x n in pn ( x ) = f [ x0 , . . . , xn ] (from Eq. 8.17)
1
Coefficient of x n in xq( x ) = f [ x1 , . . . , xn ] (q( x ) is only dependent on x1 , . . . , xn )
x n − x0
1
Coefficient of x n in xpn−1 ( x ) = f [ x0 , . . . , xn−1 ] (pn ( x ) is only dependent on x0 , x1 , . . . , xn )
x n − x0
(8.22)
we hence get
f [ x 1 , x 2 , . . . , x n ] − f [ x 0 , x 1 , . . . , x n −1 ]
f [ x0 , x1 , . . . , x n ] =
x n − x0
CHAPTER 8. INTERPOLATION
Scientific Computing 48
CHAPTER 8. INTERPOLATION
49 Scientific Computing
f (k) ( ξ )
f [ x0 , x1 , . . . , x k ] = (8.25)
k!
Proof : Clearly, the proof would involve the use of Mean Value Theorem
as it guarantees the existence of a point in the interval where f is continuously
differentiable such that divided differnece on endpoints is equal to the tangent line
at that point.
ek ( x ) = f ( x ) − pk ( x )
CHAPTER 8. INTERPOLATION
Scientific Computing 50
QED
With the Theorem 8.9 in hand which relates the kth divided difference with
the kth derivative of f , we can reform the Theorem 8.8 to get a new form
of error in Newton’s Interpolation as follows,
f ( n ) ( x0 )
f [ x0 , . . . , x0 ] = (8.27)
| {z } n!
n + 1 times
CHAPTER 8. INTERPOLATION
51 Scientific Computing
ξ = f −1 (0 ) = g (0 )
Now, we compute
y0 = f ( x0 )
y1 = f ( x1 )
x0 = g ( y0 )
x1 = g ( y1 )
x2 = x0 + (0 − y0 ) g [ y0 , y1 ] = x0 − y0 g [ y0 , y1 ] (8.30)
CHAPTER 8. INTERPOLATION
Scientific Computing 52
y3 = f ( x3 ) =⇒ x3 = g(y3 )
x4 = x3 − y0 y1 y2 g[y0 , y1 , y2 , y3 ] , y4 = f ( x4 ) =⇒ x4 = g(y4 )
and so on, we can continue in this way to generate new points for inter-
polation for inverse function g. Note that in all above iterations, we were
keeping y = 0 as we need to find the value of interpolated polynomial at
0 only, we don’t care about other values.
In general xk → ξ with k → ∞.
H ( xi ) = f ( xi ) = yi
and (8.31)
0 0
H ( xi ) = f ( xi ) = yi0
hi0 ( x j ) = h̃i ( x j ) = 0 , i, j = 0, 1, . . . , n
(
0 i 6= j (8.32)
hi ( x j ) = h̃i0 ( x j ) =
1 i=j
CHAPTER 8. INTERPOLATION
53 Scientific Computing
Eq. 8.32 is needed for maintaining same functional and derivative values
at all given points. We can verify it also that,
H(xj ) = yj
H 0 ( x j ) = y0j
However, we still need to construct hi ( x ) and h̃i ( x ). For that, recall the
basis for Lagrange Interpolating polynomial as given in Eq. 8.1 (repeated
below for convenience),
x − xj
Li ( x ) = ∏ xi − x j i = 0, 1, . . . , n
j 6 =i
hi ( x ) = 1 − 2Li0 ( xi )( x − xi ) ( Li ( x ))2 , 0 ≤ i ≤ n
(8.33)
It can be seen that hi ( x ) and h̃( x ) in Eq. 8.33 & 8.34 obey the constraints of
Eq. 8.32. Hence, they are valid candidates for Hermite polynomials!
n n
H (x) = ∑ yi hi (x) + ∑ yi0 h̃i (x) (8.35)
i =0 i =0
f ( x0 ) = y0
f ( x1 ) = y1
f 0 ( x0 ) = y00
f 0 ( x1 ) = y10
CHAPTER 8. INTERPOLATION
Scientific Computing 54
where,
x − x1
L0 ( x ) =
x0 − x1
x − x0
L1 ( x ) =
x1 − x0
1
L00 ( x ) =
x0 − x1
1
L10 ( x ) =
x1 − x0
R( x ) = G ( x ) − H ( x )
Clearly, R( xi ) = R0 ( xi ) = 0 ∀ i = 0, 1, . . . , n.
R( x ) = q( x )( x − x0 )2 ( x − x1 )2 . . . ( x − xn )2
for q( x ) 6= 0 is a polynomial.
CHAPTER 8. INTERPOLATION
55 Scientific Computing
H ( x ) = f ( z1 ) + ( x − z1 ) f [ z1 , z2 ]
+ ( x − z1 )( x − z2 ) f [z1 , z2 , z3 ]
(8.36)
+...
+ ( x − z1 )( x − z2 ) . . . ( x − z2n−1 ) f [z1 , z2 , . . . , z2n ]
The error in the above approximation can be written as the following with
the help of Theorem 8.8 and a new interpolating point x 6= zi for all i,
Now, from the above equation we see that the H ( x ) is a polynomial of de-
gree ≤ 2n − 1.
f ( x ) − H ( x ) = ( x − x 1 )2 . . . ( x − x n −1 )2 ( x − x n )2 f [ x 1 , x 1 , . . . , x n , x n , x ]
f ( xi ) − H ( xi ) = 0 for all i = 1, 2, . . . , n
CHAPTER 8. INTERPOLATION
Scientific Computing 56
d
f 0 ( x ) − H 0 ( x ) = ( x − x 1 )2 . . . ( x − x n −1 )2 ( x − x n )2 f [ x 1 , x 1 , . . . , x n , x n , x ]
( dx )
n
+ 2 f [ x1 , x1 , . . . , x n , x n , x ] ∑ ( x − x i ) ∏ ( x − x j )2
i =1 j 6 =i
(8.39)
f 0 ( xi ) − H 0 ( xi ) = 0 for all i = 1, 2, . . . , n
H ( x ) = f ( x1 ) + ( x − x1 ) f [ x1 , x1 ]
+ ( x − x1 )2 f [ x1 , x1 , x2 ]
+...
+ ( x − x 1 )2 . . . ( x − x n −1 )2 ( x − x n ) f [ x 1 , x 1 , . . . , x n , x n ]
(8.40)
CHAPTER 8. INTERPOLATION
57 Scientific Computing
( x0 , y0 ), ( x1 , y1 ), . . . , ( x n , y n )
with x0 < x1 · · · < xn . These points xi ’s are called knots and yi ’s are called
ordinates. These may be values of a function f at the points xi , i.e. f ( xi ) = yi .
A function S( x ) that satisfies the following conditions:
1. S( x ) is a linear function in the intervals [ xi , xi+1 ].
2. S( x ) is continuous in [ x0 , xn ].
3. S( xi ) = yi for i = 0, 1, . . . , n.
is called Linear Interpolating Spline.
A very natural question to ask now is that whether such a function even exists
or not?
S( x ) = Si ( x ) for x ∈ [ xi , xi+1 ]
CHAPTER 8. INTERPOLATION
Scientific Computing 58
2. S0 , S00 ∈ C ([ x0 , xn ])
3. S( xi ) = yi for all i = 0, 1, . . . , n
additionally with
Si−1 ( xi ) = yi = Si ( xi ) for i = 1, . . . , n − 1
and combined with the assumed continuity of S0 and S00 , we also get the
following conditions,
Si0−1 ( xi ) = Si0 ( xi )
Si00−1 ( xi ) = Si00 ( xi )
for i = 1, . . . , n − 1.
CHAPTER 8. INTERPOLATION
59 Scientific Computing
First, it’s easy to see that we need 4n conditions to make S( x ) (the coef-
ficients of third degree polynomial on each interval). However, a quick
observation tells us that we have total 2n (Boundary values of each sub-
interval) +(n − 1) (Boundary values for continuity of Si0 ) +(n − 1) (Bound-
ary values for continuity of Si00 ).
CHAPTER 8. INTERPOLATION
Scientific Computing 60
Eq. 8.42 has given the Si00 for each interval [ xi , xi+1 ]. Since Si00 is linear,
to get S( x ), we can simply integrate Eq. 8.42 twice, the results of which
are,
mi m
Si ( x ) = ( x i +1 − x )3 + i +1 ( x − x i )3 + C ( x − x i ) + D ( x i +1 − x )
6hi 6hi
(8.43)
mi m
Si ( x ) = ( x i +1 − x )3 + i +1 ( x − x i )3 (8.44)
6h 6h
i i
y i +1 m i +1 h i yi mi hi
+ − ( x − xi ) + − ( x i +1 − x )
hi 6 hi 6
Now, we will use the final condition, the Continuity of S0 . First of all,
the Si0 is,
m m y i +1 m i +1 h i yi mi hi
Si0 ( x ) = − i ( x i +1 − x )2 + i +1 ( x − x i )2 + − − −
2hi 2hi hi 6 hi 6
(8.45)
Now, since,
Therefore,
m i h i h i m i +1 y i y i +1
Si0 ( xi ) = − − − +
3 6 hi hi
(8.46)
h m h m y y
Si0−1 ( xi ) = i−1 i−1 + i−1 i − i−1 + i
6 3 h i −1 h i −1
6 6
h i −1 m i −1 + 2 ( h i + h i −1 ) m i + h i m i +1 = ( y i +1 − y i ) − ( y − y i −1 )
hi h i −1 i
(8.47)
CHAPTER 8. INTERPOLATION
61 Scientific Computing
CHAPTER 8. INTERPOLATION
Scientific Computing 62
00
f ( x ) ≈ curvature
Z b 2 Z b 2
00
S (x) dx ≤ f 00 ( x ) dx
a a
Z b 2 Z b 2 Z b 2 Z b
00 00 00
f ( x ) dx = S ( x ) dx + h ( x ) dx + 2 S00 ( x )h00 ( x )dx
a
|a {z } |a {z } | a
{z }
≥0 ≥0 ?
The last term can be seen to be the deciding factor, in the sense that if it is
greater than zero than we are done, however if it is less than zero, that can
become problematic.
However, as we will show now, this third term is indeed equal to zero.
CHAPTER 8. INTERPOLATION
63 Scientific Computing
a
00 00
S ( x )h ( x )dx = ∑ S00 h00 dx
i =1 x i −1
n Z xi
= ∑ |(S00 h0 )(xi ) −{z(S00 h0 )(xi−1}) − S000 h0 dx
i =1 x i −1
=0, Continuity constraints
n Z xi
=−∑ S000 h0 dx
i =1 xi−1 const.
|{z}
n
= − ∑ ci (h( xi ) − h( xi−1 )) = 0
i =1
(8.50)
QED.
CHAPTER 8. INTERPOLATION
Scientific Computing 64
CHAPTER 8. INTERPOLATION
Chapter 9
Numerical Differentiation
The answer to this problem is yes, we can using the interpolating poly-
nomial which we just discussed!
65
Scientific Computing 66
Let f ( x ) ∈ C k+2 [c, d]. If x0 , x1 , . . . , xk are distinct points in [c, d], we can
write using the Newton’s Interpolating polynomial the f ( x ) as,
f ( x ) = pk ( x ) + f [ x0 , x1 , . . . , xk , x ]ψk ( x ) (9.1)
Now, since we can write the derivative of the divided difference as the
following (refer Sec. 8.5.1, 1st point),
d
f [ x0 , x1 , . . . , xk , x ] = f [ x0 , x1 , . . . , xk , x, x ]
dx
With the help of above, we can differentiate Eq. 9.1 to get the following,
E( f ) = D ( f ) − D ( pk )
= f [ x0 , x1 , . . . , xk , a, a]ψk ( a) + f [ x0 , x1 , . . . , xk , a]ψk0 ( a)
(9.3)
f (k+2) (ξ )ψk ( a) f ( k +1) ( η ) ψ 0 ( a )
= + (Theorem 8.9)
( k + 2) ! ( k + 1) !
ψk ( a) = 0
k
f ( k +1) ( η )
E( f ) =
( k + 1) ! ∏ ( xi − x j ) for η ∈ [c, d] (9.4)
j=0,j6=i
We first discuss how this case can arise, i.e. for which a is ψk0 ( a) = 0.
k−1
xk− j − a = a − x j , j = 0, . . . ,
2
Then, we have that,
( x − x j )( x − xk− j ) = ( x − a + a − x j )( x − a + a − xk− j )
k−1
= ( x − a)2 − ( a − x j )2 , j = 0, . . . ,
2
Hence, we get the ψk ( x ) as,
k −1
2 h i
ψk ( x ) = ∏ ( x − a )2 − ( a − x j )2
j =0
Now since,
d h i
( x − a )2 − ( a − x j )2 = 2( x − a)| x=a = 0 ∀ j
dx x=a
Also note that in this case the derivative is one orde higher than that
in Eq. 9.4.
We now demonstrate few examples which portray the usage of above
cases in determining the derivatives at the given points.
Exampe 1 : For k = 1,
p1 ( x ) = f ( x0 ) + f [ x0 , x1 ]( x − x0 )
Thus,
D ( p1 ) = f [ x0 , x1 ]
regardless of a. If we set a = x0 , we thus arrive at CASE I.
h2 000
E( f ) = − f (η )
6
pk ( x ) = f ( x0 ) + f [ x0 , x1 ]( x − x0 ) + f [ x0 , x1 , x2 ]( x − x0 )( x − x1 )
p0k ( x ) = f [ x0 , x1 ] + f [ x0 , x1 , x2 ](2x − x0 − x1 )
1
f 0 ( a) = f [ a, x1 ] + f [ a, x1 , x2 ]( a − x1 ) + ( a − x1 )( a − x2 ) f 000 (η )
|6 {z }
E( f )
−3 f ( a) + 4 f ( a + h) − f ( a + 2h)
f 0 ( a) ≈
2h
and the error as (Eq. 9.4),
h2 000
E( f ) = f (ξ ) , for some ξ ∈ ( a, a, +2h)
3
On the other hand, if we choose x1 = a − h and x2 = a + h (This is NOT
the CASE II, we just assume a different distribution of points), then,
f ( a + h) − f ( a − h)
f 0 ( a) ≈
2h
and the error becomes,
h2 000
E( f ) = − f (ξ ) with |ξ − a| < |h|
6
9.1.2 Discretization
Observe in above examples that the formulas for the derivative of f were
always of the form,
Derivative on a computer
Theorem 9.12 : For a computer with fixed word length and for a given function
f , there is an optimum value of h below which the approximation of the derivative
with the derivative of pk will become worse. The optimum value of h is that value
for which the sum of the magnitudes of the round-off error and the discretization
error is minimized.
f ( a + h) − f ( a − h) h2 000
f 0 ( a) = − f (ξ )
2h 6
In a computer, during calculation, to model the roundoff, we use,
f ( a + h) + R+ instead of f ( a + h)
(9.7)
f ( a − h) + R− instead of f ( a − h)
Therefore,
0 f ( a + h) + R+ − f ( a − h) − R−
f comp =
2h (9.8)
f ( a + h) − f ( a − h) R+ − R−
= +
2h 2h
Hence,
R+ − R− h2 000
f 0 ( a) = f comp
0
− − f (ξ ) (9.9)
2h
| {z } 6
| {z }
Round-Off Error Discretization Error
0 h2 00
f ( x + h) = f ( x ) + h f ( x ) + f (ξ )
2
where ξ ∈ ( x, x + h) and f 00 ∈ C2 [( x, x + h)]. We can rewrite the above
equation as the following,
f ( x + h) − f ( x ) h 00
f 0 (x) = − f (ξ )
h 2
Now note that the first term in the above equation is just the forward-
difference equation (Example 1)! Thus if we neglect the higher order
term, thus we get an approximation of f 0 as,
f ( x + h) − f ( x )
f 0 (x) ≈ (9.10)
h
? The neglected higher order term − 2h f 00 (ξ ) is called the Truncation Er-
ror (T.E.).
h2 00
f ( x − h) = f ( x ) − h f 0 ( x ) + f (ξ )
2
Thus, we get the following formula for approximating f ( x ),
f ( x ) − f ( x − h)
f 0 (x) ≈ (9.11)
h
which is called backward-difference formula.
h2 00 h3 000
f ( x + h) = f ( x ) + h f 0 ( x ) + f (x) + f (ξ 1 )
2 6 (9.12)
h2 h3 000
f ( x − h) = f ( x ) − h f 0 ( x ) + f 00 ( x ) − f (ξ 2 )
2 6
f ( x + h) − f ( x − h) h2 000
f 0 (x) = − [ f (ξ 1 ) + f 000 (ξ 2 )] (9.13)
2h 12
Assuming f 000 ∈ C ([ x − h, x + h]), there exists some point ξ ∈ [ x − h, x + h]
such that,
1
f 000 (ξ ) = [ f 000 (ξ 1 ) + f 000 (ξ 2 )]
2
000
With the above f (ξ ), we can write Eq. 9.13 as,
f ( x + h) − f ( x − h) h2 000
f 0 (x) = − f (ξ ) (9.14)
2h 6
Thus, if we neglect the higher-order term, then,
f ( x + h) − f ( x − h)
f 0 (x) ≈ (9.15)
2h
which is the central-difference formula as in Example 1.
It should be clear now that we can extend the above calculation to even
more higher order derivatives. For example, if we extend the taylor’s the-
orem to fourth order derivatives,
h2 00 h3 000 h 4 (4)
f ( x + h) = f ( x ) + h f 0 ( x ) + f (x) + f (x) + f (ξ 1 )
2 6 24 (9.16)
h2 h3 000 h 4 (4)
f ( x − h) = f ( x ) − h f 0 ( x ) + f 00 ( x ) − f (x) + f (ξ 2 )
2 6 24
Again, adding the above two equations leads us to,
f ( x + h ) − 2 f ( x ) + f ( x − h ) h 2 (4)
f 00 ( x ) ≈ − f (ξ ) (9.17)
h2 24
for some ξ ∈ ( x − h, x + h). Then again, the approximate formula of f 00 ( x )
is,
f ( x + h) − 2 f ( x ) + f ( x − h)
f 00 ( x ) ≈ (9.18)
h2
and the Truncation Error is O(h2 ).
Numerical Integration
This can be alternatively stated as the task of finding a function F ( x ) such that
F 0 ( x ) = f ( x ). Then, we would have,
Z b
f ( x )dx = F (b) − F ( a)
a
Note that there are a lots of functions whose anti-derivative are very diffi-
cult to compute, for example the following,
Z 2 Z 1 Z π
− x2 x
e dx , sin( xe )dx , cos(3 cos θ )dθ
0 0 0
A very basic question that may arise in the reader’s mind is that if we
are given values of a function f ( x ) at a few points, say x0 , x1 , . . . , xk , then
can that information be used to estimate
Z b
f ( x )dx an integral ?
a
75
Scientific Computing 76
Surprisingly, the answer is yes! It comes from the same idea that we used
in numerical differentiation, of that of approximating the function f by
pk , i.e.
Z b
I ( f ) ≈ I ( pk ) = pk ( x )dx (10.1)
a
where pk ( x ) is the polynomial of degree ≤ k with
pk ( xi ) = f ( xi ) , i = 0, . . . , k (10.2)
E( f ) = I ( f ) − I ( pk )
I ( p k ) = A0 f ( x0 ) + A1 f ( x1 ) + · · · + A k f ( x k ) (10.3)
where Ai are the weights and f ( xi )’s are the functional values.
f ( x ) = pk ( x ) + f [ x0 , . . . , xk , x ]ψk ( x )
| {z }
Error Term
pk ( x ) = f ( x0 ) + f [ x0 , x1 ]( x − x0 ) + f [ x0 , x1 , x2 ]( x − x0 )( x − x1 ) + . . .
+ f [ x0 , x1 , . . . , xk ]( x − x0 )( x − x1 ) . . . ( x − xk−1 )
k
ψk ( x ) = ∏( x − x j )
j =0
x=a x=b
f(x)
P_1
f
a b
Let k = 2. Then
f ( x ) ≈ p2 ( x )
a+b
If we choose x0 = a, x1 = 2 and x2 = b, then the interpolating polyno-
mial p2 ( x ) is in the form,
a+b
p2 ( x ) = f ( a) + f [ a, b]( x − a) + f a, b, ( x − a)( x − b)
2
P_2
a (a+b)/2 b
( b − a )2
Z b
a+b
I ( f ) ≈ I ( p2 ) = f ( a)(b − a) + f [ a, b] + f a, b, ( x − a)( x − b)dx
2 2 a
( b − a )2 a + b ( b − a )3
= f ( a)(b − a) + f [ a, b] + f a, b,
2 2 6
a+b
f (b) − f ( a) f ( b ) − f 2 + f ( a )
= (b − a) f ( a) + −2
2 6
b−a
a+b
= f ( a) + 4 f + f (b)
6 2
(10.7)
b−a
a+b
I( f ) ≈ S = f ( a) + 4 f + f (b) (10.8)
6 2
f ( x ) ≈ p3 ( x )
a b
for some ξ ∈ ( a, b). If f ( x ) ∈ C k+1 ( a, b), then it follows that the error by
Theorem 8.9 is,
Z b
1
E( f ) = f ( k +1) ( η ) ψk ( x )dx for some η ∈ ( a, b) (10.10)
( k + 1) ! a
a+b
For that, if we introduce another point x1 = 2 , then
a+b 2
ψ1 ( x ) = ( x − x1 )ψ0 ( x ) = ( x − )
2
is of one sign. Thus, by Eq. 10.14, we get,
f 00 (η )(b − a)3
EM = for some η ∈ ( a, b) (10.16)
24
f 00 (η ) f 00 (η )(b − a)3
Z b
ET = ( x − a)( x − b)dx = for some η ∈ ( a, b)
2 a 12
(10.17)
Now note that in ( a, b), the sign of ψ2 ( x ) is NOT same. But still, note that,
Z b Z b
a+b
ψ2 ( x )dx = ( x − a)( x − b) x − dx = 0
a a 2
Hence we can use the second method in this case! For that all, we need
to find is another point x3 such that ψ3 ( x ) should be of same sign in ( a, b).
We can clearly see intuitively that this would contain heavy amount of er-
ror. This was also confirmed by error analysis and Eq. 10.15. It grows
quadratically with the size of interval ( a, b).
Set,
f i = f ( xi ) = f ( a + ih) , i = 0, . . . , N
and,
h
f i − 1 = f ( x i − ).
2 2
Now, simply apply the Rectangular Rule on each subinterval to get,
f 0 (ηi )( xi − xi−1 )2
Z xi
f ( x )dx = ( xi − xi−1 ) f ( xi−1 ) +
x i −1 | 2
{z }
Error Term (Eq. 10.15)
f 0 (η i ) h2
= h f ( x i −1 ) +
2
Summing from i = 1 to i = N, we obtain,
N N
f 0 ( ηi ) h 2
Z b
I( f ) = f ( x )dx = h ∑ f i−1 + ∑ R
= R N + EN (10.20)
a i =1 i =1
2
M f 00 (ξ )(b − a)h2
EN = (10.23)
24
T f 00 (η )(b − a)h2
EN =− (10.25)
12
h h2 (10.29)
≈ [ f ( x0 ) + f ( x1 )] + [ f 0 ( x0 ) − f 0 ( x1 )]
2 12
h h2 0
+ · · · + [ f ( x N −1 ) + f ( x N )] + [ f ( x N −1 ) − f 0 ( x N )]
2 12
Now note that all the interior derivatives form a telescopic series, thus can-
celling each other except the first and the last terms. Thus, the Composite
I ( f ) ≈ A0 f ( x0 ) + A1 f ( x1 ) + · · · + A k f ( x k ) (10.32)
I ( f ) ≈ (b − a) f ( x ) (Rectangle Rule)
(b − a)
I( f ) ≈ [ f ( a) + f (b)] (Trapezoidal Rule)
2
(b − a)
a+b
I( f ) ≈ f ( a) + 4 f + f (b) (Simpson’s Rule)
6 2
To discuss the Gaussian Rules in the more general context, we write the
integral as
Z b Z b
f ( x )dx = w( x ) g( x )dx
a a
We can clearly see in the above equations that the nodes x j and weights A j
are to be chosen so that Ik ( g) equals I ( g) exactly for polynomials g( x ) of as
higher degree as possible. This is indeed the basic idea behind the Gaussian
Rule.
R1
10.4.1 Special case when w( x ) = 1 and −1
g( x )dx ≈ ∑kj=0 A j g( x j )
In this case, we define the Error as,
Z 1 k
Ek ( g) = g( x )dx − ∑ A j g( x j ) (10.33)
−1 j =0
Now the task is to determine the weights A j and nodes x j to make the
error 0, i.e.
Ek ( g) = 0 (10.34)
for as high a degree polynomial g( x ) as possible.
Note that,
Ek ( a0 + a1 x + · · · + an x m ) = a0 Ek (1) + a1 Ek ( x ) + · · · + am Ek ( x m ) (10.35)
For k = 0
We have,
Z 1
g( x )dx ≈ A0 g( x0 )
−1
Z 1
g( x )dx ≈ 2g(0)
−1
For k = 1
We have,
Z 1
g( x )dx ≈ A0 g( x0 ) + A1 g( x1 )
−1
Thus we require,
Z 1
Ek (1) = 0 =⇒ dx − A0 − A1 = 0 =⇒ A0 + A1 = 2
−1
Z 1
Ek ( x ) = 0 =⇒ xdx − ( A0 x0 + A1 x1 ) = 0 =⇒ A0 x0 + A1 x1 = 0
−1
Z 1
2
Ek ( x2 ) = 0 =⇒ x2 dx − ( A0 x02 + A1 x12 ) = 0 =⇒ A0 x02 + A1 x12 =
−1 3
Z 1
Ek ( x3 ) = 0 =⇒ x3 dx − ( A0 x03 + A1 x13 ) = 0 =⇒ A0 x03 + A1 x13 = 0
−1
(10.38)
On solving, we get,
A0 = 1
A1 = 1
1
x0 = √
3
1
x1 = − √
3
This leads to the formula,
Z 1
1 1
g( x )dx ≈ g √ + g −√
−1 3 3
For a general k
There are 2k + 2 parameters, weights {wi }ik=0 and nodes { xi }ik=0 , to be de-
termined.
Ek ( xi ) = 0 , i = 0, 1, . . . , 2k + 1 (10.39)
This leads to the following set of equations:
(
k
0 i = 1, 3, . . . , 2k + 1.
∑ A j xij = 2
i = 0, 2, . . . , 2k.
(10.40)
j =0 i +1
However, note that the equations in Eq. 10.40 are non-linear equations and
their solvability is not at all obvious. For that, we may have the following
alternative
p k ( x ) = g ( x0 ) L0 ( x ) + g ( x1 ) L1 ( x ) + · · · + g ( x k ) L k ( x )
with,
k (x − xj )
Li ( x ) = ∏ ( x i − x j )
, i = 0, . . . , k
j=0,i 6= j
I ( p k ) = A0 g ( x0 ) + A1 g ( x1 ) + · · · + A k g ( x k ) (10.42)
Now, for the error term, using the property of orthogonal polynomials,
for many w( x ), we can find a polynomial Pk+1 ( x ) such that,
Z b
Pk+1 ( x )q( x )w( x )dx = 0 (10.44)
a
Pk+1 ( x ) = αk+1 ( x − ξ 0 )( x − ξ 1 ) . . . ( x − ξ k )
But we see that determining Pk+1 ( x ) is not at all obvious. One thing we
can do, however, is to choose the orthogonal polynomials Pk+1 to be Leg-
endre Polynomials! But the Legendre polynomials are only defined over
Rb
(−1, 1). Thus, one needs to transform original integral a f ( x )dx over the
R1
limits −1 and 1 to write −1 g(τ )dτ. This can be done using the following
change of variable,
(b − a)t + (b + a)
x=
2
Now, we can use the argument above to, for any k, construct the Orthogo-
nal Legendre Polynomials, find it’s roots ξ i , subsequently exactly calculate
the integral by Eq. 10.42, 10.43 and xi = ξ i .
Clearly, before jumping into the numerical techniques, we must first make
sure concretely that the question we are trying to solve indeed has a solu-
tion and that the solution is unique. To that extent, for IVP in Eq. 11.1, we
have the following theorem,
93
Scientific Computing 94
( x − x0 )2 00
y ( x ) = y ( x0 ) + ( x − x0 ) y 0 ( x0 ) + y ( x0 ) + . . .
2!
h2 00
= y0 + hy0 ( x0 ) + y ( x0 ) + . . .
2!
where x − x0 = h. If f is sufficiently differentiable with respect to x and
y, we can compute,
y0 = f ( x, y)
y00 = f 0 = f x + f y y0 = f x + f y f
y000 = f 00 = f xx + f xy f + f yx f + f yy f 2 + f y f x + f y2 f
and so on . . .
yn ≈ y( xn )
y0 = f ( x, y) , y( x0 ) = y0
xn = x0 + nh , n = 0, 1, . . . , N
yn+1 = yn + hTk ( xn , yn ) , n = 0, 1, . . . , N − 1
where Tk is,
h 0 h k −1 ( k −1)
Tk ( x, y) = f ( x, y) + f ( x, y) + . . . f ( x, y) , k = 1, 2, . . .
2! k!
So we are basically truncating the Taylor series to kth order and take
the h common out from them as y0 = f .
h k +1 ( k ) h k +1 ( k +1)
E= f (ξ, y(ξ )) = y (ξ ) , xn < ξ < xn + h (11.2)
( k + 1) ! ( k + 1) !
y n +1 = y n + h f ( x n , y n ) (11.3)
h2 00
E= y (ξ ) (11.4)
2
y0 = f ( x, y) , y( x0 ) = y0
hM h ( xn − x0 ) L i
| en | ≤ e −1
2L
This theorem shows that the error is O(h) and en → 0 as h → 0.
To that extent, the Runge-Kutta Method plays a major step. In this method,
we seek a formula of the form,
h2 00 h3
y( xn+1 ) = y( xn + h) = y( xn ) + hy0 ( xn ) + y ( xn ) + y000 ( xn ) + . . .
2 6
h2
= y( xn ) + h f ( xn , yn ) + ( f x + f y f )n
2
h 3
+ ( f xx + 2 f xy f + f yy f 2 + f y f x + f y2 f )n + O(h4 )
6
(11.6)
k2 α2 h2
= f ( xn + αh, yn + βk1 ) = f ( xn , yn ) + αh f x + βk1 f y + f xx
h 2 (11.7)
β2 k21
+ (αhβk1 ) f xy + f yy + O(h3 )
2
where all derivatives are evaluated at ( xn , yn ). Substituting the expression
for k2 above in Eq. 11.5 and using k1 = h f ( xn , yn ), we get upon rearrange-
ment in powers of h that,
a+b = 1
1
bα = bβ =
2
Note that there are many solutions to the above system, the simplest per-
haps being,
1
a=b=
2
α=β=1
y0 = f ( x, y) , y( x0 ) = y0
1
y n +1 = y n + ( k 1 + k 2 )
2
k1 = h f ( xn , yn ) (11.9)
k2 = h f ( xn + h, yn + k1 )
Also, the local error is of the form (refer Eq. 11.6 and Eq. 11.8)
h3
y ( x n +1 ) − y n +1 = ( f xx + 2 f xy f + f yy f 2 + f y f x + f y2 f ) + O(h4 )
12 (11.10)
= O ( h3 )
Note that the this method thus takes average slope between two points
as the quantity to add to current estimate at the previous point h distance
away.
y0 = f ( x, y) , y( x0 ) = y0
1
yn+1 = yn + (k1 + 2k2 + 2k3 + k4 )
6
k1 = h f ( xn , yn )
h k
k2 = h f ( xn + , yn + 1 ) (11.11)
2 2
h k2
k3 = h f ( xn + , yn + )
2 2
k4 = h f ( xn + h, yn + k3 )
Also, the Local Discretization Error would be of order O(h5 ) (Eq. 11.6 &
Eq. 11.8).
y( N ) ( x ) = f ( x, y( x ), y0 ( x ), . . . , y( N −1) ( x )) (11.12)
y10 = y2
y20 = y3
y30 = y4
.. (11.13)
.
y0N −1 = y N
y0N = f ( x, y1 , y2 , . . . , y N )
y10 = f 1 ( x, y1 , y2 , . . . , y N )
y20 = f 2 ( x, y1 , y2 , . . . , y N )
.. (11.14)
.
y0N = f N ( x, y1 , y2 , . . . , y N )
y0 = f ( x, y, z)
(11.15)
z0 = g( x, y, z)
Algorithm :
1. Set xn = x0 + nh where n = 0, 1, . . . .
1
yn+1 = yn + (k1 + 2k2 + 2k3 + k4 )
6 (11.16)
1
zn+1 = zn + (l1 + 2l2 + 2l3 + l4 )
6
where,
k1 = h f ( xn , yn , zn )
l1 = hg( xn , yn , zn )
h k1 l1
k2 = h f xn + , yn + , zn +
2 2 2
h k1 l1
l2 = hg xn + , yn + , zn +
2 2 2
(11.17)
h k2 l2
k3 = h f xn + , yn + , zn +
2 2 2
h k2 l2
l3 = hg xn + , yn + , zn +
2 2 2
k4 = h f ( xn + h, yn + k3 , zn + l3 )
l4 = hg ( xn + h, yn + k3 , zn + l3 )
y0 = f ( x, y) , y( x0 ) = y0 (12.1)
Z x n +1 Z x n +1
0
y dx = f ( x, y( x ))dx
xn xn
Z x n +1 (12.2)
=⇒ y n +1 = y n + f ( x, y( x ))dx
xn
as we don’t have any information about the RHS integral, thus we now
simply approximate f ( x, y( x )) by a polynomial pm ( x ) which interpo-
lates f ( x, y( x )) at the m + 1 points xn , xn−1 , xn−2 , . . . , xn−m seen previ-
ously. Set,
f ( xk , y( xk )) = f k
101
Scientific Computing 102
Inserting this equation into the integral in Eq. 12.2 and noting that hds =
dx and also appropriately changing the limits, we get,
Z 1 m
−s k
y n +1 = y n + h ∑
0 k =0 k
∆ f n−k
= yn + h [γ0 f n + γ1 ∆ f n−1 + · · · + γm ∆m ]
(12.4)
where,
Z 1
k −s
γk = (−1) ds
0 k
The Eq. 12.4 is called the Adams-Bashford Method.
• On the other hand, the Multi-Step formula require only one deriva-
tive evaluation per step, compared with four evaluations per step
with Runge-Kutta methods and is therefore considered faster and
requires less computational load.
(0)
Then, compute f ( xn+1 , yn+1 ) and obtain the following approximation,
(1) hh (0)
i
y n +1 = y n + f ( x n , y n ) + f ( x n +1 , y n +1 )
2
(1) (2)
Continue the iteration to calculate f ( xn+1 , yn+1 ) and obtain yn+1 as,
(2) hh (1)
i
y n +1 = y n + f ( x n , y n ) + f ( x n +1 , y n +1 )
2
In general, the iteration is given by,
(k) hh ( k −1)
i
y n +1 = y n + f ( xn , yn ) + f ( xn+1 , yn+1 ) , k = 1, 2, . . .
2
This leads us to the following algorithm.
y0 = f ( x, y) , y( x0 ) = y0
(0)
y n +1 = y n + h f ( x n , y n )
(k)
2. Compute yn+1 where k = 1, 2, . . . , using,
(k) hh ( k −1)
i
y n +1 = yn + f ( x n , y n ) + f ( x n +1 , y n +2 )
2
iterating on k untill
(k) ( k −1)
y n +1 − y n +1
(k)
<e
y n +1
Remarks:
(k)
Proof : Observe that with xn fixed and setting yn+1 = Y (k) , we can write
the iteration in Eq. 12.5 in the form,
(k) ( k −1)
Y =F Y
h
where F (Y ) = 2 f ( xn+1 , Y ) + C. Here C depends on n not on Y.
Now, consider the above equation as the fixed point iteration with iter-
ation function F (Y ). Now, since we know that this would converge when,
0
F (Y ) < 1 ∀ Y with |Y − yn+1 | < |Y (0) − yn+1 |
QED.
y0 = f ( x, y) , y( x0 ) = y0
(0) h
y n +1 = y n + (55 f n − 59 f n−1 + 37 f n−2 − 9 f n−3 ) , n = 3, 4, . . .
24
(0) (0)
2. Compute f n+1 = f ( xn+1 , yn+1 ).
(k) h ( k −1)
y n +1 = yn + 9 f ( xn+1 , yn+1 ) + 19 f n − 5 f n−1 + f n−2 k = 1, 2, . . .
24
4. Iterate on k until,
(k) ( k −1)
y n +1 − y n +1
(k)
< e , for prescribed tolerance e
y n +1
y0 = f ( x, y) , y( x0 ) = y0
1 This section contains some details which are rigorously explained in the following
chapter.
Now, using the mid-point rule for the integral on RHS leads to the fol-
lowing multi-step method,
yn+1 = yn−1 + 2h f n (12.8)
Since we want to focus on the stability of this multistep method, thus, for
the instance, let us consider the following problem as an example,
y0 = −2y + 1 , y(0) = 1 (12.9)
The exact solution of this can be found to be simply,
1 −2x 1
y( x ) =
e + (12.10)
2 2
Applying the multi-step method with f n = f ( xn , yn ) = −2y + 1 (Eq. 12.8),
we get,
yn+1 + 4hyn − yn−1 = 2h , y0 = 1
X Following the method to solve a Linear Difference Equation in the next
chapter, we find the characteristics polynomial is (for general solution),
β2 + 4hβ − 1 = 0
which gives us,
p p
β 1 = −2h + 1 + 4h2 β 2 = −2h − 1 + 4h2
√
Now, expanding 1 + 4h2 using Taylor Series gets us,
β 1 ≈ 1 − 2h + O(h2 ) and β 2 = −1 − 2h + O(h2 )
Note the particular solution is simply ynPS = 21 , thus the general solution is
simply (refer Chapter 13 for more details),
1
yn = C1 (1 − 2h + O(h2 ))n + C2 (−1 − 2h + O(h2 ))n + (12.11)
2
xn
Note that n = h as x0 = 0. Thus for fixed xn , we have this important
observation,
1
lim (1 + 2h)n = lim (1 + 2h) 2h 2xn = e2xn
h→∞ h→∞
n −2xn
Similarly, lim (1 − 2h) = e
h→∞
Hence, in the limit h → 0, the solution of Eq. 12.9 as written in eq. 12.11
becomes,
−2xn 1
yn = C1 e + + C2 (−1)n e2xn (12.12)
2
Remarks:-
• Note that the first term tends to the true solution (Eq. 12.11) of
the differential equation. The second term is extraneous and arises
only because we have replaced a first-order difference equation by
a second-order difference equation!
Now, for a general case, suppose that a multi-step method leads to a dif-
ference equation of order k whose characteristics equation is,
β k + a k −1 β k −1 + · · · + a 0 = 0 (12.13)
? Now, one of these solutions, say βn1 , will tend to the exact solution of
the differential equation as h → 0. All the other solutions ( βn2 , . . . , βnk )
are thus extraneous. We hence arrive at the following definition.
| β i | < 1 , i = 2, 3, . . . , k
It’s trivial to see that if | β i | > 1 for any i = 2, 3, . . . , k, then the errors will
grow exponentially.
h
y n +1 = y n −1 + ( f n +1 + 4 f n + f n −1 )
3
Moreover, for small h, the roots of the stability polynomial Eq. 12.14 is,
β 1 = 1 + λh + O(h2 )
λh
β2 = − 1 − + O ( h2 )
3
The general solution is thus,
n
2 n n λh
yn = c1 (1 + λh + O(h )) + c2 (−1) 1− + O ( h2 ) (12.15)
3
xn
Set n = h and let h → 0, the solution thus approaches,
λxn
yn = c1 eλxn + c2 (−1)n e− 3
| {z } | {z }
yd,n ( x ) ye,n ( x )
? Remarks :
• If λ > 0, the desired solution yd,n ( x ) is exponentially increasing
and the extraneous solution ye,n ( x ) is exponentially decreasing. In
that case, the Milne’s method would be stable, NOT strongly stable
though.
• On the other hand, if λ < 0, then Milne’s method would be unstable
as the extraneous solution ye,n ( x ) would be increasing exponentially.
• Methods of this type whose stability depends on the the sign of λ for
the test equation y0 = λy are said to be weakly stable.
y n + N + a N − 1 y n + N − 1 + a N − 2 y n + N − 2 + · · · + a 0 y n = bn (13.1)
β n + N + a N −1 β n + N −1 + · · · + a 0 β n = 0
Thus,
p ( β ) = β N + a N −1 β N −1 + · · · + a 0 = 0 (13.2)
which is known as characteristics equation.
Now with regards to the characteristics equation in Eq. 13.2, we can have
following cases,
111
Scientific Computing 112
β 1 = reiθ
(13.4)
β 2 = re−iθ
where r = α2 + β2 and θ = tan−1 α . Thus, the general solution
p β
CASE III : If β 1 is a double root of the characteristic equation Eq. 13.2, then a second
solution of the homogeneous LDE is nβn1 .
y n + N + a N − 1 y n + N − 1 + · · · + a 0 y n = bn (13.6)
yn = ynGS + ynPS
where ynGS is the General Solution of the Homogeneous LDE (i.e. for
bn = 0) and ynPS is the particular solution of the Eq. 13.6.
Note that in the special case that bn = b is a constant, one can find partic-
ular solution by simply substituting ynPS = A (a constant). This constant
would be simply,
b
A=
1 + a N −1 + · · · + a 0
provided, of-course, 1 + a N −1 + · · · + a0 6= 0.
We can classify the PDE 14.1 on the basis of the coefficients as follows,
• Elliptic : when b2 − 4ac < 0.
• Parabolic : when b2 − 4ac = 0.
• Hyperbolic : when b2 − 4ac > 0.
The above classification occur many times in real world as the following
examples show.
115
Scientific Computing 116
∂U ∂2 U
=κ 2
∂t ∂x
∂2 U 2
2∂ U
= c
∂t2 ∂x2
x n − x0
be a partition of [ a, b] such that xn = x0 + nh, where h = n is the dis-
cretization parameter.
Set xi = x0 + ih , i = 0, 1, . . . , n and Ui = U ( xi ).
0 h2 00 h3 000
U ( x + h) = U ( x ) + hU ( x ) + U ( x ) + U ( x ) + . . . (14.2)
2 6
h2 00 h3
U ( x − h) = U ( x ) − hU 0 ( x ) + U ( x ) − U 000 ( x ) + . . . (14.3)
2 6
Now,
dU U ( xi + h ) − U ( xi )
= + O(h) (From 14.2)
dx x= xi
h
U − Ui
≈ i +1 (Forward difference formula)
h
U ( xi ) − U ( xi − h )
= + O(h) (From 14.3)
h (14.4)
Ui − Ui−1
≈ (Backward difference formula)
h
U ( xi + h ) − U ( xi − h )
= + O(h2 ) (From Eq. 14.2 - 14.3)
2h
U − Ui−1
≈ i +1 (Central difference formula)
2h
d2 U
U ( xi + h) − 2U ( xi ) + U ( xi − h)
2
= 2
+ O(h2 ) (From Eq. 14.2 + 14.3)
dx x= xi
h
U − 2Ui + Ui−1
≈ i +1
h2
(14.5)
xi = ih , i = 0, 1, 2, . . . , N with x0 = 0 , x N = a
(14.6)
t j = jk , i = 0, 1, 2, . . . , J with t0 = 0 , t J = b
Ui+1,j − Ui,j
∂U
= + O(h)
∂x ( xi ,t j ) h
Ui,j − Ui−1,j
= + O(h)
h
Ui+1,j − Ui−1,j
= + O ( h2 )
2h
Ui,j+1 − Ui,j
∂U
= + O(k)
∂t ( xi ,t j ) k
(14.8)
Ui,j − Ui,j−1
= + O(k)
k
Ui,j+1 − Ui,j−1
= + O ( k2 )
2k
∂2 U Ui+1,j − 2Ui,j + Ui−1,j
= + O ( h2 )
∂x2 ( xi ,t j ) h 2
We now use the above technique for solving some application based prob-
lems in the next few sections.
∂U ∂2 U
= x ∈ (0, 1) , t > 0
∂t ∂x2
(14.9)
U (0, t) = U (1, t) = 0 , t > 0 (Boundary Condition)
U ( x, 0) = f ( x ) , 0 ≤ x ≤ 1 (Initial Condition)
Set xi = ih , i = 0, 1, 2, . . . and t j = jk , j = 0, 1, 2, . . . .
Let Uij be the true value of the solution at the grid point ( xi , t j ).
Figure 14.1: Computational Stencils for various schemes for Heat Equa-
tion.
ui,j+1 − ui,j
∂U
≈
∂t ( xi ,t j ) k
(14.10)
∂2 U ui+1,j − 2ui,j + ui−1,j
≈
∂x2 ( xi ,t j ) h2
With the above approximations to the derivatives, the heat equation 14.9
would thus yield to the following,
ui,j+1 − ui,j ui+1,j − 2ui,j + ui−1,j
=
k h2
which on simplification gives,
Remarks:
• It is a two level explicit system as the solution at the jth level is only
computed by values at the j − 1th level.
• This scheme is conditionally stable when 0 < r ≤ 21 (will be proved
soon).
• The local truncation error is O(h2 ) + O(k ) as seen from Eq. 14.9.
• This scheme is unconditionally stable, that is, it’s stable for all val-
ues of r.
ui,j+1 − ui,j
∂U
≈ (From Eq. 9.15)
∂t xi ,t k
j+ 21
(14.14)
Thus the Heat equation gives us,
Remarks:
Thus, we can write the explicit scheme for heat equation as,
and finally,
1 1
δt ui,j+ 1 = 2 δx2 ui,j (14.24)
k 2 h
Note that using the definitions in Eq. 14.23, you can write the Euler’s
Implicit scheme as,
1 1
δt ui,j− 1 = 2 δx2 ui,j (14.25)
k 2 h
the Crank-Nicolson scheme,
1 1 h i
δt ui,j+ 1 = 2 δx2 ui,j+1 + δx2 ui,j (14.26)
k 2 2h
and finally, the Weighted Average scheme,
1 1 h i
δt ui,j+ 1 = 2 θδx2 ui,j+1 + (1 − θ )δx2 ui,j (14.27)
k 2 h
Let
L (U ) = 0 (14.28)
represent the partial differential equation in the independent variables x
and t with exact solution U. Let,
represent the finite difference equation approximation for the PDE at (i, j)th
mesh point with exact solution u.
The local truncation error Ti,j (U ) at the point (ih, jk) is defined by
as L(Ui,j ) = 0. Thus, Ti,j gives an indication of the error resulting from the
replacement of L(Ui,j ) by Fi,j (U ). We hence arrive at the following defini-
tion,
Example. To illustrate the use of this definition, let us, for example, con-
sider the local truncation error Ti,j of the two level explicit scheme approx-
imating Ut = Uxx at the point (ih, jk).
∂U ∂2 U
2
1 2 ∂4 U 1 2 ∂3 U 1 4 ∂6 U
1 ∂ U
Ti,j = − 2 + k − h + k − h +...
∂t ∂x i,j 2 ∂t2 i,j 12 ∂x4 i,j 6 ∂t3 i,j 360 ∂x6 i,j
∂2 U
Note that since ∂U∂t − ∂x2
= 0, the major contribution to the local trun-
i,j
cation error happen only through the following term,
2
1 2 ∂4 U
1 ∂ U
k − h
2 ∂t2 i,j 12 ∂x4 i,j
Ti,j → 0 as h → 0 and k → 0
Thus, the explicit scheme approximating the heat equation in Eq. 14.11 is
consistent with the heat equation.
14.4 Stability
Definition : Stability is related to the round-off error. We say that the scheme
is stable if the round-off error in the numerical process is bounded.
L(U ) = 0 in R
xi = ih , i = 0, 1, . . . , N with Nh = 1
t j = jk , j = 0, 1, . . . , N with Jk = T
bi−1 ui−1,j+1 + bi ui,j+1 + bi+1 ui+1,j+1 = ci−1 ui−1,j + ci ui,j + ci+1 ui+1,j
(14.32)
where bi ’s and ci ’s are constants.
Now, suppose that the boundary values u0,j and u N,j for j > 0 are known.
e j = u∗j − u j = A(u0∗ − u0 ) = A j e0
Note that,
ke j k = kA j e0 k ≤ kA j kke0 k (14.37)
Now if there exists a positive number M, independent of j, h and k such
that kA j k ≤ M, then it’s easy to see that,
k e j k ≤ M k e0 k
k e j k ≤ k A k j k e0 k
kAk ≤ 1 (14.38)
This is the necessary and sufficient condition for the difference equations
to be stable when the solution of the PDE does not increase as t increases.
kAxk
kAk = max = max kAxk
x 6 =0 kxk k x k=1
Avi = λ i vi
=⇒ kAvi k = kλi vi k = |λi |kvi k
=⇒ |λi |kvi k = kAvi k ≤ kAkkvi k
=⇒ |λi | ≤ kAk , i = 1, . . . , N (14.40)
=⇒ max|λi | ≤ kAk
i
or, ρ(A) ≤ kAk
where ρ(A) is called the spectral radius and is the largest eigenvalue
of matrix A.
√
sπ
λs = a + 2 bc cos , s = 1, . . . , n (14.41)
n+1
where a, b, c ∈ R.
Note that,
kAk∞ = r + 1 − 2r + r = 1
CASE II : 1 − 2r < 0 =⇒ r > 12 .
Therefore, |1 − 2r | = 2r − 1, and
kAk∞ = r + 2r − 1 + r = 4r − 1 > 1
Thus, the scheme is stable only for 0 < r ≤ 21 . Note that since A is real
and symmetric,
kAk = ρ(A) = max|µs |
s
We can do the same calculation in a more eigenvalue oriented one, i.e., de-
riving a general form of eigenvalue and using Lax-Richtemeyer condition
of stability in Eq. 14.42.
For this, first note that the matrix A can be rewritten as,
A = I N −1 + rT N −1
where,
1
1
I N −1 =
..
.
1
1
(14.44)
−2 1
1 −2 1
T N −1 =
. .
.
1 −2 1
1 −2
Now, a particular eigenvalue of A is just the sum of the corresponding
eigenvalues of I N −1 and T N −1 . Thus, we first need to find the eigenvalues
λs of T N −1 as the eigenvalues of I N −1 are trivially all 1.
sπ
λs = −2 + 2 cos (Eq. 14.41)
sπ N
= −4 sin2
2N
for s = 1, . . . , N − 1. Therefore, the eigenvalues of A are,
2 sπ
µs = 1 − 4r sin (14.45)
2N
Now, for the stability, ρ(|µs |) ≤ 1,
sπ
ρ(|µs |) = max1 − 4r sin2 ≤1 (14.46)
s 2N
1
r≤ (14.47)
2 ( N −1) π
2 sin 2N
( N −1) π
Hence, for h → 0, then N → ∞, which then implies that sin 2
2N →
1. Which implies that,
1
r≤ (14.48)
2
is the required condition for stability (conditionally).
Ut = Uxx , 0 ≤ x ≤ L , 0 < t ≤ T
(14.49)
U ( x, 0) = f ( x ) , 0 ≤ x ≤ L
? Express initial data by finite Fourier series along the initial mesh-
point at t = 0.
Define,
x p = ph , p = 0, 1, 2, . . . , N with Nh = L
tq = qk , q = 0, 1, 2, . . . , J with Jk = T (14.50)
u( x p , tq ) = u p,q = u( ph, qk )
With the above, first note that the Fourier Series terms at particular values
of x p are
iπnx p iπnph πn
An e L = An e Nh = An eiβ n ph where β n =
Nh
Now, at q = 0, i.e. t = t0 = 0,
N
u p,0 = u( ph, 0) = ∑ An eiβn ph
n =0
Using the given u p,0 at p = 0, 1, 2, . . . , N, the constants An can be uniquely
determined! But since this problem is a linear one, thus it is enough to
investigate the propagation of only one initial value, such as eiβph as sep-
arate solutions are additive. The coefficient An is a constant and can be
neglected for the growth analysis. Thus, we study,
u p,q = eiβph · eαqk = eiβph · ξ q (14.51)
ξ≤1 (14.53)
which is the necessary and sufficient condition for stability, or also called
the von Neumann stability condition.
Remarks:
We finally note the major theme of the whole discussion. Since from the
beginning, we wanted to find an approximation as close as possible to the
true solution of an PDE, we hence discuss the convergence of the finite dif-
ference approximation to the true solution, starting from the following
definition.
Definition : Let Ui,j be the exact solution of the PDE at the mesh point (ih, jk)
and let ui,j be it’s finite difference approximation at the same point. Then, we say
that ui,j converges to Ui,j if
ui,j − Ui,j → 0 as h → 0 and k → 0