Title: Numerical Differentiation and Integration
1Numerical Differentiation and Integration
2Representing, manipulating functions
- Represent f(x) when it can be evaluated at any
point - Represent f(x) when (x1,f1), (x2,f2),, (xn,fn)
are available (only) - Interpolation - Smoothing
- Num Differentiation
- Num Integration
3Representing, manipulating functions that can be
evaluated anywhere
Integration Not Sensitive to Round-Off Step-siz
e the less, the result is better (except for
VERY small step size)
Differentiation Sensitive to Round-Off Step-siz
e optimum
4Numerical Differentiation of functions that can
be evaluated everywhere
Backward Divided Difference
Forward Divided Difference
Central Divided Difference
First or Higher Order
5Taylors series
- Or, using a simpler notation,
- We assume that f and all its derivatives are
continuous between xi and xi1
6Taylors series
- We know everything at the central point, xi.
i.e., we know fi, fi, fi, etc. - We know nothing at other points but f(x) no
derivatives.
7Truncation error
- If we save only the first 3 terms,
- Then the truncation error is
- Or, etr O(h3) (third order)
8Derive forward diff. for fi
Rearranging,
9Derive Central Diff. of f
Taylors series
substract
Divide by 2h
Sign does not matter
10Derive central diff. for fi
Adding,
Rearranging,
11Example Numerical Derivatives (Forward Divided
Difference)
First Derivative
Second Derivative
1st order
2nd order
See more forward finite-differences In your book
12Numerical Integration
13Representing, manipulating functions that can be
evaluated anywhere
Integration Not Sensitive to Round-Off Step-siz
e the less, the result is better (except for
VERY small step size)
Differentiation Sensitive to Round-Off Step-siz
e optimum
14Numerical Integration Engineering Meaning
- Determine Hydrocarbon Volume if re 3000 ft and
re
How would you calculate average porosity? How
would you calculate average water saturation? Do
you need them to get the Hydrocarbon Volume?
15Numerical Integration(Closed Formulas)
Trapesoidal Rule
Simpsons Rule (simple)
h
h
h
16Trapesoidal Rule (one panel)
h
17Trapezoidal rule(n panels)
18Repeated Simpson's 1/3 rule
weights 1 4 2 4 4 2 4 1
panel
h
h
k panels 2k intervals h ?
a
b
(k2)
(general)
19How to program (the repeated) Simpsons 1/3 rule
- Select number of panels k (2 k will give the
total number of intervals) - h(b-a)/(2k)
- Treat the first and last point separately
- Sum the second, fourth etc. and multiply by 4
- Sum the third, fifth etc. and multiply by 2
- Do the first and last, do not forget the h/3
20Integration accuracy order
- Trapezoidal O(h2)
- Simpsons 1/3 rule - O(h3)
21Richardson extrapolation
- Do calculation with h and with h/2
- Express remainder term as a power of h
- Try to extrapolate to infinitely small h
Example repeated Simpsons rule
22Integration of a function available only at
discrete points
23A car laps a race track in 84 seconds. The speed
of the car at each 6-second interval is
determined by a radar gun.Length of the lap?
Time, sec Speed, ft/sec