Approximate Integration

10

Click here to load reader

description

Midpoint Rule, Trapezoidal Rule and Simpson's Rule

Transcript of Approximate Integration

Page 1: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

Approximate Integration

MIDPOINT RULE:

b∫

a

f(x)dx ≈ Mn = ∆x[f(x1) + f(x2) + . . . + f(xn)]

where

∆x =b − a

n

and xi =1

2(xi−1 + xi) = midpoint of [xi−1, xi].

TRAPEZOIDAL RULE:

b∫

a

f(x)dx ≈ Tn =∆x

2[f(x0) + 2f(x1) + 2f(x2) + . . . + 2f(xn−1) + f(xn)]

where

∆x =b − a

n

and xi = a + i∆x.

1

Page 2: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 5 to approximatethe integral

2∫

1

1

xdx

Solution:

(a) With n = 5, a = 1, and b = 2, we have ∆x = (2 − 1)/5 = 0.2, and so the Trapezoidal Rulegives

2∫

1

1

xdx ≈ T5 =

∆x

2[f(1) + 2f(1.2) + 2f(1.4) + 2f(1.6) + 2f(1.8) + f(2)]

=0.2

2

(

1

1+

2

1.2+

2

1.4+

2

1.6+

2

1.8+

1

2

)

≈ 0.695635

(b) The midpoints of the five subintervals are 1.1, 1.3, 1.5, 1.7, and 1.9, so the Midpoint Rulegives

2∫

1

1

xdx ≈ M5 = ∆x[f(1.1) + f(1.3) + f(1.5) + f(1.7) + f(1.9)]

=1

5

(

1

1.1+

1

1.3+

1

1.5+

1

1.7+

1

1.9

)

≈ 0.691908

REMARK: Note that2

1

1

xdx = lnx

2

1= ln 2 ≈ 0.693147

therefore the errors in the Trapezoidal and Midpoint Rule approximations for n = 5 are

ET ≈ −0.002488 and EM ≈ 0.001239

We see that the size of the error in the Midpoint Rule is about half the size of the error inthe Trapezoidal Rule.

EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 10 to approxi-mate the integral

1∫

0

ex2

dx

2

Page 3: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 10 to approxi-mate the integral

1∫

0

ex2

dx

Solution:

(a) With n = 10, a = 0, and b = 1, we have ∆x = (1 − 0)/10 = 0.1, and so the TrapezoidalRule gives

1∫

0

ex2

dx ≈ T10 =∆x

2[f(0) + 2f(0.1) + 2f(0.2) + . . . + 2f(0.8) + 2f(0.9) + f(1)]

=0.1

2

(

e02

+ 2e0.12

+ 2e0.22

+ . . . + 2e0.82

+ 2e0.92

+ e12

)

≈ 1.467174693

(b) The midpoints of the ten subintervals are 0.05, 0.15, 0.25, . . . , 0.85, 0.95, so the MidpointRule gives

1∫

0

ex2

dx ≈ M10 = ∆x[f(0.05) + f(0.15) + f(0.25) + . . . + f(0.85) + f(0.95)]

=1

10

(

e0.052

+ e0.152

+ e0.252

+ . . . + e0.852

+ e0.952

)

≈ 1.460393091

REMARK: One can compute that

1∫

0

ex2

dx ≈ 1.462651746

therefore the errors in the Trapezoidal and Midpoint Rule approximations for n = 10 are

ET ≈ −0.004522947 and EM ≈ 0.002258655

We see that the size of the error in the Midpoint Rule is about half the size of the error inthe Trapezoidal Rule.

EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 10 to approxi-mate the integral

1∫

0

√1 + x3dx

3

Page 4: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

EXAMPLE: Use (a) the Trapezoidal Rule and (b) the Midpoint Rule with n = 10 to approxi-mate the integral

1∫

0

√1 + x3dx

Solution:

(a) With n = 10, a = 0, and b = 1, we have ∆x = (1 − 0)/10 = 0.1, and so the TrapezoidalRule gives

1∫

0

√1 + x3dx ≈ T10 =

∆x

