This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 0306381 Applied Programming üFixedPoint (Q Number) Arithmetic FNumerical Derivative Numerical Differentiation Motivation
Why differentiate numerically? (Why approximate the derivative?) • Analytical differentiation is difficult. • Analytical differentiation is not possible.
In applied programming situations, an analytical derivative rarely exists. 12 Derivative
Slope of tangent line
• Derivative of f (x) at x0 f ( x + h)  f ( x) f ( x ) = lim h ®0 h
' f (x) f ¢(x)
(true derivative) f (x) x0 x 13 Numerical Issues with Derivative Definition
f ' ( x ) = lim
h ®0 f ( x + h)  f ( x) h What aspect of definition is numerically problematic? h ® 0 with division by h x Division by zero x Division by something very close to 0 14 Practical Issues with Derivative Definition
f ( x + h)  f ( x) f ( x ) = lim h ®0 h
' What aspect of definition is practically problematic? h®0 • In practice, programmer may not have control
Þ h can not be arbitrarily small • Known values of x and f (x) may be far apart
Þ h is too large for accurate approximation
15 A Different Approach: Discrete Mathematics
Known values: {(xi, yi)} • So far, view has been yi = f(xi), where f (x) is a continuous function.
Rate of change of continuous f(x)?
Derivative. • Consider instead f (x) as a discrete function.
Discrete analogue of derivative?
Difference equation. 16 Forward Difference Equation f ( xi +1 )  f ( xi ) f ( xi ) » xi +1  xi
' h Requirements for derivative at point, xi: • Function value at point, xi • Function value at next point, xi+1 Any problems with these requirements?
What if variable is time?
Computation for current time requires value from future.
17 Backward Difference Equation f ( xi )  f ( xi 1 ) f ( xi ) » xi  xi 1
' h Requirements for derivative at point, xi: • Function value at point, xi • Function value at previous point, xi+1 18 Central Difference Equation f ( xi +1 )  f ( xi 1 ) f ( xi ) » xi +1  xi 1
' h Requirements for derivative at point, xi: • Function value at next point, xi • Function value at previous point, xi+1 Advantages? Disadvantages?
Increases h Symmetric about point, xi 19 TwoPoint Difference Summary • All are linear approximations based on two points. • All require “small” h to get a tangent line.
Figure used with permission from support materials for Applied Numerical Methods for Engineers and Scientists, S. S. Rao, Prentice Hall, 2002. 20 ThreePoint Difference Equations
• Forward  f ( xi + 2 ) + 4 f ( xi +1 )  3 f ( xi ) f ( xi ) » xi + 2  xi
' • Backward 3 f ( xi )  4 f ( xi 1 ) + f ( xi 2 ) f ( xi ) » xi  xi  2
'
21 Data: 2D Figure used with permission from support materials for Applied Numerical Methods for Engineers and Scientists, S. S. Rao, Prentice Hall, 2002. 22 Data: 3D Figure used with permission from support materials for Applied Numerical Methods for Engineers and Scientists, S. S. Rao, Prentice Hall, 2002. 23 Data considerations
These equations require uniform spacing (fixed h). • Realistic for digitally sampled data • Many data sets not uniformly sampled
– General 3point equations exist – More complex computationally 24 ...
View
Full
Document
 Spring '10
 RoyMelton

Click to edit the document details