13 Differentiation
13 Differentiation
13 Differentiation
Math 315
Numerical Analysis
Differentiation and Integration I
1/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
1 Differentiation
2/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Differentiation
Introduction
2
2Rm Vm + f Rm fr
V (r) = 2 2
r−
Rm + r 2
3/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Differentiation
assumptions
f (x) differentiable
f (x) defined in interval centered at x
4/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Differentiation
f (x + h) − f (x) h
f 0 (x) − ≈ f 00 (ξ)
h 2
assumptions
assume f (x) has a second derivative at x
h sufficiently small
Taylor series:
h2 00 hk hk+1 (k+1)
f (x+h) = f (x)+hf 0 (x)+ f (x)+· · ·+ f (k) (x)+ f (ξ)
2 k! (k + 1)!
5/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Differentiation
f (a + h) − f (a)
f 0 (a) ≈
h
How do we choose h?
f (a + h) required, i.e. choose based on availability of data
generally want derivative across some interval, [α, β], β−α
h “steps”
required → consider desired efficiency
consider desired accuracy of approximation
“discretization error” or “truncation error” shrinks as h shrinks if
f is sufficiently smooth → make h as small as possible
limited by the effects of catastrophic cancelation in practice
roundoff effects tend to dominate for values of h much smaller
√
than εm
6/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Differentiation
Taylor Series
h2 00 hk (k) hk+1 (k+1)
f (x + h) = f (x) + hf 0 (x) + f (x) + · · · + f (x) + f (ξ)
2 k! (k + 1)!
forward difference
h2 00
f (a + h) = f (a) + hf 0 (a) + f (ξ)
2
f (a + h) − f (a) h
f 0 (a) = − f 00 (ξ)
h 2
backward difference
h2 00
f (a − h) = f (a) − hf 0 (a) + f (ξ)
2
f (a) − f (a − h) h
f 0 (a) = + f 00 (ξ)
h 2
7/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Differentiation
forward difference
f (a + h) − f (a)
f 0 (a) =
h
backward difference
f (a) − f (a − h)
f 0 (a) =
h
8/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Differentiation
centered difference
h2 00 h3 (3)
f (a + h) = f (a) + hf 0 (a) + f (a) + f (ξ1 )
2 3!
h2 00 h3 (3)
f (a − h) = f (a) − hf 0 (a) + f (a) − f (ξ2 )
2 3!
2h3 (3)
f (a + h) − f (a − h) = 2hf 0 (a) + f (ξ)
3!
f (a + h) − f (a − h) h2 (3)
f 0 (a) = − f (ξ)
2h 3!
9/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Differentiation
centered difference
f (a + h) − f (a − h)
f 0 (a) =
2h
f (a − 2h) − 4f (a − h) + 3f (a)
f 0 (a) =
2h
10/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Differentiation
1
f 0 (a) = (f (a − 2h) − 8f (a − h) + 8f (a + h) − f (a + 2h))
12h
11/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
Numerical Differentiation
example: f (x) = ex at x = 0
f 0 (x) = 1
12/13
Prof. Talea L. Mayo Math 315 Numerical Analysis
Differentiation
13/13
Prof. Talea L. Mayo Math 315 Numerical Analysis