44
3. Finite Difference Methods
for small spacing so that the leading term (the one with the smallest exponent) is the dominant one. As Ax is reduced, the above approximations
converge to the exact derivatives with an error proportional to AX)^, where
m is the exponent of the leading truncation error term. The order of an approximation indicates how fast the error is reduced when the grid is refined;
it does not indicate the absolute magnitude of the error. The error is thus
reduced by a factor of two, four, eight or sixteen for first-, second-, thirdor fourth-order approximations, respectively. It should be remembered that
this rule is valid only for suficiently small spacings; the definition of 'small
enough' depends on the profile of the function 4(x).
3.3.2 Polynomial Fitting
An alternative way of obtaining approximations for the derivatives is to fit
the function to an interpolation curve and differentiate the resulting curve.
For example, if piece-wise linear interpolation is used, we obtain the FDS or
BDS approximations, depending on whether the second point lies to the left
or the right of point xi.
Fitting a parabola to the data at points xi-1, xi, and xi+l, and computing
the first derivative at xi from the interpolant, we obtain:
where Axi = xi - xi-1. This approximation has a second order truncation
error on any grid, and is identical to the above second order approximation
obtained using Taylor series approach. For uniform spacing, it reduces to the
CDS approximation given above.
Other polynomials, splines etc. can be used as interpolants and then to
approximate the derivative. In general, approximation of the first derivative
possesses a truncation error of the same order as the degree of the polynomial
used to approximate the function. We give below two third-order approximations obtained by fitting a cubic polynomial to four points and a fourth-order
approximation obtained by fitting a polynomial of degree four to five points
on a uniform grid:
3. Finite Difference Methods
for small spacing so that the leading term (the one with the smallest exponent) is the dominant one. As Ax is reduced, the above approximations
converge to the exact derivatives with an error proportional to AX)^, where
m is the exponent of the leading truncation error term. The order of an approximation indicates how fast the error is reduced when the grid is refined;
it does not indicate the absolute magnitude of the error. The error is thus
reduced by a factor of two, four, eight or sixteen for first-, second-, thirdor fourth-order approximations, respectively. It should be remembered that
this rule is valid only for suficiently small spacings; the definition of 'small
enough' depends on the profile of the function 4(x).
3.3.2 Polynomial Fitting
An alternative way of obtaining approximations for the derivatives is to fit
the function to an interpolation curve and differentiate the resulting curve.
For example, if piece-wise linear interpolation is used, we obtain the FDS or
BDS approximations, depending on whether the second point lies to the left
or the right of point xi.
Fitting a parabola to the data at points xi-1, xi, and xi+l, and computing
the first derivative at xi from the interpolant, we obtain:
where Axi = xi - xi-1. This approximation has a second order truncation
error on any grid, and is identical to the above second order approximation
obtained using Taylor series approach. For uniform spacing, it reduces to the
CDS approximation given above.
Other polynomials, splines etc. can be used as interpolants and then to
approximate the derivative. In general, approximation of the first derivative
possesses a truncation error of the same order as the degree of the polynomial
used to approximate the function. We give below two third-order approximations obtained by fitting a cubic polynomial to four points and a fourth-order
approximation obtained by fitting a polynomial of degree four to five points
on a uniform grid: