Chapter 02.02 Differentiation of Continuous Functions
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 ) ( ) + f x − f x
′
f ( ) x = lim x ∆ →
∆ x To be able to find a derivative numerically, one could make ∆ x finite to give,
f x ∆ x − f x ( ) ( )
- ′ f ( ) x ≈ .
∆ x
Knowing the value of x at which you want to find the derivative of f x , we choose a value
( )
of ∆ x to find the value of f ′ ( ) x . To estimate the value of f ′ ( ) x , three such approximations are suggested as follows.
Forward Difference Approximation of the First Derivative
From differential calculus, we know
( ∆ ) ( ) − f ′ ( ) x = lim x
- f x x f x
∆ → x
∆
For a finite x ,
∆ f ( x ∆ + x ) ( ) − f x f ′ x ≈
( ) x
∆ 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 f ′ ( ) x at x = , we x i may choose another point ∆ x ahead as x = x . This gives
- i
- 1
- x − x i 1 i
- where
- 1
- x x
- (a) a ( ) ( ) ( ) t i ≈ ∆ t
- t = t t i 1 i Δ<
- 16
- =
- 200
- ′′ 2 f x
- 1
- 2 !
- 1
- 2 ∆ x
- 2 x ∆
- = O ( ) ∆ x
- x
- i 1 i − 1 a ( ) ( ) ( ) t ≈ i
- t = t ∆ t i 1 i<
- 16
- =
- f ( ) x = f ( ) x f ′ ( )( x
+ + +
2 x ) ( )( ) i i- 2 !
- x = x 2 x i 2 i Δ<
′′ ′′′
- 2 !
- f x f x x
- f x
- t = t ∆ t
- i 1 i
- 16
- t = t 2 ∆ t
- =
- ( − 200
- 2 !
- x = x x i 1 i Δ<
- f ′′ x i i i 2 f ′′′ x 3 f ′ ′′′ x 4 ′ f ( ) ( ) x = f x − f ( ) x ∆ x ( )( ) ∆ x − ( )( ) ∆ x ( )( ) ∆ x − (7) i 1 i i + +
- f ( ) x −
- i i i 1 i
- f ( ) x − i 1 i i
- −
- t
- i 1 i
- 16
- i 2 i
- − ≈ j
- − = 3 . 77969 m/s =
1
f x f x( ) − ( ) i i
f ′ ( ) x ≈ i x ∆
02.02.2
Chapter 02.02
f x f x ( ) − ( ) i 1 i
=
∆ x = x − x i i
f (x )
x ∆ x
Figure 1 Graphical representation of forward difference approximation of first derivative.
Example 1
The velocity of a rocket is given by 4 14 ×
10
t 2000 ln 9 .
8 t , t
30 ν ( ) = − ≤ ≤ 4
14 × 10 − 2100 t
where ,
ν is given in m/s and t is given in seconds. At t =
16 s
a) use the forward difference approximation of the first derivative of t
ν to calculate the ( )
acceleration. Use a step size of ∆t = 2 s .
b) find the exact value of the acceleration of the rocket.
c) calculate the absolute relative true error for part (b).
Solution
ν t ν t
− i 1 i
t = i
16
t
2 Δ =
2
=18
Continuous Differentiation
02.02.3
ν
18 ν
16 − a ( ) ( ) ( ) 16 ≈
2 4
14 10 ×
( )
18 = 2000 ln − 9 . 8 ( )
18 ν 4
14 × 10 − 2100
18
( )
= 453 .
02 m/s 4
14 × 10 ν ( ) 16 = 2000 ln − 4 9 . 8 ( )
16
14 10 2100
16 × − ( )
= 392 .
07 m/s
Hence ν
18 − ν
16 a ( ) ( ) ( ) 16 ≈
2 453 . 02 − 392 .
07 =
2 2
= 30 . 474 m/s (b) The exact value of a 16 can be calculated by differentiating
( ) 4
14 × 10
t 2000 ln 9 .
8 t ν ( ) = − 4
14 × 10 − 2100 t
as
d a t = t ( ) [ ] ν ( ) dt
Knowing that
d 1 d
1
1 ln ( ) t = and = −
[ ] 2 dt t dt t t 4 4
14 10 2100 t d
14 10 × − ×
a ( ) t = 2000 4 4 − 9 .
8 14 ×
10 dt
14 10 2100 t × −
4 4
14 10 2100 t
14
10 × − ×
= 2000 ( ) − 4 1 ( − 2100 ) − 2 9 .
8 4
14
10 × 14 ×
10 − 2100 t ( )
4040 29 . 4 t − − =
3 t −
4040 29 .
4
16 − − ( )
a ( )
16 = 200
3
16 − ( ) + 2
= 29 . 674 m/s (c) The absolute relative true error is
True Value Approximat e Value −
∈ = × 100 t True Value
02.02.4
Chapter 02.02
29 . 674 30 . 474 − = × 100 29 . 674 = 2 . 6967 %
Backward Difference Approximation of the First Derivative
We know
( + f x ∆ x ) ( ) − f x f ′ x lim
( ) = x ∆ →
∆ x
For a finite ,
∆ x ( ) ( ) + f x ∆ x − f x f ′ x
( ) ≈
∆ x If ∆ x is chosen as a negative number,
f x x f x ( ∆ ) ( ) − +
′ f ( ) x ≈
∆ x f ( ) ( x − f x − x )
Δ =
x
Δ This is a backward difference approximation as you are taking a point backward from x . To find the value of f ′ ( ) x at x = , we may choose another point x ∆ x behind as x = x . This i i 1
−
gives
f ( ) ( ) x − f x i i −1
′ f ( ) x ≈ i
∆ x f ( ) ( ) x − f x i i 1
−
=
x − x i i − 1
where
x = x − x
Δ i i 1
− Continuous Differentiation
02.02.5 f (x ) x x x − ∆ x
Figure 2 Graphical representation of backward difference approximation of first derivative.
Example 2
The velocity of a rocket is given by 4
14 10 ×
ν ( ) t = 2000 ln − 4 9 . 8 t , ≤ t ≤
30
14 10 2100 t × −
(a) Use the backward difference approximation of the first derivative of ( ) t
ν to calculate the
acceleration at t
16 s . Use a step size of 2 s . = ∆t = (b) Find the absolute relative true error for part (a).
Solution
ν t − ν t i i −1
a ( ) ( ) ( ) t ≈ ∆ t t = i
16
t
2 Δ = t = t − t i 1 i Δ
− = 16 −
2
= 14 ν
16 − ν
14 a
16 ( ) ( ) ( ) ≈
2 4
14 × 10 16 2000 ln 9 .
8
16 ν ( ) = − ( ) 4
14 × 10 − 2100 ( )
16 392 .
07 m/s = 4
14 × 10 14 2000 ln 9 .
8
14 ν ( ) = − ( ) 4
14 × 10 − 2100 ( )
14
02.02.6
Chapter 02.02
= 334 . 24 m/s
ν
16 − ν
14 a ( ) ( ) ( ) 16 ≈
2 392 . 07 − 334 .
24 =
2 2 = 28 . 915 m/s
(b) The exact value of the acceleration at t = 2 16 s from Example 1 is
a ( )
16 = 29 . 674 m/s The absolute relative true error for the answer in part (a) is
29 . 674 − 28 . 915 ∈ = × 100 t 29 . 674 = 2 . 5584 %
Forward Difference Approximation from Taylor Series
Taylor’s theorem says that if you know the value of a function f (x ) at a point x and all its i derivatives at that point, provided the derivatives are continuous between x and x , then i i 1
i
f x f x f ′ x x x x x( ) = ( ) ( )( − ) ( )( − ) i 1 i i i 1 i i + + + 1 i
2 !
Substituting for convenience x x x Δ = − i i
′′ 2
f x i f x f x f ′ x x x ( ) = ( ) ( ) Δ ( )( ) Δ
i 1 i i
f x f x f ′′ x ( ) ( ) − i 1 i i
f ′ x x ( ) = − ( )( ) ∆ i
∆ x 2 ! f ( ) ( ) x − f x
( ) = ( ) ∆ i i + f ′ x O x i
∆ x The O ∆ term shows that the error in the approximation is of the order of x 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
O ( ) ∆ . Can we get better approximations? Yes, x
another method to approximate the first derivative is called the central difference approximation of the first derivative. From the Taylor series
f ′′ x i 1 i Δ Δ i i 2 f ′′′ x 3 + f ( ) x = f ( ) x f ′ ( ) x x ( )( ) x ( )( ) x (1) + + + i Δ
+ 2 ! 3 !
and
′′ ′′′ f x i i 2 f x 3
′ f ( ) x = f ( ) x − f ( ) x x ( )( ) x − ( )( ) x (2) i 1 i i Δ Δ Δ + +
− 2 !
3 ! Continuous Differentiation
02.02.7 2 f ′′′ x
i
3 f ( ) ( ) x − f x = f ′ ( )( x i 1 i 1 i Δ ( )( ) Δ 2 x ) x+ +
− + 3 ! ′′′ f ( ) ( ) x − f x f x i 1 i 1 i
2
− ′ x − ( )( ) ∆ x i + f ( ) =
3 ! f x − f x
( ) ( ) i 1 i − 1 2
hence showing that we have obtained a more accurate formula as the error is of the order of 2 O ( ) ∆ x .
f (x )
x − ∆ x x ∆ x x Figure 3 Graphical representation of central difference approximation of first derivative.
Example 3
The velocity of a rocket is given by 4
14 10 ×
( ) t = 2000 ln − 9 .
8 t , ≤ t ≤ 30 . ν 4
14 10 2100 t × −
(a) Use the central difference approximation of the first derivative of ν to calculate the ( ) t acceleration at t =
16 s . Use a step size of ∆t = 2 s .
(b) Find the absolute relative true error for part (a).
Solution
ν t − ν t
2 ∆ t t = i
16
∆t =
2
02.02.8
Chapter 02.02
2 =
18
t = t − ∆ t i 1 i −
= 16 −
2 =
14 ν 18 ν
14 −
a ( ) ( ) ( )
16 ≈
2
2
( ) 18 −
14 ν ( ) ( ) ν
=
4 4
14 10 ×
ν ( ) 18 = 2000 ln − 4 9 . 8 ( )
18 14 ×
10 − 2100
18
( )
= 453 .
02 m/s 4
14 10 ×
ν ( ) 14 = 2000 ln − 4 9 . 8 ( )
14 14 ×
10 − 2100
14
( )
= 334 .
24 m/s
ν
18 − ν
14 a ( ) ( ) ( ) 16 ≈
4 453 . 02 − 334 .
24 =
4 2 = 29 . 694 m/s
(b) The exact value of the acceleration at t = 2 16 s from Example 1 is
a ( )
16 = 29 . 674 m/s The absolute relative true error for the answer in part (a) is
29 . 674 − 29 . 694 ∈ = × 100 t 29 . 674 = . 069157 % The results from the three difference approximations are given in Table 1.
Table 1 Summary of a
16 using different difference approximations
( ) a ( )
16 Type of difference % 2 ∈ t approximation m/s
( )
Forward 30.475 2.6967 Backward 28.915 2.5584
Central 29.695 0.069157 Clearly, the central difference scheme is giving more accurate results because the 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 v′ ( ) t for 4 14 ×
10
( ) t = 2000 ln − 9 .
8 t ν 4
14 10 2100 t × −
at t
16 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. v′ t ∈ %∆ t ( ) a
2 28.915 1 29.289 1.2792 0.5 29.480 0.64787 0.25 29.577 0.32604 0.125 29.625 0.16355
From the above table, one can see that the absolute relative approximate error decreases as the step size is reduced. At ∆t = . 125 , 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 f ′′ ( ) x , the Taylor series is
f ′′ x f
2 x ( )( ) 2 ′′′ x 2 x (3) 3 i 2 i i Δ Δ Δ
3 !
where
f x i i 2 f x 3 ′ f ( ) x = f ( ) x f ( )( ) x ∆ x ( )( ) ( )( ) + + + ∆ x ∆ x (4) i 1 i i
3 !
where
x x x i 1 i Δ = − −
Subtracting 2 times Equation (4) from Equation (3) gives 2 3
f x i 2 i 2 f x f x f ′′ x x f ′′′ x x 1 i i i
( ) − ( ) = − ( ) ( )( ) Δ ( )( ) Δ
02.02.10
Chapter 02.02
f ( ) x −
2 f ( ) ( ) + x f x i 2 i 1 i
′′ = − ′′′ ( )( )
( ) i i Δ 2 x
( )
Δ
2 f x f x ( ) − ( ) ( ) i 2 i 1 i
f ′′ ( ) + x ≈ O ( ) ∆ i 2 x (5) ∆ x
( ) Example 4
The velocity of a rocket is given by 4 14 × 10
ν ( ) t = 2000 ln − 4 9 . 8 t , ≤ t ≤
30 14 ×
10 − 2100 t
Use the forward difference approximation of the second derivative of t ν to calculate the ( ) jerk at t =
16 s . Use a step size of ∆t = 2 s .
Solution
ν ν ν
t − i 2 i 2 ( ) ( ) + t t 1 i
j ( ) ( ) t ≈ i 2 ( ) ∆ t t = i
16
∆t =
2
2 =
18 =
( ) i 2 i
16 + 2 ( )
2 =
20 ν +
20 − 2 ν ( ) ( ) 18 ν
16 j ( ) ( ) 16 ≈ 2
( )
2 4
14 × 10 ν ( ) 20 = 2000 ln − 4 9 . 8 ( )
20 14 ×
10 − 2100 ( )
20 = 517 .
35 m/s 4
14 × 10 ν ( ) 18 = 2000 ln − 4 9 . 8 ( )
18 14 ×
10 − 2100 ( )
18 = 453 .
02 m/s 4
14 × 10 ν ( ) 16 = 2000 ln − 4 9 . 8 ( )
16 14 ×
10 − 2100 ( )
16 = 392 .
07 m/s . − ( ) + 517 35 2 453 . 02 392 .
07 j
16 ( ) ≈
4 3 = . 84515 m/s Continuous Differentiation
02.02.11
The exact value of j ( ) 16 can be calculated by differentiating 4 14 × 10
ν ( ) t = 2000 ln − 4 9 . 8 t 14 ×
10 − 2100 t twice as
d a t t and ( ) = [ ] ( )
ν dt d j ( ) t = [ ] a ( ) t dt
Knowing that
d
1 ln t and [ ] ( ) = dt t d
1
1 = − 2 dt t t
4 4
14 × 10 − 2100 t d 14 × 10
a t = 2000 9 .
8
( ) 4 4 −
14 × 10 dt 14 × 10 − 2100 t
4 4
14 × 10 − 2100 t 14 ×
10
2000 1 2100 9 .
8 = ( ) − ( − ) − 4 2
4 14 ×
10 14 × 10 − 2100 t
( )
− 4040 − 29 . 4 t = − + 200 3 t
Similarly it can be shown that
d j t = a t ( ) [ ] ( ) dt
18000 = 2
3 t )
18000
j ( )
16 = 2 [ 200 − + 3 ( 16 )] 3
. 77909 m/s =
The absolute relative true error is
. 77909 . 84515 − ∈ = × 100 t . 77909
= 8 . 4797 %
The formula given by Equation (5) is a forward difference approximation of the second derivative and has an error of the order of O x
( ) ∆ . 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
f ′′ x i i i 2 f ′′′ x 3 f ′ ′′′ x 4 f x = f x f ′ x ∆ x ∆ x ∆ x ∆ x ... (6) ( ) ( ) ( ) + + + + + i 1 i i ( )( ) ( )( ) ( )( )
3 ! 4 !
where
−
2 ! 3 ! 4 !
where
x = x − x i 1 i Δ −
Adding Equations (6) and (7), gives 2 4
∆ x f x f x 2 f x f ′′ x x f ′′′ x ...
( ) ( ) = ( ) ( )( ) ∆ ( )( ) i 1 i 1 i i i + + + + − +
12
′ ′′′
22 f ( ) ( ) x f x f ( )( ) x ∆ x
− 1 f x ′′ ...
( ) = − i 2
12 ( ) ∆ x 2
2 f ( ) ( ) x f x 1
O x
= ( ) + 2∆
x( ) ∆ Example 5
The velocity of a rocket is given by 4 14 × 10
ν ( ) t = 2000 ln − 4 9 . 8 t , ≤ t ≤ 30 ,
14 10 2100 t × −
(a) Use the central difference approximation of the second derivative of ( ) t
ν to calculate the
jerk at t =
16 s . Use a step size of ∆t = 2 s .
Solution
The second derivative of velocity with respect to time is called jerk. The second order approximation of jerk then is
2 t t ν − ν ( ) ν i 1 i ( ) i 1
− + j t
( ) ( ) ≈ i 2 ( ) ∆ t t = i
16
∆t =
2
= + t t ∆ t
2 =
18 =
t = t − ∆ t
16
2 = −
14 =
ν ν ν
18 − + 2 ( ) ( )
16
14 j 16 ≈
( ) ( ) 2
2 ( ) 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
× − = ∈ t % 077992 . =
2
10
14
10
14 2000 ln
14 4 4 −
− × ×
= ν
= 334 24 . m/s ( ) ( ) ( ) ( )
( ) 2
14
14 8 .
16
2
18
16
ν ν ν
( )
4 334 24 .
392 07 .
2 453 02 .
The absolute relative true error is
100 77908 . . 77908 77969 .
9 14 2100
( )
Continuous Differentiation
= ν
02.02.13 ( ) ( )
( )
18 8 .
9 18 2100
10
14
10
14 2000 ln
18 4 4 −
− × ×
= 453 02 . m/s ( ) ( )
= 392 07 . m/s ( ) ( )
( )
16 8 .
9 16 2100
10
14
10
14 2000 ln
16 4 4 −
− × ×
= ν