SlideShare a Scribd company logo
1 of 30
Download to read offline
Lecture 10—Numerical Integration
Outline
1 Numerical Integration
A Chemical Engineering Example
The Newton-Cotes Formulae
Composite Newton-Cotes Formulae — Trapezoidal/Simpson’s Rule
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 1 / 21
Calculating the Enthalpy of a Non-Ideal Gas
Suppose that we are designing a process unit that handles vapor-phase
ethanol at high pressure (e.g., 600 atm), where the ideal gas law fails.
We need to find out how much heat our process unit requires to maintain a
certain temperature, e.g., 400 ◦
C.
For a non-ideal gas, the enthapy is:
H = Hig
+ HR
HR
is the residual enthalpy (a lot like the excess enthaply HE
that applies to
liquids).
An equation of state can be used to calculate HR
:
Z =
PV
RT
= f(T, P, V)
Thermodynamics provides the equation needed to relate Z to HR
:
HR
= −RT2
P
0
dP
1
P
∂Z
∂T P
How do we evaluate such an expression?
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 2 / 21
Calculating the Enthalpy of a Non-Ideal Gas
We start with an expression for Z. The Peng-Robinson Equation of State does
an excellent job with many compounds, including ethanol:
Z =
V
V − b
−
a(T)V
RT(V + b)(V + σb)
= 1 + β − qβ
Z − β
(Z + β)(Z + σβ)
Z ≡
PV
RT
β =
bP
RT
q ≡
a
bRT
a =
ΨαR2
T2
c
Pc
b =
ΩRTc
Pc
α = 1 + (0.37464 + 1.54226ω − 0.26992ω
2
) 1 − (T/Tc )
1/2 2
Ω = 0.0778 Ψ = 0.45724
σ = 1 +
√
2 1 −
√
2
For ethanol:
ω = 0.2 Pc = 37.96 Tc = 425.1
0 200 400 600
.75
1
1.25
P, atm
Z
Compressibility of ethanol at T = 400 ◦
C
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 3 / 21
Calculating the Enthalpy of a Non-Ideal Gas
Write the equation of state out in standard cubic form:
Now we can generate Z vs. P data by:
1 The solution as a Matlab function:
function Z = Z_ethanol(T,P)
% Given a T and list of P’s, find ethanol’s compressibility factor
R = 82.06; omega = 0.2; Pc = 37.96*1.01325; Tc = 425.1;
e = 1-sqrt(2); o = 1+sqrt(2); Omega = 0.0778; Psi = 0.45724;
5 alpha=@(T) (1 + polyval([-0.26992,1.54226,0.37464],omega).*(1-sqrt(T./Tc))).^2;
q = @(T) Psi .* alpha(T) ./ ( Omega .* (T ./ Tc));
beta = @(T,P) Omega .* (P ./ Pc) ./ (T ./ Tc);
eos = @(T,P) [ -1
1+beta(T,P) .* (1-o-e)
10 beta(T,P).^2 .* (o+e-o.*e) + beta(T,P).*(o+e-q(T))
beta(T,P).^2 .* (q(T) + o.*e .* (1+beta(T,P)) ) ];
for ii = 1:length(P)
Z(ii) = max(eos(T,P(ii))); % The vapor phase volume is the largest root
end
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 4 / 21
Calculating the Enthalpy of a Non-Ideal Gas
Write the equation of state out in standard cubic form:
Now we can generate Z vs. P data by:
1 The solution as a Matlab function:
function Z = Z_ethanol(T,P)
% Given a T and list of P’s, find ethanol’s compressibility factor
R = 82.06; omega = 0.2; Pc = 37.96*1.01325; Tc = 425.1;
e = 1-sqrt(2); o = 1+sqrt(2); Omega = 0.0778; Psi = 0.45724;
5 alpha=@(T) (1 + polyval([-0.26992,1.54226,0.37464],omega).*(1-sqrt(T./Tc))).^2;
q = @(T) Psi .* alpha(T) ./ ( Omega .* (T ./ Tc));
beta = @(T,P) Omega .* (P ./ Pc) ./ (T ./ Tc);
eos = @(T,P) [ -1
1+beta(T,P) .* (1-o-e)
10 beta(T,P).^2 .* (o+e-o.*e) + beta(T,P).*(o+e-q(T))
beta(T,P).^2 .* (q(T) + o.*e .* (1+beta(T,P)) ) ];
for ii = 1:length(P)
Z(ii) = max(eos(T,P(ii))); % The vapor phase volume is the largest root
end
2 Specify some P values between 0 and 600 atm.
>> P = linspace(1e-15,600,15);
>> Z = Z_ethanol(400+273.15,P);
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 4 / 21
Calculating the Enthalpy of a Non-Ideal Gas
Now we need to convert our Z vs. P data into ∂Z
∂T
vs. P data, using
derivatives through finite differences.
1 For each P, pick a small value of ∆T
dT = .1; % .1 K is very small compared to our temperature of 673.15 K
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 5 / 21
Calculating the Enthalpy of a Non-Ideal Gas
Now we need to convert our Z vs. P data into ∂Z
∂T
vs. P data, using
derivatives through finite differences.
1 For each P, pick a small value of ∆T
dT = .1; % .1 K is very small compared to our temperature of 673.15 K
The smaller the value, the more accurate the derivative,
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 5 / 21
Calculating the Enthalpy of a Non-Ideal Gas
Now we need to convert our Z vs. P data into ∂Z
∂T
vs. P data, using
derivatives through finite differences.
1 For each P, pick a small value of ∆T
dT = .1; % .1 K is very small compared to our temperature of 673.15 K
The smaller the value, the more accurate the derivative,
But too small and numerical error will be a problem
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 5 / 21
Calculating the Enthalpy of a Non-Ideal Gas
Now we need to convert our Z vs. P data into ∂Z
∂T
vs. P data, using
derivatives through finite differences.
1 For each P, pick a small value of ∆T
dT = .1; % .1 K is very small compared to our temperature of 673.15 K
The smaller the value, the more accurate the derivative,
But too small and numerical error will be a problem
2 We can use central finite differences:
∂Z
∂T P
≈
1
2∆T
Z(P,T+∆T) − Z(P,T−∆T)
function dZ = dZdT(P,T,c)
dT = .1; % This is the h value
T1 = T + dT;
T2 = T - dT;
5 Z1 = P./(8.314*T1) .* Z_ethanol(P,T1); % Solve the PR-EOS
Z2 = P./(8.314*T2) .* Z_ethanol(P,T2); % Solve the PR-EOS
dZ = (Z1-Z2) ./ (2 * dT);
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 5 / 21
Calculating the Enthalpy of a Non-Ideal Gas
This is the partial derivative we need:
0 300 600
0
1
2
P, atm
∂Z
∂T
P
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 6 / 21
Calculating the Enthalpy of a Non-Ideal Gas
The residual enthalpy of ethanol at P = 600 atm and T = 673.15 K is:
HR
= −RT2
Itrue
0 300 600
0
.8
1.6
I
true
=
600 atm
0
1
P
∂Z
∂T P
dP
P, atm
1
P
∂Z
∂TP
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 7 / 21
Outline
1 Numerical Integration
A Chemical Engineering Example
The Newton-Cotes Formulae
Composite Newton-Cotes Formulae — Trapezoidal/Simpson’s Rule
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 8 / 21
The Newton-Cotes Formulae
The basic idea behind numerical integration is to start with a function that
we cannot integrate analytically:
The function might not have an analytic solution (like finding HR)
The function might be represented only by measured data
The Newton-Cotes Formulae are based on the integrals of interpolating
polynomials forced to pass through the function to integrate at a few given
data points.
The Newton-Cotes Formulae are closed formulae, meaning that if we are
interested in
b
a
f(x)dx
we must know what f(a) and f(b) are (the values at the endpoints).
Additionally, given np points at which f(x) is known, the Newton-Cotes
Formulae require that these points are equally spaced.
Nomenclature:
Lower Limit a = x1
Upper Limit b = xn+1
# of intervals n
Interval width h = b−a
n
# of evenly spaced data points np = n + 1
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 9 / 21
The Newton-Cotes Formulae
The 1st-Order Formula
If we have only np = 2 data points on the function (n = 1 interval), then we
imagine that the line connecting them has the same integral as the
underlying function:
0 300 600
0
.8
1.6
P
1 (x)
a
b
P, atm
1
P
∂Z
∂T
I1 =
b
a
P1(x) =
b − a
2
(f(a) + f(b))
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 10 / 21
The Newton-Cotes Formulae
The 2nd
Order Formula
If we have np = 3 data points on the function (n = 2 intervals), then we
imagine that the parabola connecting them has the same integral as the
underlying function:
0 300 600
0
.8
1.6
P
2 (x)
h = b−a
2
h
(x1 = a, f1)
(x3 = b, f3)
(x2 = a + h, f2)
P, atm
1
P
∂Z
∂T
I2 =
b
a
P2(x) =
h
3
f(x1) + 4f(x2) + f(x3)
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 11 / 21
The Newton-Cotes Formulae
The 3rd
Order Formula
If we have np = 4 data points on the function (n = 3 intervals), then we
imagine that the cubic polynomial connecting them has the same integral
as the underlying function:
0 300 600
0
.8
1.6
P
3 (x)
h
h
h
(x1, f1)
(x2, f2)
(x3, f3)
(x4, f4)
P, atm
1
P
∂Z
∂T
I3 =
b
a
P3(x) =
3h
8
f1 + 3f2 + 3f3 + f4
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 12 / 21
The Newton-Cotes Formula
Summary
All of these quadrature formulae are based on evenly spaced points
np n h I =
b
a
f(x)dx Error
2 1 (a − b) h
2
f1 + f2 O(h3
)
3 2 (a−b)
2
h
3
f1 + 4f2 + f3 O(h5
)
4 3 (a−b)
3
3h
8
f1 + 3f2 + 3f3 + f4 O(h5
)
5 4 (a−b)
4
h
15
7f1 + 32f2 + 12f3 + 32f4 + 7f5 O(h7
)
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 13 / 21
Outline
1 Numerical Integration
A Chemical Engineering Example
The Newton-Cotes Formulae
Composite Newton-Cotes Formulae — Trapezoidal/Simpson’s Rule
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 14 / 21
The Composite Rules
The basic Newton-Cotes rules are only useful for the first few orders.
In practice, nothing higher than the 4-point rule (integral of the interpolating
cubic polynomial) is commonly used.
Just like we used splines to do a better job of interpolating a large number of
data points, we typically break functions we wish to integrate into
subintervals, and then use a lower-order Newton-Cotes Rule on each
subinterval.
The resulting formulae are called the composite Newton-Cotes Formulae
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 15 / 21
The Newton-Cotes Formulae
The Composite Trapezoidal Rule
If we have 8 data points on the function, then we divide it into 7 intervals,
and sum the integrals of the 7 trapezoids :
0 300 600
0
.8
1.6
P, bar
105
×
1
P
∂Z
∂T
,1
barK
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 16 / 21
The Newton-Cotes Formulae
The Composite Trapezoidal Rule
If we have np = 8 data points on the function, then we divide it into n = 7
intervals, and sum the integrals of the 7 trapezoids :
I1,c =
h
2