2[f(0) + 2f(0.1) + 2f(0.2) + . . . + 2f(0.8) + 2f(0.9) + f(1)]

=0.1

2

(√1 + 03 + 2

√1 + 0.13 + 2

√1 + 0.23 + . . . + 2

√1 + 0.83 + 2

√1 + 0.93 +

√1 + 13

)

≈ 1.112332391

(b) The midpoints of the ten subintervals are 0.05, 0.15, 0.25, . . . , 0.85, 0.95 so the MidpointRule gives

1∫

0

√1 + x3dx ≈ M10 = ∆x[f(0.05) + f(0.15) + f(0.25) + . . . + f(0.85) + f(0.95)]

=1

10

(√1 + 0.053 +

√1 + 0.153 +

√1 + 0.253 + . . . +

√1 + 0.853 +

√1 + 0.953

)

≈ 1.111005559

REMARK: One can compute that

1∫

0

√1 + x3dx ≈ 1.111447979

therefore the errors in the Trapezoidal and Midpoint Rule approximations for n = 10 are

ET ≈ −0.000884412 and EM ≈ 0.000442420

We see that the size of the error in the Midpoint Rule is about half the size of the error inthe Trapezoidal Rule.

ERROR BOUNDS: Suppose |f ′′(x)| ≤ K for a ≤ x ≤ b. If ET and EM are the errors in theTrapezoidal and Midpoint Rules, then

|ET | ≤K(b − a)3

12n2and |EM | ≤ K(b − a)3

24n2

EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of2

1

1

xdx with n = 5.

4

Page 5: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of2

1

1

xdx with n = 5.

Solution: Note that

f ′(x) = − 1

x2and f ′′(x) =

2

x3

Since2

x3is a decreasing function on [1, 2], we have

|f ′′(x)| =

2

x3

≤ 2

13= 2

Therefore, taking K = 2, a = 1, b = 2, and n = 5 in the above error estimates, we obtain

|ET | ≤K(b − a)3

12n2=

2(2 − 1)3

12(5)2=

1

150≈ 0.0067

and

|EM | ≤ K(b − a)3

24n2=

2(2 − 1)3

24(5)2=

1

300≈ 0.0033

REMARK: Note that these error estimates are bigger than the actual errors 0.002488 and0.001239.

EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of1

0

ex2

dx with n = 10.

Solution: Note thatf ′(x) = 2xex2

and f ′′(x) = 2ex2

+ 4x2ex2

Since 2ex2

+ 4x2ex2

is an increasing function on [0, 1], we have

|f ′′(x)| = 2ex2

+ 4x2ex2 ≤ 2e12

+ 4(1)2e12

= 6e

Therefore, taking K = 6e, a = 0, b = 1, and n = 10 in the above error estimates, we obtain

|ET | ≤K(b − a)3

12n2=

6e(1 − 0)3

12(10)2=

e

200≈ 0.01359140914

and

|EM | ≤ K(b − a)3

24n2=

6e(1 − 0)3

24(10)2=

e

400≈ 0.006795704570

REMARK: Note that these error estimates are bigger than the actual errors 0.004522947 and0.002258655.

EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of1

0

√1 + x3dx with n = 10.

5

Page 6: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

EXAMPLE: Give upper bounds for the errors ET and EM involved in the approximation of1

0

√1 + x3dx with n = 10.

Solution: Note that (see the Appendix)

f ′(x) =3x2

2√

1 + x3and f ′′(x) =

3x(x3 + 4)

4(1 + x3)3/2

We now find increasing/decreasing intervals of f ′′(x). Here is the graph of f ′′(x):

To find a point of a local maximum, we note that (see the Appendix)

f ′′′(x) = −3(x6 + 20x3 − 8)

8(1 + x3)5/2

One can check that f ′′′(x) = 0 on [0, 1] at x ≈ 0.7320508076 which is a root of x6 +20x3−8 = 0.It is easy to show that this is a point of a local maximum of f ′′(x). So,

|f ′′(x)| =

3x(x3 + 4)

4(1 + x3)3/2

≤ 3x(x3 + 4)

4(1 + x3)3/2

