Num 1
Num 1
NUMERICAL DIFFERENTIATION
Finite differences
Procedure
;
if we set = 1 in the formula for the second derivative, we find (without
third differences):
Note that, if one retains only one term, one arrives at the well-known
formulae:
Example
We will estimate the values of f'(0.1) and f"(0.1) for f(x) = ex, using the
data in STEP 20.
Checkpoint
1. Derive formulae involving backward differences for the first and second
derivatives of a function.
2.The function is tabulated for x = 1.00(0.05)1.30 to 5D:
3Use Tay. lor series to find the truncation errors in the formulae:
a.
b.
c.
d.
STEP 30
NUMERICAL INTEGRATION 1
It is well known that the definite integral may be interpreted as the area under
the curve y = f (x) for and may be evaluated by subdivision of the
interval and summation of the component areas. This additive property of the
definite integral permits evaluation in a piecewise sense. For any subinterval
of the interval , we may approximate f (x) by the
interpolating polynomial Pn(x). Then we obtain the approximation
,
which will be a good approximation, provided n is chosen so that the error |f
(x) - Pn(x)| in each tabular subinterval is sufficiently
small. Note that for n > 1 the error is often alternately positive and negative in
successive subintervals and considerable cancellation of error occurs; in
contrast with numerical differentiation, quadrature is inherently accurate!
It is usually sufficient to use a rather low degree, polynomial approximation
over any subinterval .
such that b = a + Nh. Then one can use the additive property
Accuracy
.
(STEP 2 regarding the concept of truncation error.) Ignoring higher-
order terms, one arrives at an approximate bound on this error when
using the trapezoidal rule over N subintervals:
Example
using the trapezoidal rule and the data in STEP 20:. If we use T(h) to
denote the approximation with strip width h, we obtain
Checkpoint
EXERCISES
using the trapezoidal rule and the data given in Exercise 2 of the
preceding Step.
5. Use the trapezoidal rule with h = 1,0.5, and 0.25 to estimate the
value of the integral
STEP 31
NUMERICAL INTEGRATION
Simpson's Rule
Simpson's Rule
A parabolic arc is fitted to the curve y = f(x) at the three tabular points
Hence, if N - (b - a) is even, one obtains Simpson's Rule:
where
Accuracy
then
.
Note that the error bound is proportional to h4, compared with h2 for the
cruder trapezoidal rule. Note that Simpson's rule is exact for cubics!
Example
,
using Simpson's rule and the data in Exercise 2 of STEP29. If we choose
h = 0.15 or h = 0.05, there will be an even number of intervals. Denoting
the approximation with strip width h by S(h), we obtain
and
whence it is 0.000 000 8 for h = 0.15 and 0.000 000 01 for h = 0.05.
Note that the truncation error is negligible; within round-off error, the
estimate is 0.32148(6).
Checkpoint
EXERCISES
to 4D.
.
Estimate to 5D the resulting error, given that the true value of the
integral is 0.26247.
STEP 32
NUMERICAL INTEGRATION 3
where the weights wl, w2 and the abscissae xl, x2 are to be determined
such that the formula integrates exactly 1, x, x2, and x3 (and hence all
cubic functions). Then the following four conditions are imposed on the
four unknowns:
If we write
then:
since .
Note that the Gauss two-point formula is exact for cubic polynomials,
and hence may be compared in accuracy with Simson's Rule. (In fact,
the error for the Gauss formula is about 2/3 that for Simpson's Rule.).
Since the Gauss formula requires one less evaluation of function values,
it may be preferred, provided function evaluations at irrational
abscissae values are possible.
.
These two formulae are the first in the series of so called Gauss-
Legendre formulae, because of their association with Legendre
polynomials.
where W(x) is referred to as the weight function, (x1, x2, . . . , x2} is a set
of points in the integration range and the weights wi are known
constants.
The sets {xi} and (wi} are tabulated in reference books, so that
application of Gauss quadrature is easy.
yields:
yields:
Checkpoint
EXERCISE