Sie sind auf Seite 1von 49

Continuous Functions

At the end of the period, you should be


able to:
Find the derivative of a continuous
function at a certain number using
divided difference formulas.
Find the derivative of a discrete
function at a certain number using
divided difference formulas.
Find the derivative of unequally spaced
data.
lim f x x f x
f x
x 0 x

f x x f x
f x
x
Forward Difference Approximation of
the First Derivative:
Graphical Representation:

f(x)

x x+x
Example:
The velocity of a rocket is given by
14 104
t 2000 ln 9.8t ,0 t 30
14 10 2100t
4

where v(t) is in m/sec and t in sec.


(a) Use FDA of the first derivative of v(t) to
calculate the acceleration at t=16sec. Use a
step size of 2 sec.
(b) Find the exact value of the acceleration
of the rocket at t=16sec and calculate the
absolute relative true error.
Solution:
(a) acceleration at t=16sec
ti 1 ti
ati
t
ti 1 ti t
ti 16 t 2 16 2
18

18 16
a16
2
Solution:
(a) acceleration at t=16sec
14 10 4
18 2000 ln 9.818 453.02m/s
14 10 210018
4

14 104
16 2000 ln 9.816 392.07m/s
14 10 210016
4

Hence
18 16 453.02 392.07
a16 30.474m/s 2
2 2
Solution:
(b) exact value of the acceleration

a t t
d
dt
14 104 2100t d 14 104
2000 9.8
14 10 4
dt 14 10 2100t
4

14 104 2100t 4
1 2100 9.8
14 10
2000
14 10 4

14 104 2100t 2

4040 29.4t

200 3t

4040 29.416
a 16 29.674m/s 2
200 316
Solution:
(b) the absolute relative true error.

True Value - Approximate Value


t x100
True Value

29.674 30.474
x100
29.674

2.6967%
f x x f x
f x
x

f x x f x f x f x x
f x
x x
Example:
The velocity of a rocket is given by
14 104
t 2000 ln 9.8t ,0 t 30
14 10 2100t
4

where v(t) is in m/sec and t in sec.


(a) Use BDA of the first derivative of v(t)
to calculate the acceleration at t=16sec. Use
a step size of 2 sec.
(b) Find the exact value of the acceleration
of the rocket at t=16sec and calculate the
absolute relative true error.
Solution:
(a) acceleration at t=16sec
ti ti 1
at
t
ti 1 ti t
ti 16 t 2 16 2
14

16 14
a16
2
Solution:
(a) acceleration at t=16sec
14 10 4
16 2000 ln 9.816 392.07m/s
14 10 210016
4

14 104
14 2000 ln 9.814 334.24m/s
14 10 210014
4

16 14 392.07 334.24
a16 28.915m/s 2
2 2
Solution:
(b) exact value of the acceleration
4040 29.416
a 16 29.674m/s 2
200 316

the absolute relative true error.


29.674 28.915
t x100 2.5584%
29.674
f xi
f xi 1 f xi f xi xi 1 xi xi 1 xi 2
2!

f xi
f xi 1 f xi f xi x x 2
2!
f xi 1 f xi f xi
f x i x
x 2!
f xi 1 f xi
f x i 0x
x
Derive the central difference
approximation from Taylor series:
f xi
x 2 f xi x 3

f xi 1 f xi f xi x
2! 3!

f xi
x 2 f xi x 3

f xi 1 f xi f xi x
2! 3!

Subtracting equation (2) from equation (1)


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

x
x-x x x+x
Example:
The velocity of a rocket is given by
14 104
t 2000 ln 9.8t ,0 t 30
14 10 2100t
4

where v(t) is in m/sec and t in sec.


(a) Use CDA of the first derivative of v(t) to
calculate the acceleration at t=16sec. Use a
step size of 2 sec.
(b) Find the exact value of the acceleration
of the rocket at t=16sec and calculate the
absolute relative true error.
Solution:
(a) acceleration at t=16sec

ti 1 ti 1
ati
2t
ti 1 ti t ti 1 ti t
ti 16 t 2 16 2
16 2
18 14

18 14 18 14
a16
22 4
Solution:
(a) acceleration at t=16sec

14 10 4
18 2000 ln 9.818 453.02m/s
14 10 210018
4

