Calculus 1120 Dan Barbasch Oct. 2, 2012 Dan Barbasch () Calculus - - PowerPoint PPT Presentation

calculus 1120
SMART_READER_LITE
LIVE PREVIEW

Calculus 1120 Dan Barbasch Oct. 2, 2012 Dan Barbasch () Calculus - - PowerPoint PPT Presentation

Calculus 1120 Dan Barbasch Oct. 2, 2012 Dan Barbasch () Calculus 1120 Oct. 2, 2012 1 / 7 Numerical Integration Many integrals cannot be computed using FTC because while the definite integral exists because the function to be integrated is


slide-1
SLIDE 1

Calculus 1120

Dan Barbasch

  • Oct. 2, 2012

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

1 / 7

slide-2
SLIDE 2

Numerical Integration

Many integrals cannot be computed using FTC because while the definite integral exists because the function to be integrated is continuous, the antiderivative is NOT a combination of elementary functions. Question: How do you compute a logarithm table? Answer: ln x = x

1

dt t . Use numerical integration. Question: Compute values of Erf (x) = 2 √π x e−t2 dt. This integral (function of x) is very important for probability, especially its

  • applications. But it is not a combination of elementary functions.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

2 / 7

slide-3
SLIDE 3

Numerical Integration

GENERAL STRATEGY: Approximate the integral b

a f (x) dx using Riemann sums.

1 Divide the interval [a, b] into n equal parts, xi = a +i ·∆x, ∆x = b−a

n .

a = x0 < x1 < · · · < xi−1 < xi < · · · < xn.

2 Choose a point xi−1 < ξi < xi in each interval. Form the sum

n

  • i=1

f (ξi)∆xi = f (ξ1)∆x1 + · · · + f (ξn)∆xn. Usually we divide the interval into n equal parts. So ∆xi = b−a

n . The sum

simplifies to b − a n [f (ξ1) + · · · + f (ξn)] . This is used as an approximation for b

a f (x) dx.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

2 / 7

slide-4
SLIDE 4

Numerical Integration

Left Endpoint: ξi = xi−1. ∆xi = ∆x = b−a

n .

Ln(f ) = ∆x[f (ξ1) + · · · + f (ξn)] = =∆x[f (a) + · · · + f (a + (i − 1)∆x) + · · · + f (a + (n − 1)∆x)] Right Endpoint: ξi = xi. ∆xi = ∆x = b−a

n .

Rn(f ) = ∆x[f (ξ1) + · · · + f (ξn)] = ∆x[f (a + ∆x) + · · · + f (a + i∆x) + · · · + f (a + n∆x)] Midpoint: ξi = xi−1+xi

2

. ∆xi = ∆x = b−a

n .

∆x[f (ξ1) + · · · + f (ξn)] = ∆x

n

  • i=1

f (ξi).

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

2 / 7

slide-5
SLIDE 5

Numerical Integration

Example: ln 3 = 3

1

1 t dt. ∆x = 3−1

n

= 2

n.

Left Endpoint: ξi = xi−1 = 1 + 2(i−1)

n

. Ln(f ) = 2 n

  • 1 +

1 1 + 2/n + · · · + 1 1 + 2(i − 1)/n + · · · + 1 1 + 2(n − 1)/n

  • .

Right Endpoint: ξi = xi = 1 + 2i

n .

Rn(f ) = 2 n

  • 1

1 + 2/n + · · · + 1 1 + 2i/n + · · · + 1 1 + n · 2/n

  • .

We will not use the midpoint formula.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

2 / 7

slide-6
SLIDE 6

Exercise

Write an integral that computes ln 5, and Ln(f ) and Rn(f ) for n = 6. You need not compute. Write out the error estimate for arbitrary n. How many terms do you need to get an error less than 10−3?

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

3 / 7

slide-7
SLIDE 7

Pictures for a decreasing function y = f (x), a ≤ x ≤ b: The picture on the left illustrates b

a f (x) dx ≤ Ln(f ). The picture on the

right illustrates Rn(f ) ≤ b

a f (x) dx.

Exercise: Draw the pictures and write the inequalities for an increasing function.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

4 / 7

slide-8
SLIDE 8

Together they illustrate Rn(f ) ≤ b

a f (x) dx ≤ Ln(f ).

The error EL(f ) = |Ln(f ) − b

a f (x) dx| is the yellow area. The error

ER(f ) = | b

a f (x) dx − Rn(f )| is the green area.

They are both less than the sum of the rectanges above the orange region which add up to Ln(f ) − Rn(f ). This is the Error Estimate EL(f ), ER(f ) ≤ |Ln(f ) − Rn(f )|

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

4 / 7

slide-9
SLIDE 9

Ln(f ) − Rn(f ) = b − a n (f (a) − f (b)). The area in yellow represents Ln(f ) − Rn(f ). If you stack all the rectangles in the first interval, you get a rectangle of width ∆x = b−a

n

and height f (a) − f (b). The area under the secants represents Tn(f ) = 1

2 (Ln(f ) + Rn(f )) , half the

area of the full rectangles, yellow and orange.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

4 / 7

slide-10
SLIDE 10

Concave Functions. ET(f ) =

  • Tn(f ) −

b

a

f (x) dx

  • ≤ |Ln(f ) − Rn(f )|

2 . The function is the bottom of the blue region, below the secants because it is concave up. Tn(f ) is the area below the secant lines bounding the top

  • f the blue regions. The area in blue is the error ET(f ). The area in
  • range is Rn(f ).

The sum of the triangles colored yellow and blue is Ln(f )−Rn(f )

2

