11
Integration For a function f, The “integral of f from a to b” is the area under the graph of the function. If f is continuous, then the area is well defined, as the common limit of upper and lower sums. The integral is denoted a b x graph of f(x) b a dx x f ) (

Integration

Embed Size (px)

DESCRIPTION

Integration. For a function f , The “integral of f from a to b ” is the area under the graph of the function. If f is continuous, then the area is well defined, as the common limit of upper and lower sums. The integral is denoted. graph of f ( x ). x. a. b. - PowerPoint PPT Presentation

Citation preview

Page 1: Integration

IntegrationFor a function f,

The “integral of f from a to b” is the area under the graph of the function.

If f is continuous, then the area is well defined, as the common limit of upper and lower sums. The integral is denoted

a b x

graph of f(x)

b

a

dxxf )(

Page 2: Integration

Numerical Integration: Trapezoid

a b x

graph of f(x)

a b x

graph of f(x)

approximate this region

with this trapezoid

afbfab

2

AREA

Page 3: Integration

Composite Trapezoid

a b x

graph of f(x)

Apply “trapezoid” approximation to k subdivisions of [a b]

a b x

graph of f(x)

“trapezoid” approximation with 3 subdivisions of [a b]

Page 4: Integration

Composite Trapezoid

a b x

graph of f(x)

“trapezoid” approximation with 3 subdivisions of [a b]

h

Let h=(b-a)/3. The sum of all the approximations is

)()2(2)(2)(2

)()2(2

)2()(2

)()(2

bfhafhafafh

bfhafh

hafhafh

hafafh

I

Page 5: Integration

Simpson’s Rule: Suppose f(x)=x

22

2

1 abdxx

b

a

bfab

fafab2

46

1

Let a = 2 and b = 8

½(64-4) = 30

1/6(6)(2 + 4*5 +8) = 30

Page 6: Integration

Derivation of Simpson’s Rule: Suppose f(x)=x3

443

4

1 abdxx

b

a

3223

4

1abaabbab

332233

3

2

3

1

3

1

3

2

4

1aabaabbbab

333

3

2

3

1

3

2

4

1aabbab

33

3

3

2

23

8

3

2

4

1a

abbab

33

3

24

6

1a

abbab

bfab

fafab2

46

1

Page 7: Integration

Simpson’s Rule: Derivation

bfab

fafabdxxfb

a 24

6

1)(

Put all of those together, along with

Hence: If f is any cubic polynomial, then

This is the basis for Simpson’s rule.

b

a

b

a

b

a

dxxgdxxfdxxgxf )()()()(

b

a

b

a

dxxfdxxf )()(

Page 8: Integration

Simpson’s Rule

bfab

fafabI2

46

1Simpson

For any function f, the Simpson’s approximation to

is

b

a

dxxf )(

Evaluate the function at the endpoints

and in the middle

Page 9: Integration

Composite Simpson’s Rule

a b x

graph of f(x)

Simpson on 3 subdivisions of [a b]

h

h=(b-a)/3

hafafafh

I hS 21 4

6

hafafhafh

I hS 24

62

32

bfafhafh

I hS 2

53 426

Add them up. Total of 7 function evaluations.

Page 10: Integration

Numerical Integration: Ad-Hoc stopping criteria

Pick a method (trapezoid, or Simpson’s).

Set a stopping tolerance TOL.

Pick k, an initial number of subdivisions

Iterate as below–Apply composite method using k divisions–Apply composite method using 2k divisions–If answers are within TOL, stop, and return the 2k division

answer– If answers are not within TOL, increase k and repeat.

.

Page 11: Integration

Adaptive Stepsize

Only use small h (the “stepsize”) where the convergence demands it. Recursive implementation is straightforward.

function I = adr(fh,a,b,tol)

Compute I1 using 1 subdivision

Compute I2 using 2 subdivisions

If the answers are within tol, I = I2;

Else

m = (a+b)/2;

ILeft = adr(fh,a,m,tol/2);

IRight = adr(fh,m,b,tol/2);

I = ILeft + IRight;

end