eciv 301 programming & graphics numerical methods for engineers lecture 29 numerical integration
Post on 20-Jan-2016
226 views
TRANSCRIPT
ECIV 301
Programming & Graphics
Numerical Methods for Engineers
Lecture 29
Numerical Integration
Motivation
b
a
dxxfI
AREA BETWEEN a AND b
Think as Engineers!
In Summary
INTERPOLATE
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
In Summary
Also by piecewise approximation
b
ax
x
x
n
b
a
i
i
i
dxxf
dxxfI
1
Closed/Open Forms
CLOSED OPEN
Trapezoidal RuleLinear Interpolation
Trapezoidal Rule ax
ab
afbfafxf
)()(
)()(1
Trapezoidal Rule
dxaxab
afbfafdxxf
)()()()(1
2
)a(f)b(fabI
12
3hOError
Trapezoidal Rule Multiple Application
Trapezoidal Rule Multiple Application
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)
Simpson’s 1/3 Rule
Quadratic Interpolation
22102 )( xaxaaxf
Simpson’s 1/3 Rule dxxaxaadxxf 2
2102 )(
6
)()(4)( 210 xfxfxfabI
90
5hOError
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
Simpson’s 3/8 Rule
Cubic Interpolation
33
22102 xaxaxaa)x(f
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
Gauss Quadrature
x1 x2
2211 xfwxfwI
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
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
Gauss Quadrature
b
a
dx)x(fI
2
Gxababx
Gdx
abdx
2
1
12dx)x(f
abdx)x(fI
b
a
Gauss Quadrature
1
12dx)x(f
abdx)x(fI
b
a
n
ii xfwab
I12
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
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
Gaussian Quadrature
Not a good method if function is not available