14 104
14 2000 ln 9.814 334.24m/s
14 10 210014
4

18 14 453.02 334.24
a16 29.694m/s 2
4 4
Solution:
(b) exact value of the acceleration
4040 29.416
a 16 29.674m/s 2
200 316

the absolute relative true error.

29.674 29.694
t 100 0.069157%
29.674
Comparison of FDD, BDD, CDD:

Type of
Difference a16 m / s 2 t %
Approximation
Forward 30.475 2.6967
Backward 28.915 2.5584
Central 29.695 0.069157
Finding the value of the derivative within a
prespecified tolerance:
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.
Example:
Using BDD
14 104
t 2000 ln 9.8t ,0 t 30
14 10 2100t
4

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
Finite Difference Approximation of
Higher Derivatives (using Taylors thm):
f xi
2x 2 f xi 2x 3

f x f x f x 2x
i2 i i
2! 3!
f xi f xi
f xi 1 f xi f xi x x
2
x 3
2! 3!

Subtracting 2 times eqn (2) from eqn (1)

f xi 2 2 f xi 1 f xi f xi x 2 f xi x 3

f xi 2 2 f xi 1 f xi
f xi 0x
x 2
Example:
The velocity of a rocket is given by
14 104
t 2000 ln 9.8t ,0 t 30
14 10 2100t
4

where v(t) is in m/sec and t in sec.


(a) Use FDD to find the second derivative of
v(t) at t=16sec. Use a step size of 2 sec.
(b) Find the exact value of the second
derivative at t=16sec and calculate the
absolute relative true error.
Solution:
(a) second derivative at t=16sec
ti 2 2 ti 1 ti
j ti
t 2

ti 1 ti t ti 2 ti 2t
ti 16 t 2 16 2 16 22
18 20

20 2 18 16
j 16
22
Solution:
(a) second derivative at t=16sec
14 10 4
20 2000 ln 9.820 517.35m/s
14 10 210020
4

14 10 4
18 2000 ln 9.818 453.02m / s
14 10 210018
4

14 10 4
16 2000 ln 9.816 392.07m/s
14 10 210016
4

517.35 2453.02 392.07


j 16 0.84515m/s 3
4
Solution:
(b) exact value of the second derivative
a t
d
t 4040 29.4t
dt 200 3t

j t
d
at 18000 2
dt ( 200 3t )

j 16
18000
0 .77909m/s 3

[200 3(16)]2

the absolute relative true error.


0.77909 0.84515
t 100 8.4797 %
0.77909
Central Difference Approximation of
Higher Derivatives (using Taylors thm):
f xi
f xi 1 f xi f xi x x 2 f xi x 3 f xi x 4
2! 3! 4!
f xi f xi f xi
f xi 1 f xi f xi x x x x 4
2 3

2! 3! 4!

Adding equations (6) and (7), gives

f xi 1 f xi 1 2 f xi f xi x f xi
2 x 4

12
f x i 1 2 f x i f x i 1
f xi 2
0 x
x 2
Example:
The velocity of a rocket is given by
14 104
t 2000 ln 9.8t ,0 t 30
14 10 2100t
4

where v(t) is in m/sec and t in sec.


(a) Use CDD to find the second derivative of
v(t) at t=16sec. Use a step size of 2 sec.
(b) Find the exact value of the second
derivative at t=16sec and calculate the
absolute relative true error.
Solution:
(a) second derivative at t=16sec
ti 1 2 ti ti 1
ati
t 2
ti 1 ti t ti 1 ti t
t i 16 t 2 16 2 16 2
18 14

18 2 16 14
j 16
2 2
Solution:
(a) second derivative at t=16sec
14 10 4
18 2000 ln 9.818 453.02m/s
14 10 210018
4

14 10 4
16 2000 ln 9.816 392.07m/s
14 10 210016
4

14 10 4
14 2000 ln 9.814 334.24m/s
14 10 210014
4

18 2 16 14 453.02 2392.07 334.24


j 16
22 4
0.77969m/s 3
Solution:
(b) exact value of the second derivative
j t a t
d 18000
dt ( 200 3t )2

j 16
18000
0.77909m/s 3

[200 3(16)]2