x=0.7320508076...

≈ 1.467889825

Therefore, taking K = 1.467889825, a = 0, b = 1, and n = 10 in the above error estimates, weobtain

|ET | ≤K(b − a)3

12n2=

1.467889825(1− 0)3

12(10)2≈ 0.001223241521

and

|EM | ≤ K(b − a)3

24n2=

1.467889825(1− 0)3

24(10)2≈ 0.0006116207604

REMARK: Note that these error estimates are bigger than the actual errors 0.000884412 and0.000442420.

EXAMPLE: How large should we take n in order to guarantee that the Trapezoidal and Mid-

point Rule approximations for

2∫

1

1

xdx are accurate to within 0.0001?

6

Page 7: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

EXAMPLE: How large should we take n in order to guarantee that the Trapezoidal and Mid-

point Rule approximations for

2∫

1

1

xdx are accurate to within 0.0001?

Solution: We saw in one of the previous examples that |f ′′(x)| ≤ 2 for 1 ≤ x ≤ 2, so we cantake K = 2, a = 1, and b = 2 in

|ET | ≤K(b − a)3

12n2and |EM | ≤ K(b − a)3

24n2

Accuracy to within 0.0001 means that the size of the error should be less than 0.0001. Therefore,we choose n so that

2 · 13

12n2< 0.0001 (Trapezoidal Rule)

Solving the inequality for n, we get

n2 >2

12(0.0001)=⇒ n >

1√0.0006

≈ 40.8

Thus n = 41 will ensure the desired accuracy.

For the same accuracy with the Midpoint Rule we choose n so that

2 · 13

24n2< 0.0001 =⇒ n >

1√0.0012

≈ 29

SIMPSON’S RULE:

b∫

a

f(x)dx ≈ Sn =∆x

3[f(x0) + 4f(x1) + 2f(x2) + 4f(x3) + . . . + 2f(xn−2) + 4f(xn−1) + f(xn)]

where n is even and ∆x =b − a

n.

ERROR BOUND FOR SIMPSON’S RULE: Suppose that |f (4)(x)| ≤ K for a ≤ x ≤ b. If ES

is the error involved in using Simpson’s Rule, then

|ES| ≤K(b − a)5

180n4

EXAMPLE: How large should we take n in order to guarantee that the Simpson’s Rule ap-

proximation for

2∫

0

x3dx is accurate to within 0.0001?

7

Page 8: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

EXAMPLE: How large should we take n in order to guarantee that the Simpson’s Rule ap-

proximation for

2∫

0

x3dx is accurate to within 0.0001?

Solution: Note that

f ′(x) = 3x2, f ′′(x) = 6x, f ′′′(x) = 6, and f (4)(x) = 0

Therefore, taking K = 0 in the above error estimate, we obtain

|ES| ≤K(b − a)5

180n4=

0 · (b − a)5

180n4= 0

This means that Simpson’s Rule gives the exact value of

2∫

0

x3dx with n = 2. In fact,

2∫

0

x3dx =x4

4

2

0

=24

4= 4

which is the same as1

3[03 + 4 · 13 + 23]

REMARK: One can show that if f is a polynomial of degree 3 or lower, then Simpson’s Rule

gives the exact value of

b∫

a

f(x)dx.

EXAMPLE: How large should we take n in order to guarantee that the Simpson’s Rule ap-

proximation for

2∫

1

1

xdx is accurate to within 0.0001?

Solution: If f(x) = 1/x, then f (4)(x) = 24/x5. Since 24/x5 is a decreasing function on [1, 2], wehave

|f (4)(x)| =

24

x5

≤ 24

15= 24

Therefore, we can take K = 24, a = 1, and b = 2 in

|ES| ≤K(b − a)5

180n4

Accuracy to within 0.0001 means that the size of the error should be less than 0.0001. Therefore,we choose n so that

24 · 15

180n4< 0.0001

Solving the inequality for n, we get

n4 >24

180(0.0001)=⇒ n >

14√

0.00075≈ 6.04

Thus n = 8 (n must be even) will ensure the desired accuracy.

8

Page 9: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

