26
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

  • View
    226

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

ECIV 301

Programming & Graphics

Numerical Methods for Engineers

Lecture 29

Numerical Integration

Page 2: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Motivation

b

a

dxxfI

AREA BETWEEN a AND b

Page 3: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Think as Engineers!

Page 4: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

In Summary

INTERPOLATE

Page 5: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

In SummaryNewton-Cotes Formulas

Replace a complicated function or tabulated data with an approximating

function that is easy to integrate

b

a

n

b

a

dxxfdxxfI

nn

nnon xaxaxaaxf

111

Page 6: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

In Summary

Also by piecewise approximation

b

ax

x

x

n

b

a

i

i

i

dxxf

dxxfI

1

Page 7: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Closed/Open Forms

CLOSED OPEN

Page 8: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Trapezoidal RuleLinear Interpolation

Page 9: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Trapezoidal Rule ax

ab

afbfafxf

)()(

)()(1

Page 10: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Trapezoidal Rule

dxaxab

afbfafdxxf

)()()()(1

2

)a(f)b(fabI

12

3hOError

Page 11: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Trapezoidal Rule Multiple Application

Page 12: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Trapezoidal Rule Multiple Application

Page 13: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Trapezoidal Rule Multiple Application

n

xfxfxfabI

n

n

ii

2

22

10

x a=xo x1 x2 … xn-1 b=xn

f(x) f(x0) f(x1) f(x2) f(xn-1) f(xn)

Page 14: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Simpson’s 1/3 Rule

Quadratic Interpolation

22102 )( xaxaaxf

Page 15: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Simpson’s 1/3 Rule dxxaxaadxxf 2

2102 )(

6

)()(4)( 210 xfxfxfabI

90

5hOError

Page 16: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Simpson’s 1/3 Rule

x a=xo x1 x2 … xn-1 b=xn

f(x) f(x0) f(x1) f(x2) f(xn-1) f(xn)

n

xfxfxfxf

abIn

n

ll

n

ii

3

242

6,4,2

1

5,3,10

Page 17: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Simpson’s 3/8 Rule

Cubic Interpolation

33

22102 xaxaxaa)x(f

Page 18: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Simpson’s 3/8 Rule dxxaxaxaadx)x(f 3

32

2102

8

33 3210 )x(f)x(f)x(f)x(fabI

80

3 5hOError

Page 19: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Gauss Quadrature

x1 x2

2211 xfwxfwI

Page 20: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

General Case

2211

1

1

xfwxfwdx)x(fI

Gauss Method calculates pairs of wi, xi for the Integration limits

-1,1

For Other Integration LimitsUse Transformation

Page 21: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Gauss Quadrature

b

a

dx)x(fIGxaax 10

10 aaa

10 aab

For xg=-1, x=a

For xg=1, x=b

20

aba

21

aba

Page 22: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Gauss Quadrature

b

a

dx)x(fI

2

Gxababx

Gdx

abdx

2

1

12dx)x(f

abdx)x(fI

b

a

Page 23: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Gauss Quadrature

1

12dx)x(f

abdx)x(fI

b

a

n

ii xfwab

I12

Page 24: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Gauss Quadrature

Points

Weighting Factors wi

Function Arguments

Error

2 W0=1.0 X0=-0.577350269 F(4)()

W1=1.0 X1= 0.577350269

3 W0=0.5555556 X0=-0.77459669 F(6)()

W1=0.8888888 X0=0.0

W0=0.5555556 X0=0.77459669

Page 25: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Gaussian Points

Points

Weighting Factors wi

Function Arguments

Error

4 W0=0.3478548 X0=-0.861136312 F(8)()

W1=0.6521452 X1=-339981044

W2=0.6521452 X2=- 339981044

W3=0.3478548 X3=0.861136312

Page 26: ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 29 Numerical Integration

Gaussian Quadrature

Not a good method if function is not available