You are on page 1of 13

02.01.

1





Chapter 02.02
Differentiation of Continuous Functions





After reading this chapter, you should be able to:

1. derive formulas for approximating the first derivative of a function,
2. derive formulas for approximating derivatives from Taylor series,
3. derive finite difference approximations for higher order derivatives, and
4. use the developed formulas in examples to find derivatives of a function.

The derivative of a function at x is defined as
( )
( ) ( )
x
x f x x f
x f
x

+
=
0
lim
To be able to find a derivative numerically, one could make x finite to give,
( )
( ) ( )
x
x f x x f
x f

+
.
Knowing the value of x at which you want to find the derivative of ( ) x f , we choose a value
of x to find the value of ( ) x f . To estimate the value of ( ) x f , three such approximations
are suggested as follows.

Forward Difference Approximation of the First Derivative
From differential calculus, we know
( )
( ) ( )
x
x f x x f
x f
x

+
=
0
lim
For a finite x ,
( )
( ) ( )
x
x f x x f
x f

+

The above is the forward divided difference approximation of the first derivative. It is called
forward because you are taking a point ahead of x . To find the value of ( ) x f at
i
x x = , we
may choose another point x ahead as
1 +
=
i
x x . This gives
( )
( ) ( )
x
x f x f
x f
i i
i


+1

02.02.2 Chapter 02.02




( ) ( )
i i
i i
x x
x f x f

=
+
+
1
1

where

i i
x x x =
+1


Figure 1 Graphical representation of forward difference approximation of first derivative.

Example 1
The velocity of a rocket is given by
( ) 30 0 , 8 . 9
2100 10 14
10 14
ln 2000
4
4

(



= t t
t
t
where is given in m/s and t is given in seconds. At s 16 = t ,
a) use the forward difference approximation of the first derivative of ( ) t to calculate the
acceleration. Use a step size of s 2 = t .
b) find the exact value of the acceleration of the rocket.
c) calculate the absolute relative true error for part (b).

Solution
(a) ( )
( ) ( )
t
t t
t a
i i
i

+

1

16 =
i
t
2 = t
t t t
i i

1
+ =
+

