Page 1
Chapter 7
Numerical Di?erentiation and Integration
Agivensetof (n+1)datapoints (x
i
,y
i
), i=0,1,2,...,nisassumedtorepresent
some function y = y(x). The data can come from some experiment or statistical
study, where y = y(x) is unknown, or the data can be generated from a known
function y = y(x). We assume the data points are equally spaced along the x-axis
so that x
i+1
-x
i
= h is a constant for i=0,1,2,...,n-1. In this chapter we develop
ways to approximate the derivatives of y = y(x) given only the data points. We
also develop ways to integrate the function y = y(x) based solely upon the data
points given.
Numerical Approximation for Derivative
To approximate the derivative function y
!
(x), evaluated at one of the given
data points (x
i
,y
i
),sayat x = x
m
, x
0
<x
m
<x
n
, we assume that the function y(x)
has a Taylor series expansion about the point x
m
given by either of the forms
y(x
m
+h)= y(x
m
)+y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
+y
!!!
(x
n
)
h
3
3!
+··· (7.1)
or
y(x
m
-h)= y(x
m
)-y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
-y
!!!
(x
m
)
h
3
3!
+··· (7.2)
By solving the equation (7.1) for the Þrst derivative one obtains the forward
derivative approximation
y
!
(x
m
)=
y(x
m
+h)-y(x
m
)
h
+O(h). (7.3)
Solving the equation (7.2) for the Þrst derivative gives the backward derivative
approximation
y
!
(x
m
)=
y(x
m
)-y(x
m
-h)
h
+O(h). (7.4)
Page 2
Chapter 7
Numerical Di?erentiation and Integration
Agivensetof (n+1)datapoints (x
i
,y
i
), i=0,1,2,...,nisassumedtorepresent
some function y = y(x). The data can come from some experiment or statistical
study, where y = y(x) is unknown, or the data can be generated from a known
function y = y(x). We assume the data points are equally spaced along the x-axis
so that x
i+1
-x
i
= h is a constant for i=0,1,2,...,n-1. In this chapter we develop
ways to approximate the derivatives of y = y(x) given only the data points. We
also develop ways to integrate the function y = y(x) based solely upon the data
points given.
Numerical Approximation for Derivative
To approximate the derivative function y
!
(x), evaluated at one of the given
data points (x
i
,y
i
),sayat x = x
m
, x
0
<x
m
<x
n
, we assume that the function y(x)
has a Taylor series expansion about the point x
m
given by either of the forms
y(x
m
+h)= y(x
m
)+y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
+y
!!!
(x
n
)
h
3
3!
+··· (7.1)
or
y(x
m
-h)= y(x
m
)-y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
-y
!!!
(x
m
)
h
3
3!
+··· (7.2)
By solving the equation (7.1) for the Þrst derivative one obtains the forward
derivative approximation
y
!
(x
m
)=
y(x
m
+h)-y(x
m
)
h
+O(h). (7.3)
Solving the equation (7.2) for the Þrst derivative gives the backward derivative
approximation
y
!
(x
m
)=
y(x
m
)-y(x
m
-h)
h
+O(h). (7.4)
Subtracting the equation (7.2) from the equation (7.1) gives
y(x
m
+h)-y(x
m
-h)=2y
!
(x
m
)+2y
!!!
(x
m
)
h
3
3!
+··· (7.5)
fromwhichonecanobtainthecentralderivativeapproximation
y
!
(x
m
)=
y(x
m
+h)-y(x
m
-h)
2h
+O(h
2
)(7.6)
which is more accurate than the results from equations (7.3) or (7.4). By using
Taylor series expansions one can develop a variety of derivative approximations.
Onecanderiveaderivativeapproximationforanyorderderivative. Consider
an approximation for the jth derivative
d
j
y
dx
j
x=x
i
= y
(j)
(x
i
), (7.7)
where j a positive integer. The derivative can be approximated by assuming the
derivative can be represented in the form
y
(j)
(x
i
)=
1
h
j
[ß
m
y(x
i
-mh)+ß
m-1
y(x
i
-(m-1)h)+···+ß
1
y(x
i
-h)
a
0
y(x
i
)+···+a
n-1
y(x
i
+(n-1)h)+a
n
y(x
i
+nh)]+O(h
N
)
(7.8)
involving (m + n+1) data points, where ß
m
,ß
m-1
,...,ß
1
,a
0
,a
1
,...,a
n
and N are
constants to be determined. Let y
i+j
= y(x
i
+jh) for the index j ranging over the
values j = -m,-(m- 1),...,(n- 1),n and expand these terms in a Taylor series
which are then substitute into the equation (7.8). One can then collect like
terms and force the right-hand side of equation (7.8) to equal the left-hand side
of equation (7.8) by setting certain coe?cients equal to either zero or one. This
will produce a system of equations where the coe?cients ß
m
,...,ß
1
,a
0
,...,a
n
and
the order N of the error term can be determined .
Example 7-1. (Derivative formula)
Derive a formula for the Þrst derivative of the form
y
!
(x
m
)=
1
h
[a
0
y
m
+a
1
y
m+1
+a
2
y
m+2
]+O(h
N
)(7.9)
where a
0
,a
1
,a
2
and N are constants to be determined.
Solution: Substitute the Taylor series expansions
y
m+1
= y(x
m
+h)=y(x
m
)+y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
+···
y
m+2
= y(x
m
+2h)=y(x
m
)+y
!
(x
m
)(2h)+y
!!
(x
m
)
(2h)
2
2!
+···
(7.10)
Page 3
Chapter 7
Numerical Di?erentiation and Integration
Agivensetof (n+1)datapoints (x
i
,y
i
), i=0,1,2,...,nisassumedtorepresent
some function y = y(x). The data can come from some experiment or statistical
study, where y = y(x) is unknown, or the data can be generated from a known
function y = y(x). We assume the data points are equally spaced along the x-axis
so that x
i+1
-x
i
= h is a constant for i=0,1,2,...,n-1. In this chapter we develop
ways to approximate the derivatives of y = y(x) given only the data points. We
also develop ways to integrate the function y = y(x) based solely upon the data
points given.
Numerical Approximation for Derivative
To approximate the derivative function y
!
(x), evaluated at one of the given
data points (x
i
,y
i
),sayat x = x
m
, x
0
<x
m
<x
n
, we assume that the function y(x)
has a Taylor series expansion about the point x
m
given by either of the forms
y(x
m
+h)= y(x
m
)+y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
+y
!!!
(x
n
)
h
3
3!
+··· (7.1)
or
y(x
m
-h)= y(x
m
)-y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
-y
!!!
(x
m
)
h
3
3!
+··· (7.2)
By solving the equation (7.1) for the Þrst derivative one obtains the forward
derivative approximation
y
!
(x
m
)=
y(x
m
+h)-y(x
m
)
h
+O(h). (7.3)
Solving the equation (7.2) for the Þrst derivative gives the backward derivative
approximation
y
!
(x
m
)=
y(x
m
)-y(x
m
-h)
h
+O(h). (7.4)
Subtracting the equation (7.2) from the equation (7.1) gives
y(x
m
+h)-y(x
m
-h)=2y
!
(x
m
)+2y
!!!
(x
m
)
h
3
3!
+··· (7.5)
fromwhichonecanobtainthecentralderivativeapproximation
y
!
(x
m
)=
y(x
m
+h)-y(x
m
-h)
2h
+O(h
2
)(7.6)
which is more accurate than the results from equations (7.3) or (7.4). By using
Taylor series expansions one can develop a variety of derivative approximations.
Onecanderiveaderivativeapproximationforanyorderderivative. Consider
an approximation for the jth derivative
d
j
y
dx
j
x=x
i
= y
(j)
(x
i
), (7.7)
where j a positive integer. The derivative can be approximated by assuming the
derivative can be represented in the form
y
(j)
(x
i
)=
1
h
j
[ß
m
y(x
i
-mh)+ß
m-1
y(x
i
-(m-1)h)+···+ß
1
y(x
i
-h)
a
0
y(x
i
)+···+a
n-1
y(x
i
+(n-1)h)+a
n
y(x
i
+nh)]+O(h
N
)
(7.8)
involving (m + n+1) data points, where ß
m
,ß
m-1
,...,ß
1
,a
0
,a
1
,...,a
n
and N are
constants to be determined. Let y
i+j
= y(x
i
+jh) for the index j ranging over the
values j = -m,-(m- 1),...,(n- 1),n and expand these terms in a Taylor series
which are then substitute into the equation (7.8). One can then collect like
terms and force the right-hand side of equation (7.8) to equal the left-hand side
of equation (7.8) by setting certain coe?cients equal to either zero or one. This
will produce a system of equations where the coe?cients ß
m
,...,ß
1
,a
0
,...,a
n
and
the order N of the error term can be determined .
Example 7-1. (Derivative formula)
Derive a formula for the Þrst derivative of the form
y
!
(x
m
)=
1
h
[a
0
y
m
+a
1
y
m+1
+a
2
y
m+2
]+O(h
N
)(7.9)
where a
0
,a
1
,a
2
and N are constants to be determined.
Solution: Substitute the Taylor series expansions
y
m+1
= y(x
m
+h)=y(x
m
)+y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
+···
y
m+2
= y(x
m
+2h)=y(x
m
)+y
!
(x
m
)(2h)+y
!!
(x
m
)
(2h)
2
2!
+···
(7.10)
into the assumed form for the derivative to obtain
y
!
m
=
1
h
!
a
0
y
m
+a
1
"
y
m
+y
!
m
h+y
!!
m
h
2
2
+···
#
+a
2
"
y
m
+y
!
m
(2h)+y
!!
m
(2h)
2
2
+···
#$
.
We collect like terms and write the above equation in the form
y
!
m
=
1
h
!
(a
0
+a
1
+a
2
)y
m
+(a
1
h+a
2
(2h))y
!
m
+(a
1
h
2
2
+a
2
(2h
2
))y
!!
m
+O(h
3
)
$
(7.11)
In order that the right-hand side of equation (7.11) reduce to y
!
m
we require the
unknown coe?cients to satisfy the equations
a
0
+ a
1
+ a
2
=0
a
1
+2a
2
=1
(1/2) a
1
+2a
2
=0.
(7.12)
We solve this system of equations and Þnd a
0
=-3/2, a
1
=2 and a
2
=-1/2.This
gives the derivative formula
y
!
(x
m
)=
-3y
m
+4y
m+1
-y
m+2
2h
+O(h
2
)(7.13)
wherethe 1/hfactorhassimpliÞedtheerrorterminequation(7.11). Byincluding
more terms in the expansions above one can determine the exact form for the
error term.
Example 7-2. (Derivative formula)
Derive an approximation formula for the second derivative of the form
y
!!
(x
m
)=
1
h
2
[ß
1
y
m-1
+a
0
y
m
+a
1
y
m+1
]+O(h
N
)(7.14)
where ß
1
,a
0
,a
1
and N are constants to be determined.
Solution: Substitute the Taylor series expansions given by equations (7.1) and
(7.2) into the equation (7.14) and then combine like terms to obtain
y
!!
(x
m
)=
1
h
2
[(ß
1
+a
0
+a
1
)y
m-1
+(a
0
h+a
1
(2h))y
!
m
+(a
0
h
2
/2+a
1
(2h
2
))y
!!
m
+(a
1
-ß
1
)y
!!!
m
h
3
3!
+(a
1
+ß
1
)y
(iv)
m
h
4
4!
+···
$
.
(7.15)
In order for the right-hand side of this equation to reduce to y
!!
m
we require the
coe?cients to satisfy the conditions
ß
1
+ a
0
+a
1
=0
a
0
+2a
1
=0
(1/2) a
0
+2a
1
=1
Page 4
Chapter 7
Numerical Di?erentiation and Integration
Agivensetof (n+1)datapoints (x
i
,y
i
), i=0,1,2,...,nisassumedtorepresent
some function y = y(x). The data can come from some experiment or statistical
study, where y = y(x) is unknown, or the data can be generated from a known
function y = y(x). We assume the data points are equally spaced along the x-axis
so that x
i+1
-x
i
= h is a constant for i=0,1,2,...,n-1. In this chapter we develop
ways to approximate the derivatives of y = y(x) given only the data points. We
also develop ways to integrate the function y = y(x) based solely upon the data
points given.
Numerical Approximation for Derivative
To approximate the derivative function y
!
(x), evaluated at one of the given
data points (x
i
,y
i
),sayat x = x
m
, x
0
<x
m
<x
n
, we assume that the function y(x)
has a Taylor series expansion about the point x
m
given by either of the forms
y(x
m
+h)= y(x
m
)+y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
+y
!!!
(x
n
)
h
3
3!
+··· (7.1)
or
y(x
m
-h)= y(x
m
)-y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
-y
!!!
(x
m
)
h
3
3!
+··· (7.2)
By solving the equation (7.1) for the Þrst derivative one obtains the forward
derivative approximation
y
!
(x
m
)=
y(x
m
+h)-y(x
m
)
h
+O(h). (7.3)
Solving the equation (7.2) for the Þrst derivative gives the backward derivative
approximation
y
!
(x
m
)=
y(x
m
)-y(x
m
-h)
h
+O(h). (7.4)
Subtracting the equation (7.2) from the equation (7.1) gives
y(x
m
+h)-y(x
m
-h)=2y
!
(x
m
)+2y
!!!
(x
m
)
h
3
3!
+··· (7.5)
fromwhichonecanobtainthecentralderivativeapproximation
y
!
(x
m
)=
y(x
m
+h)-y(x
m
-h)
2h
+O(h
2
)(7.6)
which is more accurate than the results from equations (7.3) or (7.4). By using
Taylor series expansions one can develop a variety of derivative approximations.
Onecanderiveaderivativeapproximationforanyorderderivative. Consider
an approximation for the jth derivative
d
j
y
dx
j
x=x
i
= y
(j)
(x
i
), (7.7)
where j a positive integer. The derivative can be approximated by assuming the
derivative can be represented in the form
y
(j)
(x
i
)=
1
h
j
[ß
m
y(x
i
-mh)+ß
m-1
y(x
i
-(m-1)h)+···+ß
1
y(x
i
-h)
a
0
y(x
i
)+···+a
n-1
y(x
i
+(n-1)h)+a
n
y(x
i
+nh)]+O(h
N
)
(7.8)
involving (m + n+1) data points, where ß
m
,ß
m-1
,...,ß
1
,a
0
,a
1
,...,a
n
and N are
constants to be determined. Let y
i+j
= y(x
i
+jh) for the index j ranging over the
values j = -m,-(m- 1),...,(n- 1),n and expand these terms in a Taylor series
which are then substitute into the equation (7.8). One can then collect like
terms and force the right-hand side of equation (7.8) to equal the left-hand side
of equation (7.8) by setting certain coe?cients equal to either zero or one. This
will produce a system of equations where the coe?cients ß
m
,...,ß
1
,a
0
,...,a
n
and
the order N of the error term can be determined .
Example 7-1. (Derivative formula)
Derive a formula for the Þrst derivative of the form
y
!
(x
m
)=
1
h
[a
0
y
m
+a
1
y
m+1
+a
2
y
m+2
]+O(h
N
)(7.9)
where a
0
,a
1
,a
2
and N are constants to be determined.
Solution: Substitute the Taylor series expansions
y
m+1
= y(x
m
+h)=y(x
m
)+y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
+···
y
m+2
= y(x
m
+2h)=y(x
m
)+y
!
(x
m
)(2h)+y
!!
(x
m
)
(2h)
2
2!
+···
(7.10)
into the assumed form for the derivative to obtain
y
!
m
=
1
h
!
a
0
y
m
+a
1
"
y
m
+y
!
m
h+y
!!
m
h
2
2
+···
#
+a
2
"
y
m
+y
!
m
(2h)+y
!!
m
(2h)
2
2
+···
#$
.
We collect like terms and write the above equation in the form
y
!
m
=
1
h
!
(a
0
+a
1
+a
2
)y
m
+(a
1
h+a
2
(2h))y
!
m
+(a
1
h
2
2
+a
2
(2h
2
))y
!!
m
+O(h
3
)
$
(7.11)
In order that the right-hand side of equation (7.11) reduce to y
!
m
we require the
unknown coe?cients to satisfy the equations
a
0
+ a
1
+ a
2
=0
a
1
+2a
2
=1
(1/2) a
1
+2a
2
=0.
(7.12)
We solve this system of equations and Þnd a
0
=-3/2, a
1
=2 and a
2
=-1/2.This
gives the derivative formula
y
!
(x
m
)=
-3y
m
+4y
m+1
-y
m+2
2h
+O(h
2
)(7.13)
wherethe 1/hfactorhassimpliÞedtheerrorterminequation(7.11). Byincluding
more terms in the expansions above one can determine the exact form for the
error term.
Example 7-2. (Derivative formula)
Derive an approximation formula for the second derivative of the form
y
!!
(x
m
)=
1
h
2
[ß
1
y
m-1
+a
0
y
m
+a
1
y
m+1
]+O(h
N
)(7.14)
where ß
1
,a
0
,a
1
and N are constants to be determined.
Solution: Substitute the Taylor series expansions given by equations (7.1) and
(7.2) into the equation (7.14) and then combine like terms to obtain
y
!!
(x
m
)=
1
h
2
[(ß
1
+a
0
+a
1
)y
m-1
+(a
0
h+a
1
(2h))y
!
m
+(a
0
h
2
/2+a
1
(2h
2
))y
!!
m
+(a
1
-ß
1
)y
!!!
m
h
3
3!
+(a
1
+ß
1
)y
(iv)
m
h
4
4!
+···
$
.
(7.15)
In order for the right-hand side of this equation to reduce to y
!!
m
we require the
coe?cients to satisfy the conditions
ß
1
+ a
0
+a
1
=0
a
0
+2a
1
=0
(1/2) a
0
+2a
1
=1
We solve this system of equations and Þnd ß
1
=1, a
0
=-2 and a
1
=1. Observe
that these values for ß
1
,a
0
,a
1
make the y
!!!
m
coe?cient zero and so one obtains the
second derivative approximation
y
!!
(x
m
)=
y
m-1
-2y
m
+y
m+1
h
2
+O(h
2
). (7.16)
Derivative approximations of a function can also be derived by di?erentiat-
ing a polynomial approximation of the function. For example, one can use a
polynomial approximations such as the Newton forward, Newton backward or
Stirling polynomial approximations for y(x)andthenonecandi?erentiate the
polynomial approximation and use that as an approximation for the derivative.
For the Þrst derivative one obtains the approximation
dy
dx
x=x
0
˜
dP
n
(s)
ds
ds
dx
x=x
0
, where s =
x-x
0
h
(7.17)
Approximations for higher derivatives can be obtain by taking higher order
derivatives of the approximating polynomials. This gives the approximation
d
m
y
dx
m
˜
1
h
m
d
m
P
n
(s)
ds
m
(7.18)
for m=1,2,3,.... Di?erentiation is a roughening process and so one should ex-
pect to obtain large errors when using collocation polynomials to approximate
a derivative. The error term associated with a derivative of an interpolating
polynomial is obtained by di?erentiating the error term of the interpolating
polynomial.
Example 7-3. (Derivative formula)
Obtain approximations for the derivatives y
!
(x
0
),y
!!
(x
0
) and y
!!!
(x
0
) by di?erentia-
tion of the Stirling polynomial approximation which we obtain from the lozenge
diagram of Þgure 4-1
y(x)˜ P
n
(x)=y
0
+
"
s
1
#
?y
0
+?y
-1
2
+
%
s+1
2
&
+
%
s
2
&
2
?
2
y
-1
+
"
s+1
3
#
?
3
y
-1
+?
3
y
-2
2
+
%
s+2
4
&
+
%
s+1
4
&
2
?
4
y
-2
+···
(7.19)
where s =
x-x
0
h
takes on integer values at x
0
,x
1
,....
Solution: We use chain rule di?erentiation to di?erentiate the approximating
Page 5
Chapter 7
Numerical Di?erentiation and Integration
Agivensetof (n+1)datapoints (x
i
,y
i
), i=0,1,2,...,nisassumedtorepresent
some function y = y(x). The data can come from some experiment or statistical
study, where y = y(x) is unknown, or the data can be generated from a known
function y = y(x). We assume the data points are equally spaced along the x-axis
so that x
i+1
-x
i
= h is a constant for i=0,1,2,...,n-1. In this chapter we develop
ways to approximate the derivatives of y = y(x) given only the data points. We
also develop ways to integrate the function y = y(x) based solely upon the data
points given.
Numerical Approximation for Derivative
To approximate the derivative function y
!
(x), evaluated at one of the given
data points (x
i
,y
i
),sayat x = x
m
, x
0
<x
m
<x
n
, we assume that the function y(x)
has a Taylor series expansion about the point x
m
given by either of the forms
y(x
m
+h)= y(x
m
)+y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
+y
!!!
(x
n
)
h
3
3!
+··· (7.1)
or
y(x
m
-h)= y(x
m
)-y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
-y
!!!
(x
m
)
h
3
3!
+··· (7.2)
By solving the equation (7.1) for the Þrst derivative one obtains the forward
derivative approximation
y
!
(x
m
)=
y(x
m
+h)-y(x
m
)
h
+O(h). (7.3)
Solving the equation (7.2) for the Þrst derivative gives the backward derivative
approximation
y
!
(x
m
)=
y(x
m
)-y(x
m
-h)
h
+O(h). (7.4)
Subtracting the equation (7.2) from the equation (7.1) gives
y(x
m
+h)-y(x
m
-h)=2y
!
(x
m
)+2y
!!!
(x
m
)
h
3
3!
+··· (7.5)
fromwhichonecanobtainthecentralderivativeapproximation
y
!
(x
m
)=
y(x
m
+h)-y(x
m
-h)
2h
+O(h
2
)(7.6)
which is more accurate than the results from equations (7.3) or (7.4). By using
Taylor series expansions one can develop a variety of derivative approximations.
Onecanderiveaderivativeapproximationforanyorderderivative. Consider
an approximation for the jth derivative
d
j
y
dx
j
x=x
i
= y
(j)
(x
i
), (7.7)
where j a positive integer. The derivative can be approximated by assuming the
derivative can be represented in the form
y
(j)
(x
i
)=
1
h
j
[ß
m
y(x
i
-mh)+ß
m-1
y(x
i
-(m-1)h)+···+ß
1
y(x
i
-h)
a
0
y(x
i
)+···+a
n-1
y(x
i
+(n-1)h)+a
n
y(x
i
+nh)]+O(h
N
)
(7.8)
involving (m + n+1) data points, where ß
m
,ß
m-1
,...,ß
1
,a
0
,a
1
,...,a
n
and N are
constants to be determined. Let y
i+j
= y(x
i
+jh) for the index j ranging over the
values j = -m,-(m- 1),...,(n- 1),n and expand these terms in a Taylor series
which are then substitute into the equation (7.8). One can then collect like
terms and force the right-hand side of equation (7.8) to equal the left-hand side
of equation (7.8) by setting certain coe?cients equal to either zero or one. This
will produce a system of equations where the coe?cients ß
m
,...,ß
1
,a
0
,...,a
n
and
the order N of the error term can be determined .
Example 7-1. (Derivative formula)
Derive a formula for the Þrst derivative of the form
y
!
(x
m
)=
1
h
[a
0
y
m
+a
1
y
m+1
+a
2
y
m+2
]+O(h
N
)(7.9)
where a
0
,a
1
,a
2
and N are constants to be determined.
Solution: Substitute the Taylor series expansions
y
m+1
= y(x
m
+h)=y(x
m
)+y
!
(x
m
)h+y
!!
(x
m
)
h
2
2!
+···
y
m+2
= y(x
m
+2h)=y(x
m
)+y
!
(x
m
)(2h)+y
!!
(x
m
)
(2h)
2
2!
+···
(7.10)
into the assumed form for the derivative to obtain
y
!
m
=
1
h
!
a
0
y
m
+a
1
"
y
m
+y
!
m
h+y
!!
m
h
2
2
+···
#
+a
2
"
y
m
+y
!
m
(2h)+y
!!
m
(2h)
2
2
+···
#$
.
We collect like terms and write the above equation in the form
y
!
m
=
1
h
!
(a
0
+a
1
+a
2
)y
m
+(a
1
h+a
2
(2h))y
!
m
+(a
1
h
2
2
+a
2
(2h
2
))y
!!
m
+O(h
3
)
$
(7.11)
In order that the right-hand side of equation (7.11) reduce to y
!
m
we require the
unknown coe?cients to satisfy the equations
a
0
+ a
1
+ a
2
=0
a
1
+2a
2
=1
(1/2) a
1
+2a
2
=0.
(7.12)
We solve this system of equations and Þnd a
0
=-3/2, a
1
=2 and a
2
=-1/2.This
gives the derivative formula
y
!
(x
m
)=
-3y
m
+4y
m+1
-y
m+2
2h
+O(h
2
)(7.13)
wherethe 1/hfactorhassimpliÞedtheerrorterminequation(7.11). Byincluding
more terms in the expansions above one can determine the exact form for the
error term.
Example 7-2. (Derivative formula)
Derive an approximation formula for the second derivative of the form
y
!!
(x
m
)=
1
h
2
[ß
1
y
m-1
+a
0
y
m
+a
1
y
m+1
]+O(h
N
)(7.14)
where ß
1
,a
0
,a
1
and N are constants to be determined.
Solution: Substitute the Taylor series expansions given by equations (7.1) and
(7.2) into the equation (7.14) and then combine like terms to obtain
y
!!
(x
m
)=
1
h
2
[(ß
1
+a
0
+a
1
)y
m-1
+(a
0
h+a
1
(2h))y
!
m
+(a
0
h
2
/2+a
1
(2h
2
))y
!!
m
+(a
1
-ß
1
)y
!!!
m
h
3
3!
+(a
1
+ß
1
)y
(iv)
m
h
4
4!
+···
$
.
(7.15)
In order for the right-hand side of this equation to reduce to y
!!
m
we require the
coe?cients to satisfy the conditions
ß
1
+ a
0
+a
1
=0
a
0
+2a
1
=0
(1/2) a
0
+2a
1
=1
We solve this system of equations and Þnd ß
1
=1, a
0
=-2 and a
1
=1. Observe
that these values for ß
1
,a
0
,a
1
make the y
!!!
m
coe?cient zero and so one obtains the
second derivative approximation
y
!!
(x
m
)=
y
m-1
-2y
m
+y
m+1
h
2
+O(h
2
). (7.16)
Derivative approximations of a function can also be derived by di?erentiat-
ing a polynomial approximation of the function. For example, one can use a
polynomial approximations such as the Newton forward, Newton backward or
Stirling polynomial approximations for y(x)andthenonecandi?erentiate the
polynomial approximation and use that as an approximation for the derivative.
For the Þrst derivative one obtains the approximation
dy
dx
x=x
0
˜
dP
n
(s)
ds
ds
dx
x=x
0
, where s =
x-x
0
h
(7.17)
Approximations for higher derivatives can be obtain by taking higher order
derivatives of the approximating polynomials. This gives the approximation
d
m
y
dx
m
˜
1
h
m
d
m
P
n
(s)
ds
m
(7.18)
for m=1,2,3,.... Di?erentiation is a roughening process and so one should ex-
pect to obtain large errors when using collocation polynomials to approximate
a derivative. The error term associated with a derivative of an interpolating
polynomial is obtained by di?erentiating the error term of the interpolating
polynomial.
Example 7-3. (Derivative formula)
Obtain approximations for the derivatives y
!
(x
0
),y
!!
(x
0
) and y
!!!
(x
0
) by di?erentia-
tion of the Stirling polynomial approximation which we obtain from the lozenge
diagram of Þgure 4-1
y(x)˜ P
n
(x)=y
0
+
"
s
1
#
?y
0
+?y
-1
2
+
%
s+1
2
&
+
%
s
2
&
2
?
2
y
-1
+
"
s+1
3
#
?
3
y
-1
+?
3
y
-2
2
+
%
s+2
4
&
+
%
s+1
4
&
2
?
4
y
-2
+···
(7.19)
where s =
x-x
0
h
takes on integer values at x
0
,x
1
,....
Solution: We use chain rule di?erentiation to di?erentiate the approximating
polynomial and then use these derivatives to approximate the derivatives of y(x).
Expanding the equation (7.19) we Þnd
y(x)˜y
0
+s
"
?y
0
+?y
-1
2
#
+
1
2
s
2
?
2
y
-1
+
1
6
(s
3
-s)
"
?
3
y
-1
+?
3
y
-2
2
#
+
1
24
(s
4
-s
2
)?
4
y
-2
+···
with derivatives
y
!
(x)˜
1
h
!"
?y
0
+?y
-1
2
#
+s?
2
y
-1
+
1
6
(3s
2
-1)
"
?
3
y
-1
+?
3
y
-2
2
#
+
1
24
(4s
3
-2s)?
4
y
-2
+···
$
y
!!
(x)˜
1
h
2
!
?
2
y
-1
+s
"
?
3
y
-1
+?
3
y
-2
2
#
+
1
12
(6s
2
-1)?
4
y
-2
+···
$
y
!!!
(x)˜
1
h
3
!"
?
3
y
-1
+?
3
y
-2
2
#
+s?
4
y
-2
+···
$
At the point x = x
0
we have s=0 and so we obtain the approximations
y
!
(x
0
)˜
1
h
!"
?y
0
+?y
-1
2
#
-
1
6
"
?
3
y
-1
+?
3
y
-2
2
#$
y
!!
(x
0
)˜
1
h
2
!
?
2
y
-1
-
1
12
?
4
y
-2
$
y
!!!
(x
0
)˜
1
h
3
!"
?
3
y
-1
+?
3
y
-2
2
#$
These same results can be obtain by di?erentiating the equation (4.95) consid-
ered earlier. Note also that derivative approximations can be obtained from the
appropriate values of a di?erence table. Alternatively, the di?erences can be
expressed in terms of ordinate values and so the above derivative formulas can
also be expressed in terms of ordinate values.
Error Terms for Derivative Approximations
Toderiveerrortermsassociatedwithnumericaldi?erentiationorintegration
we will need the following results.
(1.) If F(x) is a continuous function over the interval a= x= b,thenthere
exists at least one point c such that a= c= b and
aF(a)+ßF(b)=(a+ß)F(c)(7.20)
for positive constants a and ß.
Read More