Appendix

EXAMPLE: Let f(x) =√

1 + x3. Find f ′, f ′′, and f ′′′.

Solution: Since f(x) = (1 + x3)1/2, we have

f ′(x) =1

2(1 + x3)1/2−1 · (1 + x3)′ =

1

2(1 + x3)−1/2 · 3x2 =

3x2

2√

1 + x3

f ′′(x) =

(

3x2

2(1 + x3)1/2

)

=3

2

(

x2

(1 + x3)1/2

)

=3

2· (x2)′(1 + x3)1/2 − x2[(1 + x3)1/2]′

[(1 + x3)1/2]2

=3

2·2x(1 + x3)1/2 − x2 1

2(1 + x3)1/2−1 · (1 + x3)′

1 + x3

=3

2·2x(1 + x3)1/2 − x2 1

2(1 + x3)−1/2 · 3x2

1 + x3

=3

2·2x(1 + x3)1/2 − 3

2x4(1 + x3)−1/2

1 + x3

=3

(

2x(1 + x3)1/2 − 3

2x4(1 + x3)−1/2

)

· 2(1 + x3)1/2

(1 + x3) · 2(1 + x3)1/2

=3

2·2x(1 + x3)1/2 · 2(1 + x3)1/2 − 3

2x4(1 + x3)−1/2 · 2(1 + x3)1/2

2(1 + x3)3/2

=3

2· 4x(1 + x3) − 3x4

2(1 + x3)3/2

=3

2· 4x + 4x4 − 3x4

2(1 + x3)3/2

=3

2· 4x + x4

2(1 + x3)3/2

=3

2· x(4 + x3)

2(1 + x3)3/2

=3x(4 + x3)

4(1 + x3)3/2

9

Page 10: Approximate Integration

Section 6.5 Approximate Integration 2010 Kiryl Tsishchanka

f ′′′(x) =

(

3x(4 + x3)

4(1 + x3)3/2

)

=3

4

(

x(4 + x3)

(1 + x3)3/2

)

=3

4· [x(4 + x3)]′(1 + x3)3/2 − x(4 + x3)[(1 + x3)3/2]′

[(1 + x3)3/2]2

=3

4·[x′(4 + x3) + x(4 + x3)′](1 + x3)3/2 − x(4 + x3)

3

2(1 + x3)3/2−1 · (1 + x3)′

(1 + x3)3

=3

4·[1 · (4 + x3) + x · 3x2](1 + x3)3/2 − x(4 + x3)

3

2(1 + x3)1/2 · 3x2

(1 + x3)3

=3

4·(4 + x3 + 3x3)(1 + x3)3/2 − 9

2x3(4 + x3)(1 + x3)1/2

(1 + x3)3

=3

4·(4 + 4x3)(1 + x3)3/2 − 9

2x3(4 + x3)(1 + x3)1/2

(1 + x3)3

=3

4·4(1 + x3)(1 + x3)3/2 − 9

2x3(4 + x3)(1 + x3)1/2

(1 + x3)3

=3

4·4(1 + x3)5/2 − 9

2x3(4 + x3)(1 + x3)1/2

(1 + x3)3

=3

(

4(1 + x3)5/2 − 9

2x3(4 + x3)(1 + x3)1/2

)

· 2(1 + x3)−1/2

(1 + x3)3 · 2(1 + x3)−1/2

=3

4·4(1 + x3)5/2 · 2(1 + x3)−1/2 − 9

2x3(4 + x3)(1 + x3)1/2 · 2(1 + x3)−1/2

2(1 + x3)5/2

=3

4· 8(1 + x3)2 − 9x3(4 + x3)

2(1 + x3)5/2=

3

4· 8(1 + 2x3 + x6) − 36x3 − 9x6

2(1 + x3)5/2

=3

4· 8 + 16x3 + 8x6 − 36x3 − 9x6

2(1 + x3)5/2=

3

4· 8 − 20x3 − x6

2(1 + x3)5/2

=3(8 − 20x3 − x6)

8(1 + x3)5/2= −3(x6 + 20x3 − 8)

8(1 + x3)5/2

10