Numerical Differentiation & Integration Composite Numerical - - PowerPoint PPT Presentation

numerical differentiation integration composite numerical
SMART_READER_LITE
LIVE PREVIEW

Numerical Differentiation & Integration Composite Numerical - - PowerPoint PPT Presentation

Numerical Differentiation & Integration Composite Numerical Integration I Numerical Analysis (9th Edition) R L Burden & J D Faires Beamer Presentation Slides prepared by John Carroll Dublin City University c 2011 Brooks/Cole,


slide-1
SLIDE 1

Numerical Differentiation & Integration Composite Numerical Integration I

Numerical Analysis (9th Edition) R L Burden & J D Faires

Beamer Presentation Slides prepared by John Carroll Dublin City University

c 2011 Brooks/Cole, Cengage Learning

slide-2
SLIDE 2

Example Composite Simpson Composite Trapezoidal Example

Outline

1

A Motivating Example

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 2 / 35

slide-3
SLIDE 3

Example Composite Simpson Composite Trapezoidal Example

Outline

1

A Motivating Example

2

The Composite Simpson’s Rule

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 2 / 35

slide-4
SLIDE 4

Example Composite Simpson Composite Trapezoidal Example

Outline

1

A Motivating Example

2

The Composite Simpson’s Rule

3

The Composite Trapezoidal & Midpoint Rules

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 2 / 35

slide-5
SLIDE 5

Example Composite Simpson Composite Trapezoidal Example

Outline

1

A Motivating Example

2

The Composite Simpson’s Rule

3

The Composite Trapezoidal & Midpoint Rules

4

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 2 / 35

slide-6
SLIDE 6

Example Composite Simpson Composite Trapezoidal Example

Outline

1

A Motivating Example

2

The Composite Simpson’s Rule

3

The Composite Trapezoidal & Midpoint Rules

4

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 3 / 35

slide-7
SLIDE 7

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Application of Simpson’s Rule

Use Simpson’s rule to approximate 4 ex dx

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 4 / 35

slide-8
SLIDE 8

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Application of Simpson’s Rule

Use Simpson’s rule to approximate 4 ex dx and compare this to the results obtained by adding the Simpson’s rule approximations for 2 ex dx and 4

2

ex dx

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 4 / 35

slide-9
SLIDE 9

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Application of Simpson’s Rule

Use Simpson’s rule to approximate 4 ex dx and compare this to the results obtained by adding the Simpson’s rule approximations for 2 ex dx and 4

2

ex dx and adding those for 1 ex dx, 2

1

ex dx, 3

2

ex dx and 4

3

ex dx

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 4 / 35

slide-10
SLIDE 10

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (1/3)

Simpson’s rule on [0, 4] uses h = 2

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 5 / 35

slide-11
SLIDE 11

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (1/3)

Simpson’s rule on [0, 4] uses h = 2 and gives 4 ex dx ≈ 2 3(e0 + 4e2 + e4) = 56.76958.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 5 / 35

slide-12
SLIDE 12

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (1/3)

Simpson’s rule on [0, 4] uses h = 2 and gives 4 ex dx ≈ 2 3(e0 + 4e2 + e4) = 56.76958. The exact answer in this case is e4 − e0 = 53.59815, and the error −3.17143 is far larger than we would normally accept.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 5 / 35

slide-13
SLIDE 13

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (2/3)

Applying Simpson’s rule on each of the intervals [0, 2] and [2, 4] uses h = 1

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 6 / 35

slide-14
SLIDE 14

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (2/3)

Applying Simpson’s rule on each of the intervals [0, 2] and [2, 4] uses h = 1 and gives 4 ex dx = 2 ex dx + 4

2

ex dx

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 6 / 35

slide-15
SLIDE 15

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (2/3)

Applying Simpson’s rule on each of the intervals [0, 2] and [2, 4] uses h = 1 and gives 4 ex dx = 2 ex dx + 4

2

ex dx ≈ 1 3

  • e0 + 4e + e2