2 16 + =
=18
) (x f
x x +
x
x
Continuous Differentiation 02.02.3



( )
( ) ( )
2
16 18
16

a
( )
( )
( ) 18 8 . 9
18 2100 10 14
10 14
ln 2000 18
4
4



=
m/s 02 . 453 =
( )
( )
( ) 16 8 . 9
16 2100 10 14
10 14
ln 2000 16
4
4



=
m/s 07 . 392 =
Hence
( )
( ) ( )
2
16 18
16

a

2
07 . 392 02 . 453
=

2
m/s 474 . 30 =

(b) The exact value of ( ) 16 a can be calculated by differentiating
( ) t
t
t 8 . 9
2100 10 14
10 14
ln 2000
4
4



=
as
( ) ( ) | | t
dt
d
t a =
Knowing that
( ) | |
t
t
dt
d 1
ln = and
2
1 1
t t dt
d
=
(


( ) 8 . 9
2100 10 14
10 14
10 14
2100 10 14
2000
4
4
4
4

|
|
.
|

\
|


|
|
.
|

\
|


=
t dt
d t
t a
( )
( )
( ) 8 . 9 2100
2100 10 14
10 14
1
10 14
2100 10 14
2000
2
4
4
4
4

|
|
.
|

\
|

|
|
.
|

\
|


=
t
t


t
t
3 200
4 . 29 4040
+

=
( )
( )
( ) 16 3 200
16 4 . 29 4040
16
+

= a

2
m/s 674 . 29 =
(c) The absolute relative true error is
100
Value True
Value e Approximat Value True

=
t

02.02.4 Chapter 02.02



100
674 . 29
474 . 30 674 . 29

=
% 6967 . 2 =

Backward Difference Approximation of the First Derivative
We know
( )
( ) ( )
x
x f x x f
x f
x

+
=
0
lim
For a finite x ,
( )
( ) ( )
x
x f x x f
x f

+

If x is chosen as a negative number,
( )
( ) ( )
x
x f x x f
x f

+


( ) ( )
x
x x f x f


=
This is a backward difference approximation as you are taking a point backward from x . To
find the value of ( ) x f at
i
x x = , we may choose another point x behind as
1
=
i
x x . This
gives
( )
( ) ( )
x
x f x f
x f
i i
i


1


( ) ( )
1
1

=
i i
i i
x x
x f x f

where

1


=
i i
x x x

Continuous Differentiation 02.02.5




Figure 2 Graphical representation of backward difference approximation of first derivative.

Example 2
The velocity of a rocket is given by
( ) 30 0 , 8 . 9
2100 10 14
10 14
ln 2000
4
4

(



= t t
t
t
(a) Use the backward difference approximation of the first derivative of ( ) t to calculate the
acceleration at s 16 = t . Use a step size of s 2 = t .
(b) Find the absolute relative true error for part (a).
Solution
( )
( ) ( )
t
t t
t a
i i

1


16 =
i
t
2 = t
t t t
i i

1
=


2 16 =
= 14
( )
( ) ( )
2
14 16
16

a
( )
( )
( ) 16 8 . 9
16 2100 10 14
10 14
ln 2000 16
4
4



=
m/s 07 . 392 =
( )
( )
( ) 14 8 . 9
14 2100 10 14
10 14
ln 2000 14
4
4



=
) (x f
x
x x x
02.02.6 Chapter 02.02



m/s 24 . 334 =

( )
( ) ( )
2
14 16
16

a

2
24 . 334 07 . 392
=

2
m/s 915 . 28 =
(b) The exact value of the acceleration at s 16 = t from Example 1 is
( )
2
m/s 674 . 29 16 = a
The absolute relative true error for the answer in part (a) is
100
674 . 29
915 . 28 674 . 29

=
t

% 5584 . 2 =

Forward Difference Approximation from Taylor Series
Taylors theorem says that if you know the value of a function ) (x f at a point
i
x and all its
derivatives at that point, provided the derivatives are continuous between
i
x and
1 + i
x , then
( ) ( ) ( )( )
( )
( ) +

+ + =
+ + +
2
1 1 1
! 2
i i
i
i i i i i
x x
x f
x x x f x f x f
Substituting for convenience
i i
x x x =
+1

( ) ( ) ( )
( )
( ) +

+ + =
+
2
1

! 2
x
x f
x x f x f x f
i
i i i

( )
( ) ( ) ( )
( ) +

=
+
x
x f
x
x f x f
x f
i i i
i
! 2
1

( )
( ) ( )
( ) x O
x
x f x f
x f
i i
i
+

=
+1

The ( ) x O term shows that the error in the approximation is of the order of x .
Can you now derive from the Taylor series the formula for the backward divided difference
approximation of the first derivative?
As you can see, both forward and backward divided difference approximations of the
first derivative are accurate on the order of ( ) x O . Can we get better approximations? Yes,
another method to approximate the first derivative is called the central difference
approximation of the first derivative.
From the Taylor series
( ) ( ) ( )
( )
( )
( )
( ) +

+

+ + =
+
3 2
1

! 3

! 2
x
x f
x
x f
x x f x f x f
i i
i i i
(1)
and
( ) ( ) ( )
( )
( )
( )
( ) +


+ =

3 2
1

! 3

! 2
x
x f
x
x f
x x f x f x f
i i
i i i
(2)
Subtracting Equation (2) from Equation (1)
Continuous Differentiation 02.02.7



( ) ( ) ( )( )
( )
( ) +

+ =
+
3
1 1

! 3
2
2 x
x f
x x f x f x f
i
i i i

( )
( ) ( ) ( )
( ) +

=
+
2
1 1
! 3 2
x
x f
x
x f x f
x f
i i i
i


( ) ( )
( )
2
1 1
2
x O
x
x f x f
i i
+

=
+

hence showing that we have obtained a more accurate formula as the error is of the order of
( )
2
x O .

Figure 3 Graphical representation of central difference approximation of first derivative.

Example 3
The velocity of a rocket is given by
( ) 30 0 , 8 . 9
2100 10 14
10 14
ln 2000
4
4

(



= t t
t
t .
(a) Use the central difference approximation of the first derivative of ( ) t to calculate the
acceleration at s 16 = t . Use a step size of s 2 = t .
(b) Find the absolute relative true error for part (a).
Solution
( )
( ) ( )
t
t t
t a
i i
i

+
2
1 1


16 =
i
t
2 = t
) (x f
x x +
x
x x x
02.02.8 Chapter 02.02




18
2 16
1
=
+ =
+ =
+
t t t
i i


14
2 16
1
=
=
=

t t t
i i

( )
( ) ( )
( ) 2 2
14 18
16

a

( ) ( )
4
14 18
=
( )
( )
( ) 18 8 . 9
18 2100 10 14
10 14
ln 2000 18
4
4



=
m/s 02 . 453 =
( )
( )
( ) 14 8 . 9
14 2100 10 14
10 14
ln 2000 14
4
4



=
m/s 24 . 334 =

( )
( ) ( )
4
14 18
16

a

4
24 . 334 02 . 453
=

2
m/s 694 . 29 =
(b) The exact value of the acceleration at s 16 = t from Example 1 is
( )
2
m/s 674 . 29 16 = a
The absolute relative true error for the answer in part (a) is
100
674 . 29
694 . 29 674 . 29

=
t

% 069157 . 0 =
The results from the three difference approximations are given in Table 1.

Table 1 Summary of ( ) 16 a using different difference approximations
Type of difference
approximation
( ) 16 a
( )
2
m/s
%
t

Forward
Backward
Central
30.475
28.915
29.695
2.6967
2.5584
0.069157

Clearly, the central difference scheme is giving more accurate results because the
order of accuracy is proportional to the square of the step size. In real life, one would not
Continuous Differentiation 02.02.9



know the exact value of the derivative so how would one know how accurately they have
found the value of the derivative? A simple way would be to start with a step size and keep
on halving the step size until the absolute relative approximate error is within a pre-specified
tolerance.
Take the example of finding ( ) t v for
( ) t
t
t 8 . 9
2100 10 14
10 14
ln 2000
4
4



=
at 16 = t using the backward difference scheme. Given in Table 2 are the values obtained
using the backward difference approximation method and the corresponding absolute relative
approximate errors.

Table 2 First derivative approximations and relative errors for different t values of
backward difference scheme.

t ( ) t v %
a

2
1
0.5
0.25
0.125
28.915
29.289
29.480
29.577
29.625

1.2792
0.64787
0.32604
0.16355

From the above table, one can see that the absolute relative approximate error
decreases as the step size is reduced. At 125 . 0 = t , the absolute relative approximate error
is 0.16355%, meaning that at least 2 significant digits are correct in the answer.

Finite Difference Approximation of Higher Derivatives
One can also use the Taylor series to approximate a higher order derivative. For example, to
approximate ( ) x f , the Taylor series is
( ) ( ) ( )( )
( )
( )
( )
( ) +

+

+ + =
+
3 2
2
2
! 3
2
! 2
2 x
x f
x
x f
x x f x f x f
i i
i i i
(3)
where
x x x
i i
2
2
+ =
+

( ) ( ) ( )( )
( )
( )
( )
( )
3 2
1
! 3 ! 2
x
x f
x
x f
x x f x f x f
i i
i i i


+

+ + =
+
(4)
where
x x x
i i

1
=


Subtracting 2 times Equation (4) from Equation (3) gives
( ) ( ) ( ) ( )( ) ( )( )
3 2
1 2
2 x x f x x f x f x f x f
i i i i i
+ + =
+ +


02.02.10 Chapter 02.02



( )
( ) ( ) ( )
( )
( )( ) +
+
=
+ +
x x f
x
x f x f x f
x f
i
i i i
i

2
2
1 2

( )
( ) ( ) ( )
( )
( ) x O
x
x f x f x f
x f
i i i
i
+

+

+ +
2
1 2
2
(5)
Example 4
The velocity of a rocket is given by
( ) 30 0 , 8 . 9
2100 10 14
10 14
ln 2000
4
4

(



= t t
t
t
Use the forward difference approximation of the second derivative of ( ) t to calculate the
jerk at s 16 = t . Use a step size of s 2 = t .
Solution
( )
( ) ( ) ( )
( )
2
1 2
2
t
t t t
t j
i i i
i

+ +


16 =
i
t
2 = t

18
2 16
1
=
+ =
+ =
+
t t t
i i


( )
( )
20
2 2 16
2
2
=
+ =
+ =
+
t t t
i i

( )
( ) ( ) ( )
( )
2
2
16 18 2 20
16
+
j
( )
( )
( ) 20 8 . 9
20 2100 10 14
10 14
ln 2000 20
4
4



=
m/s 35 . 517 =
( )
( )
( ) 18 8 . 9
18 2100 10 14
10 14
ln 2000 18
4
4



=
m/s 02 . 453 =
( )
( )
( ) 16 8 . 9
16 2100 10 14
10 14
ln 2000 16
4
4



=
m/s 07 . 392 =

( )
( )
4
07 . 392 02 . 453 2 35 . 517
16
+
j

3
m/s 84515 . 0 =
Continuous Differentiation 02.02.11




The exact value of ( ) 16 j can be calculated by differentiating
( ) t
t
t 8 . 9
2100 10 14
10 14
ln 2000
4
4



=
twice as
( ) ( ) | | t
dt
d
t a = and
( ) ( ) | | t a
dt
d
t j =
Knowing that
( ) | |
t
t
dt
d 1
ln = and

2
1 1
t t dt
d
=
(


( ) 8 . 9
2100 10 14
10 14
10 14
2100 10 14
2000
4
4
4
4

|
|
.
|

\
|


|
|
.
|

\
|


=
t dt
d t
t a
( )
( )
( ) 8 . 9 2100
2100 10 14
10 14
1
10 14
2100 10 14
2000
2
4
4
4
4

|
|
.
|

\
|

|
|
.
|

\
|


=
t
t


t
t
3 200
4 . 29 4040
+

=
Similarly it can be shown that
( ) ( ) | | t a
dt
d
t j =

2
) 3 200 (
18000
t +
=

( )
3
2
m/s 77909 . 0
)] 16 ( 3 200 [
18000
16
=
+
= j

The absolute relative true error is
100
77909 . 0
84515 . 0 77909 . 0

=
t

% 4797 . 8 =

The formula given by Equation (5) is a forward difference approximation of the second
derivative and has an error of the order of ( ) x O . Can we get a formula that has a better
accuracy? Yes, we can derive the central difference approximation of the second derivative.
The Taylor series is
02.02.12 Chapter 02.02



( ) ( ) ( )
( )
( )
( )
( )
( )
( ) ...
! 4 ! 3 ! 2
4 3 2
1
+

+

+

+ + =
+
x
x f
x
x f
x
x f
x x f x f x f
i i i
i i i
(6)
where
x x x
i i

1
+ =
+

( ) ( ) ( )
( )
( )
( )
( )
( )
( )

+



+ =

4 3 2
1
! 4 ! 3 ! 2
x
x f
x
x f
x
x f
x x f x f x f
i i i
i i i
(7)
where
x x x
i i

1
=


Adding Equations (6) and (7), gives
( ) ( ) ( ) ( )( ) ( )
( )
...
12
2
4
2
1 1
+

+ + = +
+
x
x f x x f x f x f x f
i i i i i

( )
( ) ( ) ( )
( )
( )( )
...
12
2
2
2
1 1
+

+
=
+
x x f
x
x f x f x f
x f
i i i i
i


( ) ( ) ( )
( )
( )
2
2
1 1
2
x O
x
x f x f x f
i i i
+

+
=
+

Example 5
The velocity of a rocket is given by
( ) 30 0 , 8 . 9
2100 10 14
10 14
ln 2000
4
4

(



= t t
t
t ,
(a) Use the central difference approximation of the second derivative of ( ) t to calculate the
jerk at s 16 = t . Use a step size of s 2 = t .
Solution
The second derivative of velocity with respect to time is called jerk. The second order
approximation of jerk then is
( )
( ) ( ) ( )
( )
2
1 1
2
t
t t t
t j
i i i
i

+


16 =
i
t
2 = t

18
2 16
1
=
+ =
+ =
+
t t t
i i


14
2 16
2
=
=
=
+
t t t
i i


( )
( ) ( ) ( )
( )
2
2
14 16 2 18
16
+
j
Continuous Differentiation 02.02.13



( )
( )
( ) 18 8 . 9
18 2100 10 14
10 14
ln 2000 18
4
4



=
m/s 02 . 453 =
( )
( )
( ) 16 8 . 9
16 2100 10 14
10 14
ln 2000 16
4
4



=
m/s 07 . 392 =
( )
( )
( ) 14 8 . 9
14 2100 10 14
10 14
ln 2000 14
4
4



=
m/s 24 . 334 =
( )
( ) ( ) ( )
( )
2
2
14 16 2 18
16
+
j

( )
4
24 . 334 07 . 392 2 02 . 453 +
=

3
m/s 77969 . 0 =
The absolute relative true error is
100
77908 . 0
77969 . 0 77908 . 0

=
t

% 077992 . 0 =

DIFFERENTIATION
Topic Differentiation of Continuous functions
Summary These are textbook notes of differentiation of continuous functions
Major General Engineering
Authors Autar Kaw, Luke Snyder
Date February 2, 2012
Web Site http://numericalmethods.eng.usf.edu

You might also like