Numeric Integration and Differentiation

Một phần của tài liệu Advanced engineering mathematics 10th edition (Trang 853 - 870)

Case III. Complex conjugate roots are of minor practical importance, and we discuss the derivation of real solutions from complex ones just in terms of a typical example

Step 3. Solution of the Entire Problem

19.5 Numeric Integration and Differentiation

In applications, the engineer often encounters integrals that are very difficult or even impossible to solve analytically. For example, the error function, the Fresnel integrals (see Probs. 16–25 on nonelementary integrals in this section), and others cannot be evaluated by the usual methods of calculus (see App. 3, (24)–(44) for such

“difficult” integrals). We then need methods from numerical analysis to evaluate such integrals. We also need numerics when the integrand of the integral to be evaluated consists of an empirical function, where we are given some recorded values of that function. Methods that address these kinds of problems are called methods of numeric integration.

Numeric integrationmeans the numeric evaluation of integrals

where aand bare given and fis a function given analytically by a formula or empirically by a table of values. Geometrically, Jis the area under the curve of fbetween aand b (Fig. 440), taken with a minus sign where fis negative.

J⫽ 冮abf(x) dx

We know that if fis such that we can find a differentiable function Fwhose derivative is f, then we can evaluate J directly, i.e., without resorting to numeric integration, by applying the familiar formula

Your CAS (Mathematica, Maple, etc.) or tables of integrals may be helpful for this purpose.

Rectangular Rule. Trapezoidal Rule

Numeric integration methods are obtained by approximating the integrand fby functions that can easily be integrated.

The simplest formula, the rectangular rule, is obtained if we subdivide the interval of integration into n subintervals of equal length and in each subinterval approximate fby the constant , the value of fat the midpoint of the jth subinterval (Fig. 441). Then fis approximated by a step function(piecewise constant function), the nrectangles in Fig. 441 have the areas and the rectangular ruleis

(1)

The trapezoidal rule is generally more accurate. We obtain it if we take the same subdivision as before and approximate f by a broken line of segments (chords) with

endpoints on the curve of f(Fig. 442). Then the area

under the curve of fbetween aand bis approximated by ntrapezoids of areas

1

2[ f(a)⫹f(x1)]h, 12[ f(x1)⫹f(x2)]h, Á, 12[ f(xnⴚ1)⫹f(b)]h.

[a, f(a)], [x1, f(x1)],Á, [b, f(b)]

ahba n b . J⫽ 冮abf(x) dxh[ f(x*)1 ⫹f(x*)2 ⫹ Á ⫹f(xn*)]

f(x*)h,1 Á, f(xn*)h,

x*j f(x*)j

h⫽(ba)>n axb

[Fr(x)⫽f(x)].

J⫽ 冮abf(x) dxF(b)⫺F(a)

y

a b x

y = f(x)

R

y

a b x

y = f(x)

x1* x2* xn*

Fig. 440. Geometric interpretation

of a definite integral Fig. 441. Rectangular rule

y

a b x

y = f(x)

x1 x2 xn – 1

Fig. 442. Trapezoidal rule

By taking their sum we obtain the trapezoidal rule

(2)

where as in (1). The ’s and aand bare called nodes.

E X A M P L E 1 Trapezoidal Rule

Evaluate by means of (2) with

Note that this integral cannot be evaluated by elementary calculus, but leads to the error function (see Eq. (35), App. 3).

Solution. from Table 19.3.

Table 19.3 Computations in Example 1

j xj xj2 exj2

0 0 0 1.000000

1 0.1 0.01 0.990050

2 0.2 0.04 0.960789

3 0.3 0.09 0.913931

4 0.4 0.16 0.852144

5 0.5 0.25 0.778801

6 0.6 0.36 0.697676

7 0.7 0.49 0.612626

8 0.8 0.64 0.527292

9 0.9 0.81 0.444858

10 1.0 1.00 0.367879

Sums 1.367879 6.778167

Error Bounds and Estimate for the Trapezoidal Rule

An error estimate for the trapezoidal rule can be derived from (5) in Sec. 19.3 with by integration as follows. For a single subinterval we have

with a suitable tdepending on x, between and Integration over xfrom to gives

xx0⫹h

0

f(x) dxh

2 [ f(x0)⫹f(x1)]⫽ 冮xx0⫹h

0

(xx0)(xx0⫺h) fs(t(x))

2 dx.

x1⫽x0⫹h

ax0 x1.

x0