+ 1 3

  • e2 + 4e3 + e4

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 6 / 35

slide-16
SLIDE 16

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (2/3)

Applying Simpson’s rule on each of the intervals [0, 2] and [2, 4] uses h = 1 and gives 4 ex dx = 2 ex dx + 4

2

ex dx ≈ 1 3

  • e0 + 4e + e2

+ 1 3

  • e2 + 4e3 + e4

= 1 3

  • e0 + 4e + 2e2 + 4e3 + e4

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 6 / 35

slide-17
SLIDE 17

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (2/3)

Applying Simpson’s rule on each of the intervals [0, 2] and [2, 4] uses h = 1 and gives 4 ex dx = 2 ex dx + 4

2

ex dx ≈ 1 3

  • e0 + 4e + e2

+ 1 3

  • e2 + 4e3 + e4

= 1 3

  • e0 + 4e + 2e2 + 4e3 + e4

= 53.86385 The error has been reduced to −0.26570.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 6 / 35

slide-18
SLIDE 18

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (3/3)

For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpson’s rule four times with h = 1

2

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 7 / 35

slide-19
SLIDE 19

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (3/3)

For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpson’s rule four times with h = 1

2 giving

4 ex dx = 1 ex dx + 2

1

ex dx + 3

2

ex dx + 4

3

ex dx

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 7 / 35

slide-20
SLIDE 20

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (3/3)

For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpson’s rule four times with h = 1

2 giving

4 ex dx = 1 ex dx + 2

1

ex dx + 3

2

ex dx + 4

3

ex dx ≈ 1 6

  • e0 + 4e1/2 + e
  • + 1

6

  • e + 4e3/2 + e2

+ 1 6

  • e2 + 4e5/2 + e3

+ 1 6

  • e3 + 4e7/2 + e4

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 7 / 35

slide-21
SLIDE 21

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (3/3)

For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpson’s rule four times with h = 1

2 giving

4 ex dx = 1 ex dx + 2

1

ex dx + 3

2

ex dx + 4

3

ex dx ≈ 1 6

  • e0 + 4e1/2 + e
  • + 1

6

  • e + 4e3/2 + e2

+ 1 6

  • e2 + 4e5/2 + e3

+ 1 6

  • e3 + 4e7/2 + e4

= 1 6

  • e0 + 4e1/2 + 2e + 4e3/2 + 2e2 + 4e5/2 + 2e3 + 4e7/2 + e4

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 7 / 35

slide-22
SLIDE 22

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Motivating Example

Solution (3/3)

For the integrals on [0, 1],[1, 2],[3, 4], and [3, 4] we use Simpson’s rule four times with h = 1

2 giving

4 ex dx = 1 ex dx + 2

1

ex dx + 3

2

ex dx + 4

3

ex dx ≈ 1 6

  • e0 + 4e1/2 + e
  • + 1

6

  • e + 4e3/2 + e2

+ 1 6

  • e2 + 4e5/2 + e3

+ 1 6

  • e3 + 4e7/2 + e4

= 1 6

  • e0 + 4e1/2 + 2e + 4e3/2 + 2e2 + 4e5/2 + 2e3 + 4e7/2 + e4

= 53.61622. The error for this approximation has been reduced to −0.01807.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 7 / 35

slide-23
SLIDE 23

Example Composite Simpson Composite Trapezoidal Example

Outline

1

A Motivating Example

2

The Composite Simpson’s Rule

3

The Composite Trapezoidal & Midpoint Rules

4

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 8 / 35

slide-24
SLIDE 24

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

To generalize this procedure for an arbitrary integral b

a

f(x) dx, choose an even integer n. Subdivide the interval [a, b] into n subintervals, and apply Simpson’s rule on each consecutive pair of subintervals.

y x a 5 x0 x2 b 5 xn y 5 f(x) x2j22 x2j21 x2j

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 9 / 35

slide-25
SLIDE 25

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term