f1 + f2
+ f2 + f3
+ f3 + f4
+ f4 + f5
+ f5 + f6
+ f6 + f7
+ f7 + f8









=
h
2
f1 + 2f2 + 2f3 + 2f4 + 2f5 + 2f6 + 2f7 + f8
=
h
2
(f1 + fn+1) + h
n
i=2
fi
The accuracy of the Composite Trapezoidal Rule is O h2
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 17 / 21
The Newton-Cotes Formulae
The 1/3 Simpsons Rule
If we have 7 data points on the function, then we divide it into 6 intervals,
and sum the integrals of the 3 parabolas that span these intervals :
0 300 600
0
.8
1.6
P, bar
105
×
1
P
∂Z
∂T
,1
barK
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 18 / 21
The Newton-Cotes Formulae
The 1/3 Simpsons Rule
If we have 7 data points on the function, then we divide it into 6 intervals,
and sum the integrals of the 3 parabolas that span these intervals :
0 300 600
0
.8
1.6
Parabola 1
P, bar
105
×
1
P
∂Z
∂T
,1
barK
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 18 / 21
The Newton-Cotes Formulae
The 1/3 Simpsons Rule
If we have 7 data points on the function, then we divide it into 6 intervals,
and sum the integrals of the 3 parabolas that span these intervals :
0 300 600
0
.8
1.6
Parabola 1
Parabola 2
P, bar
105
×
1
P
∂Z
∂T
,1
barK
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 18 / 21
The Newton-Cotes Formulae
The 1/3 Simpsons Rule
If we have 7 data points on the function, then we divide it into 6 intervals,
and sum the integrals of the 3 parabolas that span these intervals :
0 300 600
0
.8
1.6
Parabola 1
Parabola 2
Parabola 3
P, bar
105
×
1
P
∂Z
∂T
,1
barK
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 18 / 21
The Newton-Cotes Formulae
The 1/3 Simpsons Rule
If we have np = 7 data points on the function, then we divide it into n = 6
intervals, and sum the integrals of the 3 parabolas that span these intervals :
I1,c =
h
3