f(x)⫺p1(x)⫽(xx0)(xx1) fs(t)

2

n⫽1 䊏

J⬇0.1(0.5ⴢ1.367879⫹6.778167)⫽0.746211 n⫽10.

J⫽ 冮01ex2 dx

xj h⫽(ba)>n,

J⫽ 冮abf(x) dxh c12f(a)⫹f(x1)⫹f(x2)⫹ Á ⫹f(xnⴚ1)⫹12 f(b)d

Setting and applying the mean value theorem of integral calculus, which we can use because does not change sign, we find that the right side equals

where is a (suitable, unknown) value between and This is the error for the trapezoidal rule with often called the local error.

Hence the error of (2) with any n is the sum of such contributions from the n

subintervals; since and we obtain

(3)

with (suitable, unknown) between aand b.

Because of (3) the trapezoidal rule (2) is also written

Error Bounds are now obtained by taking the largest value for say, and the smallest value, in the interval of integration. Then (3) gives (note that Kis negative) (4)

Error Estimation by Halving h is advisable if is very complicated or unknown, for instance, in the case of experimental data. Then we may apply the Error Principle of Sec. 19.1. That is, we calculate by (2), first with h, obtaining, say, and then with obtaining Now if we replace in (3) with the error is multiplied by Hence (not exactly because may differ). Together,

Thus Division by 3

gives the error formula for (5)

E X A M P L E 2 Error Estimation for the Trapezoidal Rule by (4) and (5) Estimate the error of the approximate value in Example 1 by (4) and (5).

Solution. (A) Error bounds by(4).By differentiation, Also, if

so that the minimum and maximum occur at the ends of the interval. We compute and Furthermore, and (4) gives

. Hence the exact value of Jmust lie between

and Actually, J⫽0.746824,exact to 6D.

0.746211⫹0.001667⫽0.747878.

0.746211⫺0.000614⫽0.745597

⫺0.000614⬉P⬉0.001667 K⫽ ⫺1>1200,

M2*⫽fs(0)⫽ ⫺2.

M2⫽fs(1)⫽0.735759 0⬍x⬍1, ft(x)⬎0

fs(x)⫽2(2x2⫺1)ex2. Ph>2⬇13(Jh>2⫺Jh).

Jh>2

Jh>2⫺Jh⫽(4⫺1)Ph>2. Jh>2⫹Ph>2⫽Jh⫹PhJh⫹4Ph>2.

tˆ Ph>2⬇14Ph

1 4.

(12h)2, h2

JJh>2⫹Ph>2.

1 2h,

JJh⫹Ph, fs

KM2⬉P⬉KM2* where K⫽ ⫺ (ba)3

12n2 ⫽ ⫺ba 12 h2. M2*,

M2, fs,

J⫽ 冮abf(x) dxhc12f(a)⫹f(x1)⫹ Á⫹f(xnⴚ1)⫹ 12f(b)d ⫺ b12⫺a h2fs(tˆ).

(2*)

tˆ

P⫽ ⫺(ba)3

12n2 fs(tˆ)⫽ ⫺ ba

12 h2fs(tˆ)

(ba)2⫽n2h2, h⫽(ba)>n, nh3⫽n(ba)3>n3,

P n⫽1,

x1. x0

t~

冮0hv(vh) dv fs2(t~) ⫽ah33 ⫺ h23b fs2(t~) ⫽ ⫺12h3 fs(t~)

(3*)

(xx0)(xx0⫺h) xx0⫽v

(B) Error estimate by(5). in Example 1. Also,

Hence and exact to 6D.

Simpson’s Rule of Integration

Piecewise constant approximation of f led to the rectangular rule (1), piecewise linear approximation to the trapezoidal rule (2), and piecewise quadratic approximation will lead to Simpson’s rule, which is of great practical importance because it is sufficiently accurate for most problems, but still sufficiently simple.

To derive Simpson’s rule, we divide the interval of integration into an even numberof equal subintervals, say, into subintervals of length

with endpoints see Fig. 443. We now take the first

two subintervals and approximate in the interval by the

Lagrange polynomial through where From (3)

in Sec. 19.3 we obtain (6)

The denominators in (6) are and respectively. Setting we have

and we obtain

We now integrate with respect to xfrom to This corresponds to integrating with respect to sfrom to 1. Since the result is

xx2

0

f(x) dx⬇ 冮xx2

0

p2(x) dxh a1 3 f0⫹ 4

3 f1⫹ 1 3 f2b. (7*)