With h = (b − a)/n and xj = a + jh, for each j = 0, 1, . . . , n,

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 10 / 35

slide-26
SLIDE 26

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term

With h = (b − a)/n and xj = a + jh, for each j = 0, 1, . . . , n, we have b

a

f(x) dx =

n/2

  • j=1

x2j

x2j−2

f(x) dx =

n/2

  • j=1

h 3[f(x2j−2) + 4f(x2j−1) + f(x2j)] − h5 90f (4)(ξj)

  • for some ξj with x2j−2 < ξj < x2j, provided that f ∈ C4[a, b].

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 10 / 35

slide-27
SLIDE 27

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

b

a

f(x) dx =

n/2

  • j=1

h 3[f(x2j−2) + 4f(x2j−1) + f(x2j)] − h5 90f (4)(ξj)

  • Construct the Formula & Error Term (Cont’d)

Using the fact that for each j = 1, 2, . . . , (n/2) − 1 we have f(x2j) appearing in the term corresponding to the interval [x2j−2, x2j]

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 11 / 35

slide-28
SLIDE 28

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

b

a

f(x) dx =

n/2

  • j=1

h 3[f(x2j−2) + 4f(x2j−1) + f(x2j)] − h5 90f (4)(ξj)

  • Construct the Formula & Error Term (Cont’d)

Using the fact that for each j = 1, 2, . . . , (n/2) − 1 we have f(x2j) appearing in the term corresponding to the interval [x2j−2, x2j] and also in the term corresponding to the interval [x2j, x2j+2],

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 11 / 35

slide-29
SLIDE 29

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

b

a

f(x) dx =

n/2

  • j=1

h 3[f(x2j−2) + 4f(x2j−1) + f(x2j)] − h5 90f (4)(ξj)

  • Construct the Formula & Error Term (Cont’d)

Using the fact that for each j = 1, 2, . . . , (n/2) − 1 we have f(x2j) appearing in the term corresponding to the interval [x2j−2, x2j] and also in the term corresponding to the interval [x2j, x2j+2], we can reduce this sum to b

a

f(x) dx = h 3  f(x0) + 2

(n/2)−1

  • j=1

f(x2j) + 4

n/2

  • j=1

f(x2j−1) + f(xn)   − h5 90

n/2

  • j=1

f (4)(ξj)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 11 / 35

slide-30
SLIDE 30

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term (Cont’d)

The error associated with this approximation is E(f) = − h5 90

n/2

  • j=1

f (4)(ξj) where x2j−2 < ξj < x2j, for each j = 1, 2, . . . , n/2. If f ∈ C4[a, b], the Extreme Value Theorem

See Theorem implies that f (4) assumes its

maximum and minimum in [a, b].

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 12 / 35

slide-31
SLIDE 31

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term (Cont’d)

Since min

x∈[a,b] f (4)(x) ≤ f (4)(ξj) ≤ max x∈[a,b] f (4)(x)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 13 / 35

slide-32
SLIDE 32

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term (Cont’d)

Since min

x∈[a,b] f (4)(x) ≤ f (4)(ξj) ≤ max x∈[a,b] f (4)(x)

we have n 2 min

x∈[a,b] f (4)(x) ≤ n/2

  • j=1

f (4)(ξj) ≤ n 2 max

x∈[a,b] f (4)(x)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 13 / 35

slide-33
SLIDE 33

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term (Cont’d)

Since min

x∈[a,b] f (4)(x) ≤ f (4)(ξj) ≤ max x∈[a,b] f (4)(x)

we have n 2 min

x∈[a,b] f (4)(x) ≤ n/2

  • j=1

f (4)(ξj) ≤ n 2 max

x∈[a,b] f (4)(x)

and min

x∈[a,b] f (4)(x) ≤ 2

n

n/2

  • j=1

f (4)(ξj) ≤ max

x∈[a,b] f (4)(x)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 13 / 35

slide-34
SLIDE 34

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term (Cont’d)

By the Intermediate Value Theorem