f1 + 4f2 + f3
+ f3 + 4f4 + f5
+ f5 + 4f6 + f7


=
h
3
f1 + 4f2 + 2f3 + 4f4 + 2f5 + 4f6 + f7
=
h
3

(f1 + fn+1) + 4
n
i=2,even
fi + 2
n−1
i=3,odd
fi


This formula is used when we have an odd number of data points.
The accuracy of the Composite Simpson’s Rule is O h4
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 19 / 21
The Newton-Cotes Formulae
The 1/3 + 3/8 Simpsons Rule
If we have np = 8 data points on the function, then we divide have n = 7 intervals.
0 300 600
0
.8
1.6
P, bar
105
×
1
P
∂Z
∂T
,1
barK
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 20 / 21
The Newton-Cotes Formulae
The 1/3 + 3/8 Simpsons Rule
If we have np = 8 data points on the function, then we divide have n = 7 intervals.
We need 2 intervals for each 1/3 Simpsons Rule.
0 300 600
0
.8
1.6
Parabola 1
Parabola 2
P, bar
105
×
1
P
∂Z
∂T
,1
barK
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 20 / 21
The Newton-Cotes Formulae
The 1/3 + 3/8 Simpsons Rule
If we have np = 8 data points on the function, then we divide have n = 7 intervals.
We need 2 intervals for each 1/3 Simpsons Rule.
For the final 3 intervals use the 3/8 (4-point) Simpson’s Rule
0 300 600
0
.8
1.6
Parabola 1
Parabola 2
Cubic Polynomial
P, bar
105
×
1
P
∂Z
∂T
,1
barK
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 20 / 21
The Newton-Cotes Formulae
The 1/3 + 3/8 Simpsons Rule
If we have np = 8 data points on the function, then we divide it into n = 7
intervals, and sum the integrals of the 2 parabolas and single cubic that
span these intervals :
I1,c =
h
3
f1 + 4f2 + f3
+ f3 + 4f4 + f5
+
3h
8
f5 + 4f6 + 4f7 + f8
=
h
3
f1 + 4f2 + 2f3 + 4f4 + f5 +
3h
8
(f5 + 3f6 + 3f7 + f8)
=
h
3