dxh ds,

⫺1

x2. x0

p2(x)⫽12s(s⫺1)f0⫺(s⫹1)(s⫺1)f1⫹12(s⫹1)sf2. xx2⫽x⫺(x1⫹h)⫽(s⫺1)h

xx1⫽sh, xx0⫽x⫺(x1⫺h)⫽(s⫹1)h

s⫽(xx1)>h, 2h2,

2h2, ⫺h2, p2(x)⫽ (xx1)(xx2)

(x0⫺x1)(x0⫺x2) f0⫹ (xx0)(xx2)

(x1⫺x0)(x1⫺x2) f1⫹ (xx0)(xx1) (x2⫺x0)(x2⫺x1) f2.

fjf(xj).

(x0, f0), (x1, f1), (x2, f2), p2(x)

x0⬉xx2⫽x0⫹2h f(x)

x0 (⫽ a), x1,Á, x2mⴚ1, x2m (⫽ b);

h⫽(ba)>(2m), n⫽2m

axb

Jh>2⫹Ph>2⫽0.746824, Ph>2⫽13(Jh>2⫺Jh)⫽0.000153

Jh>2⫽0.05ca

19

j⫽1

eⴚ(j>20)2⫹1

2 (1⫹0.367879)d⫽0.746671.

Jh⫽0.746211

y

x a x1 x2 x3 x4 x2m–2 x2m–1b

First parabola

Last parabola Second parabola

y = f(x)

Fig. 443. Simpson’s rule

A similar formula holds for the next two subintervals from to and so on. By summing all these mformulas we obtain Simpson’s rule4

(7)

where and Table 19.4 shows an algorithm for Simpson’s

rule.

Table 19.4 Simpson’s Rule of Integration

ALGORITHM SIMPSON (a, b, m, ƒ0, ƒ1, • • •, ƒ2m)

This algorithm computes the integral from given values ƒj ⫽ƒ(xj) at equidistant x0⫽a, x1⫽x0⫹h,• • •, x2mx0⫹2mhbby Simpson’s rule (7), where

INPUT: a, b, m, ƒ0,• • •, ƒ2m

OUTPUT: Approximate value J苲of J Compute

s1⫽ƒ1⫹ƒ3⫹• • •⫹ƒ2mⴚ1

s2⫽ƒ2⫹ƒ4⫹• • •⫹ƒ2mⴚ2

h⫽(ba) / 2m

OUTPUT J苲. Stop.

End SIMPSON

Error of Simpson’s Rule (7). If the fourth derivative exists and is continuous on the errorof (7), call it is

(8)

here is a suitable unknown value between aand b. This is obtained similarly to (3).

With this we may also write Simpson’s rule (7) as

abf(x) dxh3 ( f0⫹4f1⫹ Á⫹f2m)⫺ b180⫺a h4f(4)(tˆ).

(7**) tˆ

PS⫽ ⫺ (ba)5

180(2m)4 f(4)(tˆ)⫽ ⫺ ba

180 h4f(4)(tˆ);

Ps, axb,

f(4) J苲⫽h

3 (s0⫹4s1⫹2s2) s0⫽f0⫹f2m

h⫽(ba)>(2m).

J⫽ 兰abf(x) dx fjf(xj).

h⫽(ba)>(2m)

abf(x) dxh3 (f0⫹4f1⫹2f2⫹4f3⫹Á ⫹2f2mⴚ2⫹4f2mⴚ1⫹f2m),

x4, x2

4THOMAS SIMPSON (1710–1761), self-taught English mathematician, author of several popular textbooks.

Simpson’s rule was used much earlier by Torricelli, Gregory (in 1668), and Newton (in 1676).

Error Bounds. By taking for in (8) the maximum and minimum on the interval of integration we obtain from (8) the error bounds (note that Cis negative)

(9)

Degree of Precision (DP) of an integration formula. This is the maximum degree of arbitrary polynomials for which the formula gives exact values of integrals over any intervals.

Hence for the trapezoidal rule,

because we approximate the curve of fby portions of straight lines (linear polynomials).

For Simpson’s rule we might expect (why?). Actually,

by (9) because is identically zero for a cubic polynomial. This makes Simpson’s rule sufficiently accurate for most practical problems and accounts for its popularity.

Numeric Stabilitywith respect to roundingis another important property of Simpson’s rule. Indeed, for the sum of the roundoff errors of the values in (7) we obtain, since