See Theorem Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 14 / 35

slide-35
SLIDE 35

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term (Cont’d)

By the Intermediate Value Theorem

See Theorem there is a µ ∈ (a, b)

such that f (4)(µ) = 2 n

n/2

  • j=1

f (4)(ξj)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 14 / 35

slide-36
SLIDE 36

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term (Cont’d)

By the Intermediate Value Theorem

See Theorem there is a µ ∈ (a, b)

such that f (4)(µ) = 2 n

n/2

  • j=1

f (4)(ξj) Thus E(f) = − h5 90

n/2

  • j=1

f (4)(ξj) = − h5 180nf (4)(µ)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 14 / 35

slide-37
SLIDE 37

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Construct the Formula & Error Term (Cont’d)

By the Intermediate Value Theorem

See Theorem there is a µ ∈ (a, b)

such that f (4)(µ) = 2 n

n/2

  • j=1

f (4)(ξj) Thus E(f) = − h5 90

n/2

  • j=1

f (4)(ξj) = − h5 180nf (4)(µ)

  • r, since h = (b − a)/n,

E(f) = −(b − a) 180 h4f (4)(µ)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 14 / 35

slide-38
SLIDE 38

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

These observations produce the following result.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 15 / 35

slide-39
SLIDE 39

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

These observations produce the following result.

Theorem: Composite Simpson’s Rule

Let f ∈ C4[a, b], n be even, h = (b − a)/n, and xj = a + jh, for each j = 0, 1, . . . , n.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 15 / 35

slide-40
SLIDE 40

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

These observations produce the following result.

Theorem: Composite Simpson’s Rule

Let f ∈ C4[a, b], n be even, h = (b − a)/n, and xj = a + jh, for each j = 0, 1, . . . , n. There exists a µ ∈ (a, b) for which the Composite Simpson’s rule for n subintervals can be written with its error term as b

a

f(x) dx = h 3  f(a) + 2

(n/2)−1

  • j=1

f(x2j) + 4

n/2

  • j=1

f(x2j−1) + f(b)   −b − a 180 h4f (4)(µ)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 15 / 35

slide-41
SLIDE 41

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Comments on the Formula & Error Term

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 16 / 35

slide-42
SLIDE 42

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Comments on the Formula & Error Term

Notice that the error term for the Composite Simpson’s rule is O(h4), whereas it was O(h5) for the standard Simpson’s rule.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 16 / 35

slide-43
SLIDE 43

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Comments on the Formula & Error Term

Notice that the error term for the Composite Simpson’s rule is O(h4), whereas it was O(h5) for the standard Simpson’s rule. However, these rates are not comparable because, for the standard Simpson’s rule, we have h fixed at h = (b − a)/2, but for Composite Simpson’s rule we have h = (b − a)/n, for n an even integer.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 16 / 35

slide-44
SLIDE 44

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Comments on the Formula & Error Term

Notice that the error term for the Composite Simpson’s rule is O(h4), whereas it was O(h5) for the standard Simpson’s rule. However, these rates are not comparable because, for the standard Simpson’s rule, we have h fixed at h = (b − a)/2, but for Composite Simpson’s rule we have h = (b − a)/n, for n an even integer. This permits us to considerably reduce the value of h.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 16 / 35

slide-45
SLIDE 45

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Simpson’s Rule

Comments on the Formula & Error Term

Notice that the error term for the Composite Simpson’s rule is O(h4), whereas it was O(h5) for the standard Simpson’s rule. However, these rates are not comparable because, for the standard Simpson’s rule, we have h fixed at h = (b − a)/2, but for Composite Simpson’s rule we have h = (b − a)/n, for n an even integer. This permits us to considerably reduce the value of h. The following algorithm uses the Composite Simpson’s rule on n

  • subintervals. It is the most frequently-used general-purpose

quadrature algorithm.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 16 / 35

slide-46
SLIDE 46

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-47
SLIDE 47

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

INPUT