(f1 + fn−2) + 4
n−3
i=2,even
fi + 2
n−4
i=3,odd
fi

 +
3h
8
(fn−2 + 3fn−1 + 3fn + fn+1)
This formula is used when we have an even number of data points.
The accuracy of the Composite Simpson’s Rule is O h4
Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 21 / 21

More Related Content

What's hot

Some properties of m sequences over finite field fp
Some properties of m sequences over finite field fpSome properties of m sequences over finite field fp
Some properties of m sequences over finite field fpIAEME Publication
 
lecture 1
lecture 1lecture 1
lecture 1sajinsc
 
Variational Bayes: A Gentle Introduction
Variational Bayes: A Gentle IntroductionVariational Bayes: A Gentle Introduction
Variational Bayes: A Gentle IntroductionFlavio Morelli
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Deepak John
 
1 chapter1 introduction
1 chapter1 introduction1 chapter1 introduction
1 chapter1 introductionSSE_AndyLi
 
Otter 2016-11-28-01-ss
Otter 2016-11-28-01-ssOtter 2016-11-28-01-ss
Otter 2016-11-28-01-ssRuo Ando
 
2. polynomial interpolation
2. polynomial interpolation2. polynomial interpolation
2. polynomial interpolationEasyStudy3
 
Expressiveness and Model of the Polymorphic λ Calculus
Expressiveness and Model of the Polymorphic λ CalculusExpressiveness and Model of the Polymorphic λ Calculus
Expressiveness and Model of the Polymorphic λ Calculusevastsdsh
 
Elliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve CryptographyElliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve CryptographyMd. Al-Amin Khandaker Nipu
 
lecture 4
lecture 4lecture 4
lecture 4sajinsc
 

What's hot (20)

Chap09alg
Chap09algChap09alg
Chap09alg
 
Some properties of m sequences over finite field fp
Some properties of m sequences over finite field fpSome properties of m sequences over finite field fp
Some properties of m sequences over finite field fp
 
Function and graphs
Function and graphsFunction and graphs
Function and graphs
 
lecture 1
lecture 1lecture 1
lecture 1
 
Computer Science Assignment Help
Computer Science Assignment Help Computer Science Assignment Help
Computer Science Assignment Help
 
Variational Bayes: A Gentle Introduction
Variational Bayes: A Gentle IntroductionVariational Bayes: A Gentle Introduction
Variational Bayes: A Gentle Introduction
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Analysis and design of algorithms part 4
Analysis and design of algorithms part 4
 
Function
Function Function
Function
 
1 chapter1 introduction
1 chapter1 introduction1 chapter1 introduction
1 chapter1 introduction
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Otter 2016-11-28-01-ss
Otter 2016-11-28-01-ssOtter 2016-11-28-01-ss
Otter 2016-11-28-01-ss
 
2. polynomial interpolation
2. polynomial interpolation2. polynomial interpolation
2. polynomial interpolation
 
Numerical Methods 1
Numerical Methods 1Numerical Methods 1
Numerical Methods 1
 
Expressiveness and Model of the Polymorphic λ Calculus
Expressiveness and Model of the Polymorphic λ CalculusExpressiveness and Model of the Polymorphic λ Calculus
Expressiveness and Model of the Polymorphic λ Calculus
 
Elliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve CryptographyElliptic Curves and Elliptic Curve Cryptography
Elliptic Curves and Elliptic Curve Cryptography
 
Lec4
Lec4Lec4
Lec4
 
lecture 4
lecture 4lecture 4
lecture 4
 
Chemistry Assignment Help
Chemistry Assignment Help Chemistry Assignment Help
Chemistry Assignment Help
 
Analysis of Algorithm
Analysis of AlgorithmAnalysis of Algorithm
Analysis of Algorithm
 

Similar to Lecture 11 f17

Numerical Evaluation of Complex Integrals of Analytic Functions
Numerical Evaluation of Complex Integrals of Analytic FunctionsNumerical Evaluation of Complex Integrals of Analytic Functions
Numerical Evaluation of Complex Integrals of Analytic Functionsinventionjournals
 