the absolute relative true error.


0.77908 0.78
t 100 0.077992%
0.77908
Discrete Functions
lim f x x f x
f x
x 0 x

f x x f x
f x
x
Example:
The velocity of a rocket is given as a
function of time
t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67

Use FDA of the first derivative of v(t) to


calculate the acceleration at t=16sec.
Solution:
To find the acceleration at t=16s , we need to
choose the two values closest to t=16s , that
also bracket t=16s to evaluate it. The two
points are t=15s and t=20s. t ti 1 ti
20 15
5
20 15
a16
ti 1 ti
ati 5
517.35 362.78
t
5
30.914 m/s 2
Direct Fit Polynomials:
Using interpolation, find the polynomial
Pn x a0 a1 x an1 x n1 an x n

To find the first derivative,

Pn x a1 2a2 x n 1an 1 x n 2 nan x n 1


dPn ( x )
dx

Similarly other derivatives can be found.


Example:
The velocity of a rocket is given as a
function of time t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Using the third order polynomial interpolant
for velocity, find the acceleration of the
rocket at t=16sec.
Solution:
For the third order polynomial (also called
cubic interpolation), we choose the velocity
given by
vt a0 a1t a2 t a3t
2 3

Using four points


v10 227.04 a0 a1 10 a2 10 a3 10
2 3

v15 362.78 a0 a1 15 a2 15 a3 15
2 3

v20 517.35 a0 a1 20 a2 20 a3 20
2 3

v22.5 602.97 a0 a1 22.5 a2 22.5 a3 22.5


2 3
Solution:
Writing the four equations in matrix form, we
have 1 10 100 1000 a0 227.04
1 15 225 3375 a 362.78
1
1 20 400 8000 a 2 517.35

1 22.5 506.25 11391 3
a 602.97
Solving the above four equations gives
a0 4.3810 a1 21.289 a2 0.13065 a3 0.0054606

Hence
vt a0 a1t a2t 2 a3t 3
4.3810 21.289t 0.13065t 2 0.0054606t 3 , 10 t 22.5
Solution:
The acceleration at t=16 is given by
t 4.3810 21.289t 0.13065t 2 0.0054606t 3 ,10 t 22.5

at vt 4.3810 21.289t 0.13065t 2 0.0054606t 3


d d
dt dt

21.289 0.26130t 0.016382t 2 , 10 t 22.5

a16 21.289 0.2613016 0.01638216


2

29.664m/s 2
Lagrange Polynomials:
Using interpolation, find the polynomial
n
fn ( x) Li ( x ) f ( xi )
i 0

f2 x
x x1 x x2 f x x x0 x x2 f x x x0 x x1 f x
x0 x1 x0 x2 0 x1 x0 x1 x2 1 x2 x0 x2 x1 2

Find the derivatives,


2 x x1 x2 2 x x0 x 2 2 x x0 x1
f 2 x f x0 f x1 f x
x0 x1 x0 x2 x1 x0 x1 x2 x2 x0 x2 x1 2

f 2 x f x0 f x1 f x2
2 2 2
x0 x1 x0 x2 x1 x0 x1 x2 x2 x0 x2 x1
Example:
The velocity of a rocket is given as a
function of time t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Find the acceleration of the rocket at
t=16sec using second order Lagrangian
polynomial interpolation for velocity .
Solution:
t t1 t t 2 t t 0 t t 2 t t 0 t t1
v(t ) v(t 0 ) v(t1 ) v(t 2 )
t 0 t1 t 0 t 2 t1 t 0 t1 t 2 t 2 t 0 t 2 t1

2t t1 t 2 2t t 0 t 2 2t t0 t1
at t t1 t t t t t2

t 0 t1 t 0 t 2 0 t1 t 0 t1 t 2 2 0 2 1

216 15 20 216 10 20 216 10 15


a16 227.04 362.78 20 1020 15 517.35

10 1510 20 15 1015 20

0.06227.04 0.08362.78 0.14517.35

29.784m/s 2
The Calculus Seven, by Louies Leithold
Holistic Numerical Methods Institute by Autar
Kaw and Charlie Barker.
Numerical Methods for Engineers by Chapra
and Canale

Das könnte Ihnen auch gefallen