endpoints a, b; even positive integer n

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-48
SLIDE 48

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

INPUT

endpoints a, b; even positive integer n

OUTPUT

approximation XI to I

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-49
SLIDE 49

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

INPUT

endpoints a, b; even positive integer n

OUTPUT

approximation XI to I Step 1 Set h = (b − a)/n

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-50
SLIDE 50

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

INPUT

endpoints a, b; even positive integer n

OUTPUT

approximation XI to I Step 1 Set h = (b − a)/n Step 2 Set XI0 = f(a) + f(b) XI1 = 0; (Summation of f(x2i−1) XI2 = 0. (Summation of f(x2i))

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-51
SLIDE 51

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

INPUT

endpoints a, b; even positive integer n

OUTPUT

approximation XI to I Step 1 Set h = (b − a)/n Step 2 Set XI0 = f(a) + f(b) XI1 = 0; (Summation of f(x2i−1) XI2 = 0. (Summation of f(x2i)) Step 3 For i = 1, . . . , n − 1 do Steps 4 and 5:

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-52
SLIDE 52

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

INPUT

endpoints a, b; even positive integer n

OUTPUT

approximation XI to I Step 1 Set h = (b − a)/n Step 2 Set XI0 = f(a) + f(b) XI1 = 0; (Summation of f(x2i−1) XI2 = 0. (Summation of f(x2i)) Step 3 For i = 1, . . . , n − 1 do Steps 4 and 5: Step 4: Set X = a + ih

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-53
SLIDE 53

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

INPUT

endpoints a, b; even positive integer n

OUTPUT

approximation XI to I Step 1 Set h = (b − a)/n Step 2 Set XI0 = f(a) + f(b) XI1 = 0; (Summation of f(x2i−1) XI2 = 0. (Summation of f(x2i)) Step 3 For i = 1, . . . , n − 1 do Steps 4 and 5: Step 4: Set X = a + ih Step 5: If i is even then set XI2 = XI2 + f(X) else set XI1 = XI1 + f(X)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-54
SLIDE 54

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

INPUT

endpoints a, b; even positive integer n

OUTPUT

approximation XI to I Step 1 Set h = (b − a)/n Step 2 Set XI0 = f(a) + f(b) XI1 = 0; (Summation of f(x2i−1) XI2 = 0. (Summation of f(x2i)) Step 3 For i = 1, . . . , n − 1 do Steps 4 and 5: Step 4: Set X = a + ih Step 5: If i is even then set XI2 = XI2 + f(X) else set XI1 = XI1 + f(X) Step 6 Set XI = h(XI0 + 2 · XI2 + 4 · XI1)/3

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-55
SLIDE 55

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Simpson’s Rule Algorithm

To approximate the integral I = b

a f(x) dx:

INPUT

endpoints a, b; even positive integer n

OUTPUT

approximation XI to I Step 1 Set h = (b − a)/n Step 2 Set XI0 = f(a) + f(b) XI1 = 0; (Summation of f(x2i−1) XI2 = 0. (Summation of f(x2i)) Step 3 For i = 1, . . . , n − 1 do Steps 4 and 5: Step 4: Set X = a + ih Step 5: If i is even then set XI2 = XI2 + f(X) else set XI1 = XI1 + f(X) Step 6 Set XI = h(XI0 + 2 · XI2 + 4 · XI1)/3 Step 7

OUTPUT (XI) STOP

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 17 / 35

slide-56
SLIDE 56

Example Composite Simpson Composite Trapezoidal Example

Outline

1

A Motivating Example

2

The Composite Simpson’s Rule

3

The Composite Trapezoidal & Midpoint Rules

4

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 18 / 35

slide-57
SLIDE 57

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Trapezoidal & Midpoint Rules

Preamble

The subdivision approach can be applied to any of the Newton-Cotes formulas.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 19 / 35

slide-58
SLIDE 58

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Trapezoidal & Midpoint Rules

Preamble

The subdivision approach can be applied to any of the Newton-Cotes formulas. The extensions of the Trapezoidal and Midpoint rules will be presented without proof.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 19 / 35

slide-59
SLIDE 59

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Trapezoidal & Midpoint Rules

Preamble

The subdivision approach can be applied to any of the Newton-Cotes formulas. The extensions of the Trapezoidal and Midpoint rules will be presented without proof. The Trapezoidal rule requires only one interval for each application, so the integer n can be either odd or even.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 19 / 35

slide-60
SLIDE 60

Example Composite Simpson Composite Trapezoidal Example

Composite Integration: Trapezoidal & Midpoint Rules

Preamble

The subdivision approach can be applied to any of the Newton-Cotes formulas. The extensions of the Trapezoidal and Midpoint rules will be presented without proof. The Trapezoidal rule requires only one interval for each application, so the integer n can be either odd or even. For the Midpoint rule, however, the integer n must be even.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 19 / 35

slide-61
SLIDE 61

Example Composite Simpson Composite Trapezoidal Example

Numerical Integration: Composite Trapezoidal Rule

y x a 5 x0 b 5 xn y 5 f(x) xj21 xj x1 xn21

Note: The Trapezoidal rule requires only one interval for each application, so the integer n can be either odd or even.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 20 / 35

slide-62
SLIDE 62

Example Composite Simpson Composite Trapezoidal Example

Numerical Integration: Composite Trapezoidal Rule

Theorem: Composite Trapezoidal Rule

Let f ∈ C2[a, b], h = (b − a)/n, and xj = a + jh, for each j = 0, 1, . . . , n.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 21 / 35

slide-63
SLIDE 63

Example Composite Simpson Composite Trapezoidal Example

Numerical Integration: Composite Trapezoidal Rule

Theorem: Composite Trapezoidal Rule

Let f ∈ C2[a, b], h = (b − a)/n, and xj = a + jh, for each j = 0, 1, . . . , n. There exists a µ ∈ (a, b) for which the Composite Trapezoidal Rule for n subintervals can be written with its error term as b

a

f(x) dx = h 2  f(a) + 2

n−1

  • j=1

f(xj) + f(b)   − b − a 12 h2f ′′(µ)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 21 / 35

slide-64
SLIDE 64

Example Composite Simpson Composite Trapezoidal Example

Numerical Integration: Composite Midpoint Rule

Midpoint Rule (1-point open Newton-Cotes formula)

x1

x−1

f(x) dx = 2hf(x0) + h3 3 f ′′(ξ), where x−1 < ξ < x1

Theorem: Composite Midpoint Rule

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 22 / 35

slide-65
SLIDE 65

Example Composite Simpson Composite Trapezoidal Example

Numerical Integration: Composite Midpoint Rule

Midpoint Rule (1-point open Newton-Cotes formula)

x1

x−1

f(x) dx = 2hf(x0) + h3 3 f ′′(ξ), where x−1 < ξ < x1

Theorem: Composite Midpoint Rule

Let f ∈ C2[a, b], n be even, h = (b − a)/(n + 2), and xj = a + (j + 1)h for each j = −1, 0, . . . , n + 1.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 22 / 35

slide-66
SLIDE 66

Example Composite Simpson Composite Trapezoidal Example

Numerical Integration: Composite Midpoint Rule

Midpoint Rule (1-point open Newton-Cotes formula)

x1

x−1

f(x) dx = 2hf(x0) + h3 3 f ′′(ξ), where x−1 < ξ < x1

Theorem: Composite Midpoint Rule

Let f ∈ C2[a, b], n be even, h = (b − a)/(n + 2), and xj = a + (j + 1)h for each j = −1, 0, . . . , n + 1. There exists a µ ∈ (a, b) for which the Composite Midpoint rule for n + 2 subintervals can be written with its error term as b

a

f(x) dx = 2h

n/2

  • j=0

f(x2j) + b − a 6 h2f ′′(µ)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 22 / 35

slide-67
SLIDE 67

Example Composite Simpson Composite Trapezoidal Example

Numerical Integration: Composite Midpoint Rule

x y a 5 x21 x0 x1 xn x2j21 xn21 x2j x2j11 b 5 xn11 y 5 f (x)

Note: The Midpoint Rule requires two intervals for each application, so the integer n must be even.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 23 / 35

slide-68
SLIDE 68

Example Composite Simpson Composite Trapezoidal Example

Outline

1

A Motivating Example

2

The Composite Simpson’s Rule

3

The Composite Trapezoidal & Midpoint Rules

4

Comparing the Composite Simpson & Trapezoidal Rules

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 24 / 35

slide-69
SLIDE 69

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Example: Trapezoidal .v. Simpson’s Rules

Determine values of h that will ensure an approximation error of less than 0.00002 when approximating π

0 sin x dx and employing:

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 25 / 35

slide-70
SLIDE 70

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Example: Trapezoidal .v. Simpson’s Rules

Determine values of h that will ensure an approximation error of less than 0.00002 when approximating π

0 sin x dx and employing:

(a) Composite Trapezoidal rule and

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 25 / 35

slide-71
SLIDE 71

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Example: Trapezoidal .v. Simpson’s Rules

Determine values of h that will ensure an approximation error of less than 0.00002 when approximating π

0 sin x dx and employing:

(a) Composite Trapezoidal rule and (b) Composite Simpson’s rule.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 25 / 35

slide-72
SLIDE 72

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Solution (1/5)

The error form for the Composite Trapezoidal rule for f(x) = sin x on [0, π] is

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 26 / 35

slide-73
SLIDE 73

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Solution (1/5)

The error form for the Composite Trapezoidal rule for f(x) = sin x on [0, π] is

  • πh2

12 f ′′(µ)

  • =
  • πh2

12 (− sin µ)

  • = πh2

12 | sin µ|.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 26 / 35

slide-74
SLIDE 74

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Solution (1/5)

The error form for the Composite Trapezoidal rule for f(x) = sin x on [0, π] is

  • πh2

12 f ′′(µ)

  • =
  • πh2

12 (− sin µ)

  • = πh2

12 | sin µ|. To ensure sufficient accuracy with this technique, we need to have πh2 12 | sin µ| ≤ πh2 12 < 0.00002.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 26 / 35

slide-75
SLIDE 75

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

πh2 12 | sin µ| ≤ πh2 12 < 0.00002

Solution (2/5)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 27 / 35

slide-76
SLIDE 76

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

πh2 12 | sin µ| ≤ πh2 12 < 0.00002

Solution (2/5)

Since h = π/n implies that n = π/h, we need π3 12n2 < 0.00002

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 27 / 35

slide-77
SLIDE 77

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

πh2 12 | sin µ| ≤ πh2 12 < 0.00002

Solution (2/5)

Since h = π/n implies that n = π/h, we need π3 12n2 < 0.00002 ⇒ n >

  • π3

12(0.00002) 1/2 ≈ 359.44 and the Composite Trapezoidal rule requires n ≥ 360.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 27 / 35

slide-78
SLIDE 78

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Solution (3/5)

The error form for the Composite Simpson’s rule for f(x) = sin x on [0, π] is

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 28 / 35

slide-79
SLIDE 79

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Solution (3/5)

The error form for the Composite Simpson’s rule for f(x) = sin x on [0, π] is

  • πh4

180f (4)(µ)

  • =
  • πh4

180 sin µ

  • = πh4

180| sin µ|

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 28 / 35

slide-80
SLIDE 80

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Solution (3/5)

The error form for the Composite Simpson’s rule for f(x) = sin x on [0, π] is

  • πh4

180f (4)(µ)

  • =
  • πh4

180 sin µ

  • = πh4

180| sin µ| To ensure sufficient accuracy with this technique we need to have πh4 180| sin µ| ≤ πh4 180 < 0.00002

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 28 / 35

slide-81
SLIDE 81

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

πh4 180| sin µ| ≤ πh4 180 < 0.00002

Solution (4/5)

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 29 / 35

slide-82
SLIDE 82

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

πh4 180| sin µ| ≤ πh4 180 < 0.00002

Solution (4/5)

Using again the fact that n = π/h gives π5 180n4 < 0.00002

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 29 / 35

slide-83
SLIDE 83

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

πh4 180| sin µ| ≤ πh4 180 < 0.00002

Solution (4/5)

Using again the fact that n = π/h gives π5 180n4 < 0.00002 ⇒ n >

  • π5

180(0.00002) 1/4 ≈ 17.07 So Composite Simpson’s rule requires only n ≥ 18.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 29 / 35

slide-84
SLIDE 84

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Solution (5/5)

Composite Simpson’s rule with n = 18 gives π sin x dx ≈ π 54  2

8

  • j=1

sin jπ 9

  • + 4

9

  • j=1

sin (2j − 1)π 18   = 2.0000104

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 30 / 35

slide-85
SLIDE 85

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Example

Solution (5/5)

Composite Simpson’s rule with n = 18 gives π sin x dx ≈ π 54  2

8

  • j=1

sin jπ 9

  • + 4

9

  • j=1

sin (2j − 1)π 18   = 2.0000104 This is accurate to within about 10−5 because the true value is − cos(π) − (− cos(0)) = 2.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 30 / 35

slide-86
SLIDE 86

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Conclusion

Composite Simpson’s rule is the clear choice if you wish to minimize computation.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 31 / 35

slide-87
SLIDE 87

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Conclusion

Composite Simpson’s rule is the clear choice if you wish to minimize computation. For comparison purposes, consider the Composite Trapezoidal rule using h = π/18 for the integral in the previous example.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 31 / 35

slide-88
SLIDE 88

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Conclusion

Composite Simpson’s rule is the clear choice if you wish to minimize computation. For comparison purposes, consider the Composite Trapezoidal rule using h = π/18 for the integral in the previous example. This approximation uses the same function evaluations as Composite Simpson’s rule but the approximation in this case π sin x dx ≈ π 36  2

17

  • j=1

sin jπ 18

  • + sin 0 + sin π

 

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 31 / 35

slide-89
SLIDE 89

Example Composite Simpson Composite Trapezoidal Example

Composite Numerical Integration: Conclusion

Composite Simpson’s rule is the clear choice if you wish to minimize computation. For comparison purposes, consider the Composite Trapezoidal rule using h = π/18 for the integral in the previous example. This approximation uses the same function evaluations as Composite Simpson’s rule but the approximation in this case π sin x dx ≈ π 36  2

17

  • j=1

sin jπ 18

  • + sin 0 + sin π

  = π 36  2

17

  • j=1

sin jπ 18   = 1.9949205 is accurate only to about 5 × 10−3.

Numerical Analysis (Chapter 4) Composite Numerical Integration I R L Burden & J D Faires 31 / 35

slide-90
SLIDE 90

Questions?

slide-91
SLIDE 91

Reference Material

slide-92
SLIDE 92

The Extreme Value Theorem

If f ∈ C[a, b], then c1, c2 ∈ [a, b] exist with f(c1) ≤ f(x) ≤ f(c2), for all x ∈ [a, b]. In addition, if f is differentiable on (a, b), then the numbers c1 and c2 occur either at the endpoints of [a, b] or where f ′ is zero.

Return to Derivation of the Composite Simpson’s Rule

y x a c2 c1 b y 5 f (x)

slide-93
SLIDE 93

Intermediate Value Theorem

If f ∈ C[a, b] and K is any number between f(a) and f(b), then there exists a number c ∈ (a, b) for which f(c) = K.

x y f(a) f(b) y 5 f (x) K (a, f(a)) (b, f(b)) a b c

(The diagram shows one of 3 possibilities for this function and interval.)

Return to Derivation of the Composite Simpson’s Rule