ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integ Integration Integration Definition – Total area within a region – In mathematical terms, it is the total value, or summation, of f(x) dx over the range from a to b: I fx a b dx
15
Embed
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical IntegrationIntegration Definition –Total area within a region –In mathematical.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration
IntegrationIntegration
Definition– Total area within a region
– In mathematical terms, it is the total value, or summation, of f(x) dx over the range from a to b:
I f x a
b dx
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration
Newton-Cotes FormulasNewton-Cotes Formulas
General Idea– replace a complicated function or tabulated data with a polynomial
that is easy to integrate:
– where fn(x) is an nth order interpolating polynomial.
I f x a
b dx fn x a
b dx
dxxaxaxaadxxfdxxfIb
a
nn
b
a n
b
a ... 2
210
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration
Trapezoid Rule ExamplesTrapezoid Rule Examples
Tabulated
Inline Function
% f(x)=cos(x)+sin(2x) on [0 pi/2]h=(pi/2-0)/10;>> x=0:h:pi/2;>> y=cos(x)+sin(2*x);>> I2=trapz(x,y)1.9897
p=inline('cos(x)+sin(2*x)');>> I3=trap(p,0,pi/2,10)1.9897% plot f(x) and I(x)>> for k=1:11I4(k)=trap(p,0,x(k),20);end;>> plot(x,y,x,I4,'r')
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration
Simpson’s RulesSimpson’s Rules
Increasing the approximation order results in better integration accuracy– Simpson’s 1/3 rule
• based on taking 2nd order polynomial integrations• use two panels (three points) every integral• only for even number of panels
– Simpson’s 3/8 rule is• based on taking 3rd order polynomial integrations• use three panels (four points) every integral• only for three-multiple number of panels
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration
Simpson’s 1/3 RuleSimpson’s 1/3 Rule
Using the Lagrange form for a quadratic fit of three points:– Integration over the three points simplifies to:
Composite
dxxfIx
x n 2
0
fn x x x1 x0 x1
x x2 x0 x2
f x0 x x0 x1 x0
x x2 x1 x2
f x1 x x0 x2 x0
x x1 x2 x1
f x2
2
43
02
210
xxh
xfxfxfh
I
n
n
jj
i
n
ii
i
nnn
xfxfxfxfh
I
xfxfxfh
xfxfxfh
xfxfxfh
I
2
even ,2
1
odd ,1
0
12432210
243
43
43
43
n
abh
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration
Simpson’s 3/8 RuleSimpson’s 3/8 Rule
Basic
Composite
n
abh
3210 338
3
3
0
xfxfxfxfh
dxxfIx
x n
203 xx
h
nnn
b
a n xfxfxfxf
xfxfxfxfxfhdxxfI
125
43210
33...3
3233
8
3
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration
Combined Simpson’s RuleCombined Simpson’s Rule
Combined Simpson’s rule– If n (number of panels) is even, use Simpson’s 1/3 rule– If n is odd, use Simpson’s 3/8 rule once at beginning or
end and use Simpson’s 1/3 rule for the rest of the panels
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration
Error of Simpson’s 1/3 RuleError of Simpson’s 1/3 Rule
If f(x) is a polynomial function of degree 3 or less, Simpson’s rule provides no error.
Use smaller spacing (h decreases) or more panels to reduce the error.
In general, Simpson’s rule is accurate enough for the most of functions f(x) with much less panels compared to that with the trapezoidal rule.
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical Integration