. It is half the sum of the yellow rectanges on the previous slide. The error estimate says that the blue area is all contained in the sum of the triangles.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

4 / 7

slide-11
SLIDE 11

Estimates

Increasing Function Ln(f ) ≤ b

a f (x) dx ≤ Rn(f ).

Decreasing Function Rn(f ) ≤ b

a f (x) dx ≤ Ln(f ).

Estimate for a monotone function: Error = |Value − Approximation| . En(f ) =

  • b

a f (x) dx − Ln(f )

  • ,
  • b

a f (x) dx − Rn(f )

  • .

En(f ) ≤ |Rn(f ) − Ln(f )| = b − a n |f (b) − f (a)| For ln 3, the error is therefore less than 2

n|1/3 − 1| = 4 3n.

Problem: Find n so that En(f ) ≤ 10−3. Answer: We know En(f ) ≤

4

  • 3n. If

4 3n ≤ 10−3 (⇒ n ≥ 1334) then certainly

En(f ) ≤ 4 3n ≤ 10−3. The actual approximation L1334(f ) or R1334(f ) is a sum which is hard to compute in practice because you have to add a lot of very small numbers.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

5 / 7

slide-12
SLIDE 12

Estimates

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

5 / 7

slide-13
SLIDE 13

Estimates

  • b

a

f (x) dx − Ln(f ) + Rn(f ) 2

  • ≤ b − a

2n |f (b) − f (a)| . So if we use Tn(f ) := Ln(f )+Rn(f )

2

for the approximation, we can use n = 1334/2 = 667. Ln(f ) =∆x[f (x0)+ f (x1) + · · · + f (xi) + · · · + f (xn−1)] Rn(f ) =∆x[ f (x1) + · · · + f (xi) + · · · + f (xn−1) + f (xn)] Tn(f ) = b − a 2n [f (x0) + 2f (x1) + · · · + 2f (xn−1) + f (xn)]

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

5 / 7

slide-14
SLIDE 14

Trapezoidal/Simpson’s Rule

The estimates from before are for functions which are monotone and concave up/down over the whole interval. If the function does not have these properties, break the integral up into smaller intervals. The left and right endpoint are instances of approximating f (x) by a horizontal line on each interval [xi−1, xi]. We can use other functions such as lines (Trapezoidal Rule), parabolas (Simpson’s Rule) or even higher

  • rder polynomials.

The formulas are not much harder, and the error estimates hold for any functions that have derivatives.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

6 / 7

slide-15
SLIDE 15

Trapezoidal/Simpson’s Rule

Trapezoidal Rule Picture: Tn(f ) = b − a 2n [f (x0) + 2f (x1) + · · · + 2f (xn−1) + f (xn)] Error Estimate: ET,n(f ) ≤ M(b−a)3

12n2

, where M is the maximum value of |f (2)(x)| for a ≤ x ≤ b. A worse formula, but easier to prove is ET,n ≤ b−a

2n |f (b) − f (a)|

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

6 / 7

slide-16
SLIDE 16

Trapezoidal/Simpson’s Rule

The formula for the Approximation is Tn(f ) from the previous slide. In the case of f (x) = 1/x and a = 1 ≤ x ≤ 3, f (2)(x) = −2

x3 . Over the

interval, |f (2)(x)| ≤ 2. So | ln 3 − Tn(f )| ≤ (3 − 1)3 · 2 12n2 = 16 12n2 = 4 3n2 . Solving

4 3n2 ≤ 10−3, n ≥

  • 4000/3, we can take n ≥ 37.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

6 / 7

slide-17
SLIDE 17

Trapezoidal/Simpson’s Rule

Simpson Rule Picture: n must be even. To fit a parabola you need three points, so pairs of intervals [xi−1, xi] and [xi, xi+1]. You want ax2 + bx + c such that ax2

i−1+

bxi−1+ c = f (xi−1) ax2

i +

bxi+ c = f (xi) ax2

i+1+

bxi+1+ c = f (xi+1) If you only ask for the first two, there are too many choices, and the parabolas don’t fit tightly enough.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

6 / 7

slide-18
SLIDE 18

Trapezoidal/Simpson’s Rule

Simpson Rule Picture: xi−1, xi, xi+1 are translated to −h, 0, h, and y0, y1, y2 are the values f (xi−1), f (xi), f (xi+1), and h = ∆x = b−a

n .

Sn(f ) = b − a 3n [f (x0) + 4f (x1) + 2f (x2) + 4f (x3) + · · · + 4f (xn−1) + f (xn)] Error Estimate: ES,n ≤ (b−a)5M

180n4

where M is the maximum of |f (4)(x)|

  • ver the interval a ≤ x ≤ b.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

6 / 7

slide-19
SLIDE 19

Error estimate for ln 3.

For the estimate of ln 3, f (4)(x) = 24

x5 . Its maximum over 1 ≤ x ≤ 3 is

M = 24. ES,n(f ) ≤ (3 − 1)5 · 24 180n4 = 32 · 24 180n4 = 64 15n4 . 64 15n4 ≤ 10−3 ⇒ n ≥ 10. We can write the approximation ln 3 ≈ 2 30 1 1 + 4 1 1.2 + 2 1 1.4 + 4 1 1.6 + 2 1 1.8 + 4 1 2.0 + + 2 1 2.2 + 4 1 2.4 + 2 1 2.6 + 4 1 2.8 + 1 3

  • ≈ 1.09866.

Another way to approximate gives ln 3 ≈ 1.09861, the difference is in the 5th decimal. Exercise: Do this for ln 5.

Dan Barbasch () Calculus 1120

  • Oct. 2, 2012

7 / 7