Differentiation-Continuous
Functions
Differentiation – Continuous
Functions
[Link]
What is Differentiation?
• Differentiation is the process of finding the
rate of change of a function.
• It tells us how fast a value is changing at any
point.
• The derivative represents the instantaneous
slope of the curve.
Derivative and Tangent Line
Derivative and Tangent Line
Forward Difference Approximation
lim f ( x + Δx ) − f ( x )
f ′( x ) =
Δx → 0 Δx
For a finite ' Δx'
f (x + ∆x ) − f ( x )
f ′( x ) ≈
∆x
3 [Link]
Graphical Representation Of
Forward Difference
Approximation
f(x)
x x+Δx
Figure 1 Graphical Representation of forward difference approximation of first derivative.
4 [Link]
Example 1
The velocity of a rocket is given by
14 × 10 4
ν (t ) = 2000 ln − 9.8t ,0 ≤ t ≤ 30
14 × 10 4
− 2100t
where 'ν' is given in m/s and 't ' is given in seconds.
a) Use forward difference approximation of the first derivative of ν(t ) to
calculate the acceleration at t = 16 s . 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).
5 [Link]
Example 1 Cont.
Solution
ν (ti +1 ) −ν (ti )
a(ti ) ≈
∆t
ti = 16
Δt = 2
ti +1 = ti + ∆t
= 16 + 2
= 18
ν (18) −ν (16)
a(16 ) ≈
2
6 [Link]
Example 1 Cont.
14 × 10 4
ν (18) = 2000 ln − 9.8(18)
14 × 10 − 2100(18)
4
= 453.02m/s
14 ×10 4
ν (16) = 2000 ln − 9.8(16 )
14 ×10 − 2100(16 )
4
= 392.07 m/s
Hence
ν (18) −ν (16)
a(16 ) ≈
2
7 [Link]
Example 1 Cont.
453.02 − 392.07
≈
2
≈ 30.474m/s 2
b) The exact value of a (16 ) can be calculated by differentiating
14 ×10 4
ν (t ) = 2000 ln − 9.8t
14 ×10 − 2100t
4
as
a(t ) = [ν(t )]
d
dt
8 [Link]
Example 1 Cont.
Knowing that
d 1 1
d
[ln(t )] = 1 and
dt t
= −
t2
dt t
14 × 10 4 − 2100t d 14 × 10 4
a (t ) = 2000
dt 14 × 10 4 − 2100t − 9.8
14 × 10 4
14 × 10 4 − 2100t × 4
(− 1) (− 2100 ) − 9.8
14 10
= 2000
14 × 10 4
(
14 × 10 4 − 2100t )2
− 4040 − 29.4t
=
− 200 + 3t
9 [Link]
Example 1 Cont.
− 4040 − 29.4(16 )
a (16 ) =
− 200 + 3(16)
= 29.674m/s 2
The absolute relative true error is
True Value - Approximate Value
∈t = x100
True Value
29.674 − 30.474
= x100
29.674
= 2.6967%
10 [Link]
Backward Difference Approximation of the
First Derivative
We know
lim f ( x + Δx ) − f ( x )
f ′( x ) =
Δx → 0 Δ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
11 [Link]
Backward Difference Approximation of the
First Derivative Cont.
This is a backward difference approximation as you are taking a point
backward from x. To find the value of f ′(x ) at x = xi, we may choose another
point ' Δx' behind as x = x . This gives
i −1
f ( xi ) − f ( xi −1 )
f ′( xi ) ≈
∆x
f ( xi ) − f ( xi −1 )
=
xi − xi −1
where
Δx = xi − xi −1
12 [Link]
Backward Difference Approximation of the
First Derivative Cont.
f(x)
x-Δx x
Figure 2 Graphical Representation of backward difference
approximation of first derivative
13 [Link]
Example 2
The velocity of a rocket is given by
14 × 10 4
ν (t ) = 2000 ln − 9.8t ,0 ≤ t ≤ 30
14 × 10 4
− 2100t
where 'ν' is given in m/s and 't ' is given in seconds.
a) Use backward difference approximation of the first derivative of ν(t )
to calculate the acceleration at t = 16 s . Use a step size of Δt = 2 s .
b) Find the absolute relative true error for part (a).
14 [Link]
Example 2 Cont.
Solution
ν (ti ) −ν (ti −1 )
a(t ) ≈
∆t
ti = 16
Δt = 2
ti −1 = ti − ∆t
= 16 − 2
= 14
ν (16) −ν (14)
a(16 ) ≈
2
15 [Link]
Example 2 Cont.
14 × 10 4
ν (16) = 2000 ln − 9.8(16)
14 × 10 − 2100(16)
4
= 392.07 m/s
14 × 10 4
ν (14 ) = 2000 ln − 9.8(14 )
14 × 10 − 2100(14 )
4
= 334.24m/s
ν (16) −ν (14)
a(16 ) ≈
2
392.07 − 334.24
=
2
≈ 28.915m/s 2
16 [Link]
Example 2 Cont.
The exact value of the acceleration at t = 16 s from Example 1 is
a(16 ) = 29.674m/s 2
The absolute relative true error is
29.674 − 28.915
∈t = x100
29.674
= 2.5584%
17 [Link]
Derive the forward difference approximation
from Taylor series
Taylor’s theorem says that if you know the value of a function ' f ' at a point
xi and all its derivatives at that point, provided the derivatives are
continuous between xi and xi +1 , then
f ′′(xi )
f ( xi +1 ) = f (xi ) + f ′(xi )(xi +1 − xi ) + (xi +1 − xi )2 +
2!
Substituting for convenience Δx = xi +1 − xi
f ′′( xi )
f ( xi +1 ) = f (xi ) + f ′( xi )Δx + (Δx )2 +
2!
f ( xi +1 ) − f ( xi ) f ′′(xi )
f ′( xi ) = − (∆x ) +
∆x 2!
f ( xi +1 ) − f ( xi )
f ′( xi ) = + 0(∆x )
∆x
18 [Link]
Derive the forward difference approximation
from Taylor series Cont.
The (0∆x ) term shows that the error in the approximation is of the order
of (Δx ) Can you now derive from Taylor series the formula for backward
divided difference approximation of the first derivative?
As shown above, both forward and backward divided difference
approximation of the first derivative are accurate on the order of(0∆x )
Can we get better approximations? Yes, another method to approximate
the first derivative is called the Central difference approximation of
the first derivative.
19 [Link]
Derive the forward difference approximation
from Taylor series Cont.
From Taylor series
f ′′( xi ) ′′′( )
f ( xi +1 ) = f ( xi ) + f ′( xi )Δx + (Δx )2 + f xi (Δx )3 +
2! 3!
f ′′( xi ) ′′′( )
f ( xi −1 ) = f ( xi ) − f ′( xi )Δx + (Δx )2 − f xi (Δx )3 +
2! 3!
Subtracting equation (2) from equation (1)
2 f ′′′( xi )
f ( xi +1 ) − f ( xi −1 ) = f ′( xi )(2Δx ) + (Δx )3 +
3!
f ( xi +1 ) − f ( xi −1 ) f ′′′( xi )
f ′( xi ) = − (∆x )2 +
2∆x 3!
f ( xi +1 ) − f ( xi −1 )
f ′( xi ) = + 0(∆x )
2
2∆x
20 [Link]
Central Divided Difference
Hence showing that we have obtained a more accurate formula as the
error is of the order of 0(Δx )2 .
f(x)
x
x-Δx x x+Δx
Figure 3 Graphical Representation of central difference approximation of first derivative
21 [Link]
Example 3
The velocity of a rocket is given by
14 × 10 4
ν (t ) = 2000 ln − 9.8t ,0 ≤ t ≤ 30
14 × 10 4
− 2100t
where 'ν' is given in m/s and 't ' is given in seconds.
(a) Use central divided difference approximation of the first derivative of ν(t )
to calculate the acceleration at t = 16 s . Use a step size of Δt = 2 s .
(b) Find the absolute relative true error for part (a).
22 [Link]
Example 3 cont.
Solution
ν (ti +1 ) −ν (ti −1 )
( )
a ti ≈
2∆t
ti = 16
∆t = 2
ti +1 = ti + ∆t
= 16 + 2
= 18
ti −1 = ti − ∆t
= 16 − 2
= 14
ν (18) −ν (14)
a(16 ) ≈
2(2 )
ν (18) −ν (14)
≈
4
23 [Link]
Example 3 cont.
14 × 10 4
ν (18) = 2000 ln − 9.8(18)
14 × 10 4
− 2100(18 )
= 453.02m/s
14 × 10 4
ν (14 ) = 2000 ln − 9.8(14 )
14 × 10 − 2100(14 )
4
= 334.24m/s
ν (18) −ν (14)
a(16 ) ≈
4
453.02 − 334.24
≈
4
≈ 29.694m/s 2
24 [Link]
Example 3 cont.
The exact value of the acceleration at t = 16 s from Example 1 is
a (16 ) = 29.674m/s 2
The absolute relative true error is
29.674 − 29.694
∈t = ×100
29.674
= 0.069157%
25 [Link]
Comparision of FDD, BDD, CDD
The results from the three difference approximations are given in Table 1.
Table 1 Summary of a (16) using different divided difference approximations
Type of Difference a(16 )
∈t %
Approximation
(m / s )
2
Forward 30.475 2.6967
Backward 28.915 2.5584
Central 29.695 0.069157
26 [Link]
Finding the value of the derivative
within a prespecified tolerance
In real life, one would not 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 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
14 × 10 4
ν (t ) = 2000 ln − 9.8t
14 × 10 − 2100t
4
at t = 16 using the backward divided difference scheme.
27 [Link]
Finding the value of the derivative
within a prespecified tolerance Cont.
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 v ′(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
28 [Link]
Finding the value of the derivative
within a prespecified tolerance Cont.
From the above table, one can see that the absolute relative
approximate error decreases as the step size is reduced. At ∆t = 0.125
the absolute relative approximate error is 0.16355%, meaning that
at least 2 significant digits are correct in the answer.
29 [Link]
Finite Difference Approximation of
Higher Derivatives
One can use Taylor series to approximate a higher order derivative.
For example, to approximate f ′′( x ) , the Taylor series for
f ′′(xi ) ′′′( )
f ( xi + 2 ) = f ( xi ) + f ′(xi )(2Δx ) + (2Δx )2 + f xi (2Δx )3 +
2! 3!
where
xi + 2 = xi + 2Δx
f ′′(xi ) ′′′( )
f ( xi +1 ) = f ( xi ) + f ′( xi )(∆x ) + (∆x )2 + f xi (∆x )3
2! 3!
where
xi −1 = xi − Δx
30 [Link]
THE END
[Link]