where uis the rounding unit ( if we round off to 6D; see Sec. 19.1). Also is the sum of the coefficients for a pair of intervals in (7); take in (7) to see this. The bound is independent of m, so that it cannot increase with increasing m, that is, with decreasing h. This proves stability.

Newton–Cotes Formulas.We mention that the trapezoidal and Simpson rules are special closed Newton–Cotes formulas, that is, integration formulas in which is interpolated at equally spaced nodes by a polynomial of degree for trapezoidal, for Simpson), and closedmeans that aand bare nodes and higher nare used occasionally. From on, some of the coefficients become negative, so that a positive could make a negative contribution to an integral, which is absurd. For more on this topic see Ref. [E25] in App. 1.

E X A M P L E 3 Simpson’s Rule. Error Estimate

Evaluate by Simpson’s rule with and estimate the error.

Solution. Since , Table 19.5 gives

J⬇0.1

3 (1.367879⫹4#3.740266⫹2#3.037901)⫽0.746825.

h⫽0.1

2m⫽10 J⫽ 冮01ex2dx

fj

n⫽8

(ax0, bxn). n⫽3 n⫽2 n(n⫽1

f(x)

䊏 (ba)u

m⫽1 6⫽1⫹4⫹1

u⫽12ⴢ10ⴚ6 h

3 ƒ P0⫹4P1⫹ Á⫹P2mƒ ⬉ ba

3.2m 6mu⫽(ba)u h⫽(ba)>2m,

fj 2m⫹1

Pj f(4)

DP⫽3 DP⫽2

DP⫽1

CM4⬉PSCM4* where C⫽ ⫺ (ba)5

180(2m)4 ⫽ ⫺ba 180 h4.

M*4 M4

f(4)

Estimate of error.Differentiation gives By considering the derivative of we find that the largest value of in the interval of integration occurs at 0 and the smallest value at

Computation gives the values and Since

and we obtain Therefore, from (9),

Hence Jmust lie between and so that at

least four digits of our approximate value are exact. Actually, the value 0.746825 is exact to 5D because (exact to 6D).

Thus our result is much better than that in Example 1 obtained by the trapezoidal rule, whereas the number

of operations is nearly the same in both cases. 䊏

J⫽0.746824

0.746825⫹0.000005⫽0.746830, 0.746825⫺0.000007⫽0.746818

⫺0.000007⬉Ps⬉0.000005.

C⫽ ⫺1>1800000⫽ ⫺0.00000056.

ba⫽1, 2m⫽10

M*4⫽f(4)(x*)⫽ ⫺7.419.

M4⫽f(4)(0)⫽12 x*⫽(2.5⫺0.5110)1>2.

f(4) f(4)

f(5) f(4)(x)⫽4(4x4⫺12x2⫹3)ex2.

Table 19.5 Computations in Example 3

j xj xj2

exj2

0 0 0 1.000000

1 0.1 0.01 0.990050

2 0.2 0.04 0.960789

3 0.3 0.09 0.913931

4 0.4 0.16 0.852144

5 0.5 0.25 0.778801

6 0.6 0.36 0.697676

7 0.7 0.49 0.612626

8 0.8 0.64 0.527292

9 0.9 0.81 0.444858

10 1.0 1.00 0.367879

Sums 1.367879 3.740266 3.037901

Instead of picking an and then estimating the error by (9), as in Example 3, it is better to require an accuracy (e.g., 6D) and then determine from (9).

E X A M P L E 4 Determination of in Simpson’s Rule from the Required Accuracy What nshould we choose in Example 3 to get 6D-accuracy?

Solution. Using (which is bigger in absolute value than we get from (9), with and the required accuracy,

thus .

Hence we should choose Do the computation, which parallels that in Example 3.

Note that the error bounds in (4) or (9) may sometimes be loose, so that in such a case a smaller may already suffice.

Error Estimation for Simpson’s Rule by Halving h. The idea is the same as in (5) and gives

(10)

is obtained by using hand by using 1 and Ph>2is the error of Jh>2.

2h, Jh>2

Jh

Ph>2⬇151 (Jh>2⫺Jh).

n⫽2m

n⫽2m⫽20.

m⫽c2ⴢ106ⴢ12 180ⴢ24 d

1>4

⫽9.55 ƒCM4ƒ⫽ 12

180(2m)4⫽1 2ⴢ10ⴚ6,

ba⫽1 M*,4

M4⫽12 n2m

n⫽2m n⫽2m

Derivation.In (5) we had as the reciprocal of and resulted from in (3) by replacing hwith In (10) we have as the reciprocal of

and results from in (8) by replacing hwith E X A M P L E 5 Error Estimation for Simpson’s Rule by Halving

Integrate from 0 to 2 with and apply (10).

Solution. The exact 5D-value of the integral is Simpson’s rule gives

Hence (10) gives and thus with an

error which is less in absolute value than of the error 0.02979 of Hence the use of (10) was well worthwhile.

Adaptive Integration

The idea is to adapt step hto the variability of That is, where fvaries but little, we can proceed in large steps without causing a substantial error in the integral, but where fvaries rapidly, we have to take small steps in order to stay everywhere close enough to the curve of f.

Changing his done systematically, usually by halving h, and automatically (not “by hand”) depending on the size of the (estimated) error over a subinterval. The subinterval is halved if the corresponding error is still too large, that is, larger than a given tolerance TOL (maximum admissible absolute error), or is not halved if the error is less than or equal to TOL (or doubled if the error is very small).

Adapting is one of the techniques typical of modern software. In connection with integration it can be applied to various methods. We explain it here for Simpson’s rule. In Table 19.6 an asterisk means that for that subinterval, TOL has been reached.

E X A M P L E 6 Adaptive Integration with Simpson’s Rule

Integrate from to 2 by adaptive integration and with Simpson’s rule and TOL

Solution. Table 19.6 shows the calculations. Figure 444 shows the integrand and the adapted intervals used. The first two intervals ([0, 0.5], [0.5, 1.0]) have length 0.5, hence [because we use subintervals in Simpson’s rule The next two intervals ([1.00, 1.25], [1.25, 1.50]) have length 0.25 (hence and the last four intervals have length 0.125. Sample computations. For 0.740480 see

Example 5. Formula (10) gives Note that 0.123716 refers to [0, 0.5]

and [0.5, 1], so that we must subtract the value corresponding to [0, 1] in the line before. Etc.

gives 0.0001 for subintervals of length 1, 0.00005 for length 0.5, etc. The value of the integral obtained is the sum of the values marked by an asterisk (for which the error estimate has become less than TOL). This gives

The exact 5D-value is . Hence the error is 0.00017. This is about of the absolute value of that in Example 5. Our more extensive computation has produced a much better result.J⫽1.25953 1>200 䊏

J⬇0.123716⫹0.528895⫹0.388263⫹0.218483⫽1.25936.

TOL[0, 2]⫽0.0002

(0.123716⫺0.122794)>15⫽0.000061.

h⫽0.125)

(7**)].

2m⫽2 h⫽0.25

f(x) [0, 2]⫽0.0002.

x⫽0 f(x)⫽14px4 cos 14px

f(x).

Jh>2. 䊏

1

⫺0.00283 10

JJh>2⫹Ph>2⫽1.26236, Ph>2⫽151(1.22974⫺0.74048)⫽0.032617

⫽16[0⫹4ⴢ0.045351⫹2ⴢ0.555361⫹4ⴢ1.521579⫹0]⫽1.22974.

Jh>2⫽16[ f(0)⫹4 f (12)⫹2f(1)⫹4f (32)⫹f(2)]

Jh⫽133f(0)⫹4f(1)⫹f(2)4⫽13(0⫹4ⴢ0.555360⫹0)⫽0.740480, J⫽1.25953.

h⫽1 f(x)⫽14 px4 cos 14 px

1 2h.

h4

1 16 ⫽(12)4

15⫽16⫺1

1 15 1

2h.

h2

1 4 ⫽(12)2 3⫽4⫺1

1 3

Gauss Integration Formulas Maximum Degree of Precision

Our integration formulas discussed so far use function values at predetermined (equidistant) x-values (nodes) and give exact results for polynomials not exceeding a Table 19.6 Computations in Example 6

Interval Integral Error (10) TOL Comment

[0, 2] 0.740480 0.0002

[0, 1] 0.122794

[1, 2] 1.10695

Sum ⫽1.22974 0.032617 0.0002 Divide further

[0.0, 0.5] 0.004782

[0.5, 1.0] 0.118934

Sum ⫽0.123716* 0.000061 0.0001 TOL reached

[1.0, 1.5] 0.528176

[1.5, 2.0] 0.605821

Sum ⫽1.13300 0.001803 0.0001 Divide further [1.00, 1.25] 0.200544

[1.25, 1.50] 0.328351

Sum ⫽0.528895* 0.000048 0.00005 TOL reached [1.50, 1.75] 0.388235

[1.75, 2.00] 0.218457

Sum ⫽0.606692 0.000058 0.00005 Divide further [1.500, 1.625] 0.196244

[1.625, 1.750] 0.192019

Sum ⫽0.388263* 0.000002 0.000025 TOL reached [1.750, 1.875] 0.153405

[1.875, 2.000] 0.065078

Sum ⫽0.218483* 0.000002 0.000025 TOL reached

f(x)

0 x 1.5 1.0 0.5

0.5

0 1 1.5 2

Fig. 444. Adaptive integration in Example 6

certain degree [called the degree of precision; see after (9)]. But we can get much more accurate integration formulas as follows. We set

(11)

with fixed n, and obtained from by setting

Then we determine the ncoefficients and nnodes so that (11) gives exact results for polynomials of degree kas high as possible. Since is the number of coefficients of a polynomial of degree it follows that

Gauss has shown that exactness for polynomials of degree not exceeding (instead of for predetermined nodes) can be attained, and he has given the location of the the jth zero of the Legendre polynomial in Sec. 5.3) and the coefficients which depend on nbut not on and are obtained by using Lagrange’s interpolation polynomial, as shown in Ref. [E5] listed in App. 1. With these and formula (11) is called a Gauss integration formulaor Gauss quadrature formula.Its degree of precision is as just explained. Table 19.7 gives the values needed for (For larger n, see pp. 916–919of Ref. [GenRef1] in App. 1.)

n⫽2,Á , 5.

2n⫺1, Aj,

tj

f(t),

Aj

Pn

tj(⫽n⫺1

2n⫺1 k⬉2n⫺1.

2n⫺1,

nn⫽2n t1,Á, tn

A1,Á, An

x⫽12[a(t⫺1)⫹b(t⫹1)].

xa, b t⫽ ⫾1

[fjf(tj)]

冮ⴚ11 f(t) dtj⫽1an Aj fj

Table 19.7 Gauss Integration: Nodes tjand Coefficients Aj

n Nodes tj Coefficients Aj Degree of Precision

⫺0.5773502692 1 2 3

0.5773502692 1

⫺0.7745966692 0.5555555556

3 0 0.8888888889 5

0.7745966692 0.5555555556

⫺0.8611363116 0.3478548451

⫺0.3399810436 0.6521451549

4 7

0.3399810436 0.6521451549 0.8611363116 0.3478548451

⫺0.9061798459 0.2369268851

⫺0.5384693101 0.4786286705

5 0 0.5688888889 9

0.5384693101 0.4786286705 0.9061798459 0.2369268851

E X A M P L E 7 Gauss Integration Formula with n 3

Evaluate the integral in Example 3 by the Gauss integration formula (11) with

Solution. We have to convert our integral from 0 to 1 into an integral from to 1. We set Then dx⫽12 dt,and (11) with n⫽3and the above values of the nodes and the coefficients yields

x⫽12(t⫹1).

⫺1 n⫽3.

(exact to 6D: 0.746825), which is almost as accurate as the Simpson result obtained in Example 3 with a much larger number of arithmetic operations. With 3 function values (as in this example) and Simpson’s rule we would get with an error over 30 times that of the Gauss integration.

E X A M P L E 8 Gauss Integration Formula with n 4 and 5

Integrate from to 2 by Gauss. Compare with the adaptive integration in Example 6 and comment.

Solution. gives as needed in (11). For we calculate (6S)

The error is 0.00003 because (6S). Calculating with 10S and gives the same result; so the error is due to the formula, not rounding. For and 10S we get too large by the amount 0.000000250 because The accuracy is impressive, particularly if we compare the amount of work with that in Example 6.

Gauss integration is of considerable practical importance. Whenever the integrand f is given by a formula (not just by a table of numbers) or when experimental measurements can be set at times (or whatever trepresents) shown in Table 19.7 or in Ref. [GenRef1], then the great accuracy of Gauss integration outweighs the disadvantage of the complicated and (which may have to be stored). Also, Gauss coefficients are positive for all n, in contrast with some of the Newton–Cotes coefficients for larger n.

Of course, there are frequent applications with equally spaced nodes, so that Gauss integration does not apply (or has no great advantage if one first has to get the in (11) by interpolation).

Since the endpoints and 1 of the interval of integration in (11) are not zeros of they do not occur among and the Gauss formula (11) is called, therefore, an open formula, in contrast with a closed formula, in which the endpoints of the interval of integration are and [For example, (2) and (7) are closed formulas.]

Numeric Differentiation

Numeric differentiationis the computation of values of the derivative of a function ffrom given values of f. Numeric differentiation should be avoided whenever possible. Whereas integrationis a smoothing process and is not very sensitive to small inaccuracies in function values, differentiationtends to make matters rough and generally gives values of that are much less accurate than those of f. The difficulty with differentiation is tied in with the definition of the derivative, which is the limit of the difference quotient, and, in that quotient, you usually have the difference of a large quantity divided by a small quantity. This can cause numerical instability. While being aware of this caveat, we must still develop basic differentiation formulas for use in numeric solutions of differential equations.

We use the notations etc., and may obtain rough approximation formulas for derivatives by remembering that

fr(x)⫽ lim

h:0

f(xh)⫺f(x)

h .

fjr⫽fr(xj), fjs⫽fs(xj),

fr

tn. t0

t0,Á, tn,

Pn,

⫺1

tj Aj

Aj tj

tj

J⫽1.259525935 (10S). 䊏

J⬇1.259526185, n⫽5

n⫽4 J⫽1.25953

⫽0.347855(0.000290309⫹1.02570)⫹0.652145(0.129464⫹1.25459)⫽1.25950.

JA1 f1⫹ Á ⫹A4 f4⫽A1( f1⫹f4)⫹A2( f2⫹f3)

n⫽4 f(t)⫽14p(t⫹1)4 cos (14p(t⫹1)),

xt⫹1

x⫽0 f(x)⫽14px4 cos 14px

1

6 (1⫹4eⴚ0.25⫹eⴚ1)⫽0.747180,

⬇1 2 c5

9 exp a⫺1 4a1⫺B

3 5b2b⫹8

9 exp a⫺1 4b⫹5

9 exp a⫺1 4a1⫹B

3

5b2b d ⫽0.746815

冮01exp (⫺x2) dx⫽12 冮ⴚ11exp a⫺14 (t⫹1)2bdt

This suggests (12)

Similarly, for the second derivative we obtain

(13) etc.

More accurate approximations are obtained by differentiating suitable Lagrange polynomials. Differentiating (6) and remembering that the denominators in (6) are

we have

Evaluating this at we obtain the “three-point formulas”

(a)

(14) (b)

(c)

Applying the same idea to the Lagrange polynomial we obtain similar formulas, in particular,

(15)

Some examples and further formulas are included in the problem set as well as in Ref. [E5] listed in App. 1.

f2r⬇ 1

12h ( f0⫺8f1⫹8f3⫺f4).

p4(x), f2r ⬇ 1

2h ( f0⫺4f1⫹3f2).

f1r ⬇ 1

2h (⫺f0⫹f2), f0r⬇ 1

2h (⫺3f0⫹4f1⫺f2), x0, x1, x2,

fr(x)⬇pr2(x)⫽ 2xx1⫺x2

2h2 f0⫺ 2xx0⫺x2

h2 f1⫹ 2xx0⫺x1

2h2 f2.

h2, 2h2,

2h2, f1s⬇ d

2f1

h2 ⫽ f2⫺2 f1⫹f0

h2 ,

f1>2r ⬇ df1>2

hf1⫺f0

h .

1–6 RECTANGULAR AND TRAPEZOIDAL RULES 1. Rectangular rule.Evaluate the integral in Example 1 by the rectangular rule (1) with subintervals of length 0.1. Compare with Example 1. (6S-exact:

0.746824)

2. Bounds for (1).Derive a formula for lower and upper bounds for the rectangular rule. Apply it to Prob. 1.

P R O B L E M S E T 1 9 . 5

3. Trapezoidal rule.To get a feel for increase in accuracy, integrate from 0 to 1 by (2) with

4. Error estimation by halfing.Integrate from

0 to 1 by (2) with and esti-

mate the error for and by (5).

5. Error estimation. Do the tasks in Prob. 4 for f(x)⫽sin 12px.

h⫽0.25 h⫽0.5

h⫽1, h⫽0.5, h⫽0.25 f(x)⫽x4

0.25, 0.1.

h⫽1, 0.5, x2

6. Stability.Prove that the trapezoidal rule is stable with respect to rounding.

7–15 SIMPSON’S RULE Evaluate the integrals

by Simpson’s rule with 2m as indicated, and compare with the exact value known from calculus.

7. 8.

9. 10.

11. 12.

13. Error estimate. Compute the integral Jby Simpson’s rule with and use the value and that in Prob.

11 to estimate the error by (10).

14. Error bounds and estimate. Integrate from 0 to 2 by (7) with and with Give error bounds for the value and an error estimate by (10).

15. Given TOL. Find the smallest nin computing A(see Probs. 7 and 8) such that 5S-accuracy is guaranteed (a)by (4) in the use of (2), (b)by (9) in the use of (7).

16–21 NONELEMENTARY INTEGRALS

The following integrals cannot be evaluated by the usual methods of calculus. Evaluate them as indicated. Compare your value with that possibly given by your CAS. is the sine integral. and are the Fresnel integrals.

See App. A3.1. They occur in optics.

16. by (2), and apply (5).

17. by (7),

18. Obtain a better value in Prob. 17. Hint.Use (10).

19. by (7), 20. by (7),

21. by (7),

22–25 GAUSS INTEGRATION Integrate by (11) with

22. from 0 to 23. from 0 to 1 24. from 0 to 1.25 25. exp (⫺x2)from 0 to 1

sin (x2) xex

1 2p cos x

n⫽5:

2m⫽10 C(1.25)

2m⫽10 S(1.25)

2m⫽10 Si(1)

2m⫽2, 2m⫽4 Si(1)

n⫽5, n⫽10, Si(1)

S(x)⫽ 冮0xsin (x*2) dx*, C(x)⫽ 冮0xcos (x*2) dx*

Si(x)⫽ 冮0xsin x*x* dx*,

C(x) S(x)

Si(x) h⫽0.5

h⫽0.5.

h⫽1

ex 2m⫽8

J, 2m⫽10 J, 2m⫽4

B, 2m⫽10 B, 2m⫽4

A, 2m⫽10 A, 2m⫽4

J⫽ 冮011⫹dxx2

B⫽ 冮00.4xex2 dx,

A⫽ 冮12dxx,

26. TEAM PROJECT. Romberg Integration (W. Rom- berg, Norske Videnskab. Trondheim, F rh.28, Nr. 7, 1955). This method uses the trapezoidal rule and gains precision stepwise by halving hand adding an error estimate. Do this for the integral of from

to with as follows.

Step 1.Apply the trapezoidal rule (2) with (hence to get an approximation . Halve h and use (2) to get and an error estimate

If stop. The result is

Step 2. Show that hence

and go on. Use (2) with to get and add to it the error estimate to

get the better Calculate

If stop. The result is

(Why does come in?) Show that we obtain so that we can stop. Arrange your J- and -values in a kind of “difference table.”P P32⫽ ⫺0.000266,

24⫽16

J33⫽J32⫹P32. ƒ P32ƒ ⬉TOL,

P32⫽ 1

24⫺1 (J32⫺J22)⫽ 1

15 (J32⫺J22).

J32⫽J31⫹P31.

P31⫽13(J31⫺J21) J31 h>4

ƒ P21ƒ ⬎TOL

P21⫽ ⫺0.066596, J22⫽J21⫹P21. ƒ P21ƒ ⬉TOL,

P21⫽ 1

22⫺1

(J21⫺J11).

J21

J11 n⫽1)

h⫽2 TOL⫽10ⴚ3,

x⫽2 x⫽0

f(x)⫽ex

J22 J21

J11

J31 J32 J33

⑀31

⑀21

⑀32

If were greater than TOL, you would have to go on and calculate in the next step from (2) with

then

with with with

where (How does this come in?) Apply the Romberg method to the integral

of from to 2 with

27–30 DIFFERENTIATION

27. Consider for

Calculate from Determine the errors. Compare and comment.

(15).

(14c),

(14a), (14b), f2r

x3⫽0.6, x4⫽0.8.

x0⫽0, x1⫽0.2, x2⫽0.4, f(x)⫽x4

TOL⫽10ⴚ4.

x⫽0 f(x)⫽14px4 cos 14px

63⫽26⫺1.

P43⫽631(J43⫺J33) J44⫽J43⫹P43

P42⫽151(J42⫺J32) J43⫽J42⫹P42

P41⫽13(J41⫺J31) J42⫽J41⫹P41

h⫽14;

J41 ƒ P32ƒ

Một phần của tài liệu Advanced engineering mathematics 10th edition (Trang 853 - 870)

Tải bản đầy đủ (PDF)

(1.283 trang)