4-1. Numeriacal Differention

공부하자·2022년 9월 28일
0

수치해석

목록 보기
6/9

Numeriacal Differention

Deleting the terms involving ξ(x)\xi(x) gives

f(x)f(x0+h)f(x0)h.f^{\prime}(x) \approx \frac{f\left(x_0+h\right)-f\left(x_0\right)}{h} .

One difficulty with this formula is that we have no information about Dxf(ξ(x))D_x f^{\prime \prime}(\xi(x)), so the truncation error cannot be estimated. When xx is x0x_0, however, the coefficient of Dxf(ξ(x)D_x f^{\prime \prime}(\xi(x) ) is 0 , and the formula simplifies to

f(x0)=f(x0+h)f(x0)hh2f(ξ).f^{\prime}\left(x_0\right)=\frac{f\left(x_0+h\right)-f\left(x_0\right)}{h}-\frac{h}{2} f^{\prime \prime}(\xi) .

For small values of hh, the difference quotient [f(x0+h)f(x0)]/h\left[f\left(x_0+h\right)-f\left(x_0\right)\right] / h can be used to approximate f(x0)f^{\prime}\left(x_0\right) with an error bounded by Mh/2M|h| / 2, where MM is a bound on f(x)\left|f^{\prime \prime}(x)\right| for xx between x0x_0 and x0+hx_0+h. This formula is known as the forward-difference formula if h>0h>0 (see Figure 4.1) and the backward-difference formula if h<0h<0.

Example

Use the forward-difference formula to approximate the derivative of f(x)=lnxf(x)=\ln x at x0=1.8x_0=1.8 using h=0.1,h=0.05h=0.1, h=0.05, and h=0.01h=0.01, and determine bounds for the approximation errors.

Three-Point Endpoint Formula

f(x0)=12h[3f(x0)+4f(x0+h)f(x0+2h)]+h23f(3)(ξ0)f^{\prime}\left(x_0\right)=\frac{1}{2 h}\left[-3 f\left(x_0\right)+4 f\left(x_0+h\right)-f\left(x_0+2 h\right)\right]+\frac{h^2}{3} f^{(3)}\left(\xi_0\right),
where ξ0\xi_0 lies between x0x_0 and x0+2hx_0+2 h.

Three-Point Midpoint Formula

f(x0)=12h[f(x0+h)f(x0h)]h26f(3)(ξ1)f^{\prime}\left(x_0\right)=\frac{1}{2 h}\left[f\left(x_0+h\right)-f\left(x_0-h\right)\right]-\frac{h^2}{6} f^{(3)}\left(\xi_1\right)

Five-Point Formulas

The methods presented in Eqs. (4.4) and (4.5) are called three-point formulas (even though the third point f(x0)f\left(x_0\right) does not appear in Eq. (4.5)). Similarly, there are five-point formulas that involve evaluating the function at two additional points. The error term for these formulas is O(h4)O\left(h^4\right). One common five-point formula is used to determine approximations for the derivative at the midpoint.

Five-Point Midpoint Formula

  • f(x0)=112h[f(x02h)8f(x0h)+8f(x0+h)f(x0+2h)]+h430f(5)(ξ)f^{\prime}\left(x_0\right)=\frac{1}{12 h}\left[f\left(x_0-2 h\right)-8 f\left(x_0-h\right)+8 f\left(x_0+h\right)-f\left(x_0+2 h\right)\right]+\frac{h^4}{30} f^{(5)}(\xi),
    where ξ\xi lies between x02hx_0-2 h and x0+2hx_0+2 h.

Five-Point Endpoint Formula

f(x0)=112h[25f(x0)+48f(x0+h)36f(x0+2h)+16f(x0+3h)3f(x0+4h)]+h45f(5)(ξ),\begin{aligned} f^{\prime}\left(x_0\right)=& \frac{1}{12 h}\left[-25 f\left(x_0\right)+48 f\left(x_0+h\right)-36 f\left(x_0+2 h\right)\right.\\ &\left.+16 f\left(x_0+3 h\right)-3 f\left(x_0+4 h\right)\right]+\frac{h^4}{5} f^{(5)}(\xi), \end{aligned}

where ξ\xi lies between x0x_0 and x0+4hx_0+4 h.
Left-endpoint approximations are found using this formula with h>0h>0 and right-endpoint approximations with h<0h<0. The five-point endpoint formula is particularly useful for the clamped cubic spline interpolation of Section 3.5.

Example 2

Values for f(x)=xexf(x)=x e^x are given in Table 4.24.2. Use all the applicable three-point and five-point formulas to approximate f(2.0)f^{\prime}(2.0).

Second Derivative Midpoint Formula

f(x0)=1h2[f(x0h)2f(x0)+f(x0+h)]h212f(4)(ξ),f^{\prime \prime}\left(x_0\right)=\frac{1}{h^2}\left[f\left(x_0-h\right)-2 f\left(x_0\right)+f\left(x_0+h\right)\right]-\frac{h^2}{12} f^{(4)}(\xi),

for some ξ\xi, where x0h<ξ<x0+hx_0-h<\xi<x_0+h.
If f(4)f^{(4)} is continuous on [x0h,x0+h]\left[x_0-h, x_0+h\right] it is also bounded, and the approximation is O(h2)O\left(h^2\right).

Example3

Round-Off Error Instability

It is particularly important to pay attention to round-off error when approximating derivatives. To illustrate the situation, let us examine the three-point midpoint formula Eq. (4.5),

f(x0)=12h[f(x0+h)f(x0h)]h26f(3)(ξ1),f^{\prime}\left(x_0\right)=\frac{1}{2 h}\left[f\left(x_0+h\right)-f\left(x_0-h\right)\right]-\frac{h^2}{6} f^{(3)}\left(\xi_1\right),

more closely. Suppose that in evaluating f(x0+h)f\left(x_0+h\right) and f(x0h)f\left(x_0-h\right) we encounter round-off errors e(x0+h)e\left(x_0+h\right) and e(x0h)e\left(x_0-h\right). Then our computations actually use the values f~(x0+h)\tilde{f}\left(x_0+h\right) and f~(x0h)\tilde{f}\left(x_0-h\right), which are related to the true values f(x0+h)f\left(x_0+h\right) and f(x0h)f\left(x_0-h\right) by

f(x0+h)=f~(x0+h)+e(x0+h) and f(x0h)=f~(x0h)+e(x0h).f\left(x_0+h\right)=\tilde{f}\left(x_0+h\right)+e\left(x_0+h\right) \quad \text { and } \quad f\left(x_0-h\right)=\tilde{f}\left(x_0-h\right)+e\left(x_0-h\right) .
profile
아주대학교 수업 기록

0개의 댓글