Python intro ch_e_comp
Python intro ch_e_compPython intro ch_e_comp
Python intro ch_e_compPaulo Castro
 
Vapor liquid equilibrium using hysys
Vapor liquid equilibrium using hysysVapor liquid equilibrium using hysys
Vapor liquid equilibrium using hysysUET
 
Functional Regression Analysis
Functional Regression AnalysisFunctional Regression Analysis
Functional Regression AnalysisNeuroMat
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfAmayJaiswal4
 
Pythagorean Triplets
Pythagorean TripletsPythagorean Triplets
Pythagorean TripletsSualeh Fatehi
 
Trilinear embedding for divergence-form operators
Trilinear embedding for divergence-form operatorsTrilinear embedding for divergence-form operators
Trilinear embedding for divergence-form operatorsVjekoslavKovac1
 
lecture 15
lecture 15lecture 15
lecture 15sajinsc
 
String kmp
String kmpString kmp
String kmpthinkphp
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqPradeep Bisht
 
Transient Heat Conduction in a Circular Finned Tube Heat Exchanger.pptx
Transient Heat Conduction in a Circular Finned Tube Heat Exchanger.pptxTransient Heat Conduction in a Circular Finned Tube Heat Exchanger.pptx
Transient Heat Conduction in a Circular Finned Tube Heat Exchanger.pptxImanNezam1
 
The best sextic approximation of hyperbola with order twelve
The best sextic approximation of hyperbola with order twelveThe best sextic approximation of hyperbola with order twelve
The best sextic approximation of hyperbola with order twelveIJECEIAES
 

Similar to Lecture 11 f17 (20)

Numerical Evaluation of Complex Integrals of Analytic Functions
Numerical Evaluation of Complex Integrals of Analytic FunctionsNumerical Evaluation of Complex Integrals of Analytic Functions
Numerical Evaluation of Complex Integrals of Analytic Functions
 
Python intro ch_e_comp
Python intro ch_e_compPython intro ch_e_comp
Python intro ch_e_comp
 
analysis.ppt
analysis.pptanalysis.ppt
analysis.ppt
 
Vapor liquid equilibrium using hysys
Vapor liquid equilibrium using hysysVapor liquid equilibrium using hysys
Vapor liquid equilibrium using hysys
 
Statistical Physics Assignment Help
Statistical Physics Assignment Help Statistical Physics Assignment Help
Statistical Physics Assignment Help
 
Functional Regression Analysis
Functional Regression AnalysisFunctional Regression Analysis
Functional Regression Analysis
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdf
 
Pythagorean Triplets
Pythagorean TripletsPythagorean Triplets
Pythagorean Triplets
 
Trilinear embedding for divergence-form operators
Trilinear embedding for divergence-form operatorsTrilinear embedding for divergence-form operators
Trilinear embedding for divergence-form operators
 
lecture 15
lecture 15lecture 15
lecture 15
 
String kmp
String kmpString kmp
String kmp
 
Soave1972
Soave1972Soave1972
Soave1972
 
Redlich,1975
Redlich,1975Redlich,1975
Redlich,1975
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
Topic 8 kft 131
Topic 8 kft 131Topic 8 kft 131
Topic 8 kft 131
 
CDT 22 slides.pdf
CDT 22 slides.pdfCDT 22 slides.pdf
CDT 22 slides.pdf
 
Poster Icqc
Poster IcqcPoster Icqc
Poster Icqc
 
Transient Heat Conduction in a Circular Finned Tube Heat Exchanger.pptx
Transient Heat Conduction in a Circular Finned Tube Heat Exchanger.pptxTransient Heat Conduction in a Circular Finned Tube Heat Exchanger.pptx
Transient Heat Conduction in a Circular Finned Tube Heat Exchanger.pptx
 
Navid_Alavi
Navid_AlaviNavid_Alavi
Navid_Alavi
 
The best sextic approximation of hyperbola with order twelve
The best sextic approximation of hyperbola with order twelveThe best sextic approximation of hyperbola with order twelve
The best sextic approximation of hyperbola with order twelve
 

Recently uploaded

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 

