Numerical differentiation Recall finite differences from first week Derived from Taylor series
Neglecting all tersms higher than first order That’s the forward difference - also backwards and centered difference
Why is centered finite difference O(h2)? Subtract second equation from first
We can combine Taylor series expansions in many different ways to get estimates of derivatives Example: backwards second derivative, O(h2) Start with
Multiply first equation by -5, second equation by 4 and add together +
Multiply third equation by -1 and add to above result + Rearrange
Where did I get -5, 4,-1? We multiply 1st equation by a, second by b, third by c
Now sum all equations and collect terms Decide what derivatives we want to make disappear - want a second derivative only - eliminate first and third
Three unknowns - 2 equations - make an assumption Let c=-1 Can solve by hand
If we have more derivatives to get rid of, use matrix methods - always one assumption
More Richardson extrapolation Recall Can do the same thing with derivatives
Use same approach as Romberg integration with halving the step size Example: Formula for active lateral pressure coefficient Ka with internal angle of friction f and wall with slope b and flat top is Use Richardson/Romberg approach to estimate at b=10 degrees and f=15 degrees
Use O(h2) estimates to get O(h6) estimate
Now do Richardson/Romberg trick
Derivatives of unequally spaced data Can use matrix approach with different amounts of h Example: given values of f at x=(1,2,5.5,9) determine f’’ at 2
Let h=1, x=2 (values at 1,2,5.5,9) Equations to get rid of f’ and f’’’ are and assume a value for c
Let c=1, then a=-22.8667, b=-8.5333 then or
Derivatives of unequally spaced data Another way is to take derivative of interpolating polynomial Lagrange polynomial - second order in this case
Derivatives and integrals with errors in data Errors in data points can cause problems esp. with differentiation Example: with and without noise True derivative is 2x-6
Look at ratio of noise in y to noise in dy/dx For differentiation, fit a smooth line to the data, then take derivative