Lecture 11 f17

  • 1. Lecture 10—Numerical Integration Outline 1 Numerical Integration A Chemical Engineering Example The Newton-Cotes Formulae Composite Newton-Cotes Formulae — Trapezoidal/Simpson’s Rule Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 1 / 21
  • 2. Calculating the Enthalpy of a Non-Ideal Gas Suppose that we are designing a process unit that handles vapor-phase ethanol at high pressure (e.g., 600 atm), where the ideal gas law fails. We need to find out how much heat our process unit requires to maintain a certain temperature, e.g., 400 ◦ C. For a non-ideal gas, the enthapy is: H = Hig + HR HR is the residual enthalpy (a lot like the excess enthaply HE that applies to liquids). An equation of state can be used to calculate HR : Z = PV RT = f(T, P, V) Thermodynamics provides the equation needed to relate Z to HR : HR = −RT2 P 0 dP 1 P ∂Z ∂T P How do we evaluate such an expression? Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 2 / 21
  • 3. Calculating the Enthalpy of a Non-Ideal Gas We start with an expression for Z. The Peng-Robinson Equation of State does an excellent job with many compounds, including ethanol: Z = V V − b − a(T)V RT(V + b)(V + σb) = 1 + β − qβ Z − β (Z + β)(Z + σβ) Z ≡ PV RT β = bP RT q ≡ a bRT a = ΨαR2 T2 c Pc b = ΩRTc Pc α = 1 + (0.37464 + 1.54226ω − 0.26992ω 2 ) 1 − (T/Tc ) 1/2 2 Ω = 0.0778 Ψ = 0.45724 σ = 1 + √ 2 1 − √ 2 For ethanol: ω = 0.2 Pc = 37.96 Tc = 425.1 0 200 400 600 .75 1 1.25 P, atm Z Compressibility of ethanol at T = 400 ◦ C Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 3 / 21
  • 4. Calculating the Enthalpy of a Non-Ideal Gas Write the equation of state out in standard cubic form: Now we can generate Z vs. P data by: 1 The solution as a Matlab function: function Z = Z_ethanol(T,P) % Given a T and list of P’s, find ethanol’s compressibility factor R = 82.06; omega = 0.2; Pc = 37.96*1.01325; Tc = 425.1; e = 1-sqrt(2); o = 1+sqrt(2); Omega = 0.0778; Psi = 0.45724; 5 alpha=@(T) (1 + polyval([-0.26992,1.54226,0.37464],omega).*(1-sqrt(T./Tc))).^2; q = @(T) Psi .* alpha(T) ./ ( Omega .* (T ./ Tc)); beta = @(T,P) Omega .* (P ./ Pc) ./ (T ./ Tc); eos = @(T,P) [ -1 1+beta(T,P) .* (1-o-e) 10 beta(T,P).^2 .* (o+e-o.*e) + beta(T,P).*(o+e-q(T)) beta(T,P).^2 .* (q(T) + o.*e .* (1+beta(T,P)) ) ]; for ii = 1:length(P) Z(ii) = max(eos(T,P(ii))); % The vapor phase volume is the largest root end Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 4 / 21
  • 5. Calculating the Enthalpy of a Non-Ideal Gas Write the equation of state out in standard cubic form: Now we can generate Z vs. P data by: 1 The solution as a Matlab function: function Z = Z_ethanol(T,P) % Given a T and list of P’s, find ethanol’s compressibility factor R = 82.06; omega = 0.2; Pc = 37.96*1.01325; Tc = 425.1; e = 1-sqrt(2); o = 1+sqrt(2); Omega = 0.0778; Psi = 0.45724; 5 alpha=@(T) (1 + polyval([-0.26992,1.54226,0.37464],omega).*(1-sqrt(T./Tc))).^2; q = @(T) Psi .* alpha(T) ./ ( Omega .* (T ./ Tc)); beta = @(T,P) Omega .* (P ./ Pc) ./ (T ./ Tc); eos = @(T,P) [ -1 1+beta(T,P) .* (1-o-e) 10 beta(T,P).^2 .* (o+e-o.*e) + beta(T,P).*(o+e-q(T)) beta(T,P).^2 .* (q(T) + o.*e .* (1+beta(T,P)) ) ]; for ii = 1:length(P) Z(ii) = max(eos(T,P(ii))); % The vapor phase volume is the largest root end 2 Specify some P values between 0 and 600 atm. >> P = linspace(1e-15,600,15); >> Z = Z_ethanol(400+273.15,P); Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 4 / 21
  • 6. Calculating the Enthalpy of a Non-Ideal Gas Now we need to convert our Z vs. P data into ∂Z ∂T vs. P data, using derivatives through finite differences. 1 For each P, pick a small value of ∆T dT = .1; % .1 K is very small compared to our temperature of 673.15 K Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 5 / 21
  • 7. Calculating the Enthalpy of a Non-Ideal Gas Now we need to convert our Z vs. P data into ∂Z ∂T vs. P data, using derivatives through finite differences. 1 For each P, pick a small value of ∆T dT = .1; % .1 K is very small compared to our temperature of 673.15 K The smaller the value, the more accurate the derivative, Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 5 / 21
  • 8. Calculating the Enthalpy of a Non-Ideal Gas Now we need to convert our Z vs. P data into ∂Z ∂T vs. P data, using derivatives through finite differences. 1 For each P, pick a small value of ∆T dT = .1; % .1 K is very small compared to our temperature of 673.15 K The smaller the value, the more accurate the derivative, But too small and numerical error will be a problem Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 5 / 21
  • 9. Calculating the Enthalpy of a Non-Ideal Gas Now we need to convert our Z vs. P data into ∂Z ∂T vs. P data, using derivatives through finite differences. 1 For each P, pick a small value of ∆T dT = .1; % .1 K is very small compared to our temperature of 673.15 K The smaller the value, the more accurate the derivative, But too small and numerical error will be a problem 2 We can use central finite differences: ∂Z ∂T P ≈ 1 2∆T Z(P,T+∆T) − Z(P,T−∆T) function dZ = dZdT(P,T,c) dT = .1; % This is the h value T1 = T + dT; T2 = T - dT; 5 Z1 = P./(8.314*T1) .* Z_ethanol(P,T1); % Solve the PR-EOS Z2 = P./(8.314*T2) .* Z_ethanol(P,T2); % Solve the PR-EOS dZ = (Z1-Z2) ./ (2 * dT); Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 5 / 21
  • 10. Calculating the Enthalpy of a Non-Ideal Gas This is the partial derivative we need: 0 300 600 0 1 2 P, atm ∂Z ∂T P Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 6 / 21
  • 11. Calculating the Enthalpy of a Non-Ideal Gas The residual enthalpy of ethanol at P = 600 atm and T = 673.15 K is: HR = −RT2 Itrue 0 300 600 0 .8 1.6 I true = 600 atm 0 1 P ∂Z ∂T P dP P, atm 1 P ∂Z ∂TP Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 7 / 21
  • 12. Outline 1 Numerical Integration A Chemical Engineering Example The Newton-Cotes Formulae Composite Newton-Cotes Formulae — Trapezoidal/Simpson’s Rule Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 8 / 21
  • 13. The Newton-Cotes Formulae The basic idea behind numerical integration is to start with a function that we cannot integrate analytically: The function might not have an analytic solution (like finding HR) The function might be represented only by measured data The Newton-Cotes Formulae are based on the integrals of interpolating polynomials forced to pass through the function to integrate at a few given data points. The Newton-Cotes Formulae are closed formulae, meaning that if we are interested in b a f(x)dx we must know what f(a) and f(b) are (the values at the endpoints). Additionally, given np points at which f(x) is known, the Newton-Cotes Formulae require that these points are equally spaced. Nomenclature: Lower Limit a = x1 Upper Limit b = xn+1 # of intervals n Interval width h = b−a n # of evenly spaced data points np = n + 1 Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 9 / 21
  • 14. The Newton-Cotes Formulae The 1st-Order Formula If we have only np = 2 data points on the function (n = 1 interval), then we imagine that the line connecting them has the same integral as the underlying function: 0 300 600 0 .8 1.6 P 1 (x) a b P, atm 1 P ∂Z ∂T I1 = b a P1(x) = b − a 2 (f(a) + f(b)) Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 10 / 21
  • 15. The Newton-Cotes Formulae The 2nd Order Formula If we have np = 3 data points on the function (n = 2 intervals), then we imagine that the parabola connecting them has the same integral as the underlying function: 0 300 600 0 .8 1.6 P 2 (x) h = b−a 2 h (x1 = a, f1) (x3 = b, f3) (x2 = a + h, f2) P, atm 1 P ∂Z ∂T I2 = b a P2(x) = h 3 f(x1) + 4f(x2) + f(x3) Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 11 / 21
  • 16. The Newton-Cotes Formulae The 3rd Order Formula If we have np = 4 data points on the function (n = 3 intervals), then we imagine that the cubic polynomial connecting them has the same integral as the underlying function: 0 300 600 0 .8 1.6 P 3 (x) h h h (x1, f1) (x2, f2) (x3, f3) (x4, f4) P, atm 1 P ∂Z ∂T I3 = b a P3(x) = 3h 8 f1 + 3f2 + 3f3 + f4 Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 12 / 21
  • 17. The Newton-Cotes Formula Summary All of these quadrature formulae are based on evenly spaced points np n h I = b a f(x)dx Error 2 1 (a − b) h 2 f1 + f2 O(h3 ) 3 2 (a−b) 2 h 3 f1 + 4f2 + f3 O(h5 ) 4 3 (a−b) 3 3h 8 f1 + 3f2 + 3f3 + f4 O(h5 ) 5 4 (a−b) 4 h 15 7f1 + 32f2 + 12f3 + 32f4 + 7f5 O(h7 ) Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 13 / 21
  • 18. Outline 1 Numerical Integration A Chemical Engineering Example The Newton-Cotes Formulae Composite Newton-Cotes Formulae — Trapezoidal/Simpson’s Rule Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 14 / 21
  • 19. The Composite Rules The basic Newton-Cotes rules are only useful for the first few orders. In practice, nothing higher than the 4-point rule (integral of the interpolating cubic polynomial) is commonly used. Just like we used splines to do a better job of interpolating a large number of data points, we typically break functions we wish to integrate into subintervals, and then use a lower-order Newton-Cotes Rule on each subinterval. The resulting formulae are called the composite Newton-Cotes Formulae Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 15 / 21
  • 20. The Newton-Cotes Formulae The Composite Trapezoidal Rule If we have 8 data points on the function, then we divide it into 7 intervals, and sum the integrals of the 7 trapezoids : 0 300 600 0 .8 1.6 P, bar 105 × 1 P ∂Z ∂T ,1 barK Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 16 / 21
  • 21. The Newton-Cotes Formulae The Composite Trapezoidal Rule If we have np = 8 data points on the function, then we divide it into n = 7 intervals, and sum the integrals of the 7 trapezoids : I1,c = h 2          f1 + f2 + f2 + f3 + f3 + f4 + f4 + f5 + f5 + f6 + f6 + f7 + f7 + f8          = h 2 f1 + 2f2 + 2f3 + 2f4 + 2f5 + 2f6 + 2f7 + f8 = h 2 (f1 + fn+1) + h n i=2 fi The accuracy of the Composite Trapezoidal Rule is O h2 Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 17 / 21
  • 22. The Newton-Cotes Formulae The 1/3 Simpsons Rule If we have 7 data points on the function, then we divide it into 6 intervals, and sum the integrals of the 3 parabolas that span these intervals : 0 300 600 0 .8 1.6 P, bar 105 × 1 P ∂Z ∂T ,1 barK Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 18 / 21
  • 23. The Newton-Cotes Formulae The 1/3 Simpsons Rule If we have 7 data points on the function, then we divide it into 6 intervals, and sum the integrals of the 3 parabolas that span these intervals : 0 300 600 0 .8 1.6 Parabola 1 P, bar 105 × 1 P ∂Z ∂T ,1 barK Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 18 / 21
  • 24. The Newton-Cotes Formulae The 1/3 Simpsons Rule If we have 7 data points on the function, then we divide it into 6 intervals, and sum the integrals of the 3 parabolas that span these intervals : 0 300 600 0 .8 1.6 Parabola 1 Parabola 2 P, bar 105 × 1 P ∂Z ∂T ,1 barK Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 18 / 21
  • 25. The Newton-Cotes Formulae The 1/3 Simpsons Rule If we have 7 data points on the function, then we divide it into 6 intervals, and sum the integrals of the 3 parabolas that span these intervals : 0 300 600 0 .8 1.6 Parabola 1 Parabola 2 Parabola 3 P, bar 105 × 1 P ∂Z ∂T ,1 barK Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 18 / 21
  • 26. The Newton-Cotes Formulae The 1/3 Simpsons Rule If we have np = 7 data points on the function, then we divide it into n = 6 intervals, and sum the integrals of the 3 parabolas that span these intervals : I1,c = h 3   f1 + 4f2 + f3 + f3 + 4f4 + f5 + f5 + 4f6 + f7   = h 3 f1 + 4f2 + 2f3 + 4f4 + 2f5 + 4f6 + f7 = h 3  (f1 + fn+1) + 4 n i=2,even fi + 2 n−1 i=3,odd fi   This formula is used when we have an odd number of data points. The accuracy of the Composite Simpson’s Rule is O h4 Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 19 / 21
  • 27. The Newton-Cotes Formulae The 1/3 + 3/8 Simpsons Rule If we have np = 8 data points on the function, then we divide have n = 7 intervals. 0 300 600 0 .8 1.6 P, bar 105 × 1 P ∂Z ∂T ,1 barK Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 20 / 21
  • 28. The Newton-Cotes Formulae The 1/3 + 3/8 Simpsons Rule If we have np = 8 data points on the function, then we divide have n = 7 intervals. We need 2 intervals for each 1/3 Simpsons Rule. 0 300 600 0 .8 1.6 Parabola 1 Parabola 2 P, bar 105 × 1 P ∂Z ∂T ,1 barK Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 20 / 21
  • 29. The Newton-Cotes Formulae The 1/3 + 3/8 Simpsons Rule If we have np = 8 data points on the function, then we divide have n = 7 intervals. We need 2 intervals for each 1/3 Simpsons Rule. For the final 3 intervals use the 3/8 (4-point) Simpson’s Rule 0 300 600 0 .8 1.6 Parabola 1 Parabola 2 Cubic Polynomial P, bar 105 × 1 P ∂Z ∂T ,1 barK Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 20 / 21
  • 30. The Newton-Cotes Formulae The 1/3 + 3/8 Simpsons Rule If we have np = 8 data points on the function, then we divide it into n = 7 intervals, and sum the integrals of the 2 parabolas and single cubic that span these intervals : I1,c = h 3 f1 + 4f2 + f3 + f3 + 4f4 + f5 + 3h 8 f5 + 4f6 + 4f7 + f8 = h 3 f1 + 4f2 + 2f3 + 4f4 + f5 + 3h 8 (f5 + 3f6 + 3f7 + f8) = h 3  (f1 + fn−2) + 4 n−3 i=2,even fi + 2 n−4 i=3,odd fi   + 3h 8 (fn−2 + 3fn−1 + 3fn + fn+1) This formula is used when we have an even number of data points. The accuracy of the Composite Simpson’s Rule is O h4 Che 310 | Chapra 19 | Numerical Integration 10 — Numerical Integration November 9, 2017 21 / 21