Title: ChE306: Heat and Mass Transfer
1Chapter 4
Numerical Differentiation and Integration
2Numerical Differentiation
- Two major reasons for considering numerically
approximations of the differentiation process - Approximation of derivatives in ordinary
differential equations and partial differential
equations. This is done in order to reduce the
differential equation to a form that can be
solved more easily than the original differential
equation. - Forming the derivative of a function f (x) which
is known only as empirical data (xi, yi) i
1, . . . , m. The data generally is known only
approximately, so that yi f (xi), i 1, . . .
, m.
3Numerical Differentiation
- Two methods are used for numerically
approximations of the differentiation process - Taylors theorem as approximation of the
derivative. - Differentiation of interpolation approximation of
the function.
4Differentiation by Backward FD
- First-order derivative in terms of ? with O(h)
- Develop relationship between BFD and ?
- Apply to y at i
- Truncate all but first term
5Differentiation by Backward FD
- Truncation error
- i.e., truncation error of higher-order terms
O(hn) is smaller as the step size h decreases
6Differentiation by Backward FD
- Second-order derivative in terms of ? with O(h)
- Apply to y at i, truncating all but first term
7Differentiation by Backward FD
- First-order derivative in terms of ? with O(h2)
(3.32)
Combine both equations
(3.36)
truncate
8Differentiation by Backward FD
- Second-order derivative in terms of ? with O(h2)
(3.36)
combine
(3.37)
truncate
9Differentiation by Backward FD
10Differentiation by Backward FD
11Differentiation by Forward FD
- First-order derivative in terms of ? with O(h)
- Develop relationship between FFD and ?
- Apply to y at i
- Truncate all but first term
(3.53)
12Differentiation by Forward FD
- Second-order derivative in terms of ? with O(h)
- Apply to y at i, truncating all but first term
(3.57)
13Differentiation by Forward FD
- First-order derivative in terms of ? with O(h2)
(3.53)
combine
(3.57)
truncate
14Differentiation by Forward FD
- Second-order derivative in terms of ? with O(h2)
(3.57)
combine
(3.58)
truncate
15Differentiation by Forward FD
16Differentiation by Forward FD
17Differentiation by Central FD
- First-order derivative in terms of ? with O(h2)
- Apply to y at i, truncating all but first term
(3.78)
18Differentiation by Central FD
- Second-order derivative in terms of ? with O(h2)
- Apply to y at i, truncating all but first term
(3.81)
19Differentiation by Central FD
- First-order derivative in terms of ? with O(h4)
(3.78)
combine
(3.82)
truncate
20Differentiation by Central FD
- Second-order derivative in terms of ? with O(h4)
(3.81)
combine
(3.83)
truncate
21Differentiation by Central FD
22Differentiation by Central FD
23Example 4.1
- Mass transfer flux from an open vessel
- Flux
- unsteady-stateconcentration
- where ? isdetermined by
Step 1 determine ? Step 2 evaluate X Step 3
calculate N (requires evaluation of derivative)
24Example 4.1 Input data
- Mass transfer flux from an open vessel
- time eps3600
- axial positions vector 0.1, 0.2, 0.3
- diffusion coefficient vapor in air 2.2e-5 m2/s
- temperature 25C
- pressure 101325 Pa
- vapor pressure at temp 3161 Pa
- File containing equation for ? 'Ex_4_1_phi'
- File containing concentration profile
'Ex4_1_profile'
25Example 4.2
- Numerical differentiation (1st to 4th-order
derivatives) of a series of numerical data. - deriv.m is applied in this example to calculate
first- to fourth-order derivatives of a matrix of
data. Central finite difference is used to
calculate the derivatives.
26Numerical Integration
27Numerical Integration
28Numerical Integration
29Numerical Integration
- We also want to choose the approximates
of a form we can integrate directly and easily.
Examples are polynomials, trig functions,
piecewise polynomials, and others. If we use
polynomial approximations, then how do we choose
them. At this point, we have two choices - Taylor polynomials approximating f (x)
- 2. Interpolatory polynomials approximating f (x)
30Newton-Cotes Integration
- Accomplished by replacing function yf(x) with a
polynomial, such as the Gregory-Newton forward
interpolation formula. - First three Newton-Cotes Integration formulas
are Trapezoid, Simpson's 1/3, and Simpson's 3/8
rules
31Trapezoid Rule
32Trapezoid Rule
33Trapezoid Rule
34Trapezoid Rule
35Trapezoid Rule
36Trapezoid Rule
37Trapezoid Rule
38Trapezoid Rule
39Trapezoid Rule
40Trapezoid Rule
41Trapezoid Rule
42Trapezoid Rule
- Use one segment with h and fit polynomial through
(xo,yo) and (x1,y1). - Retain first 2 terms of Gregory-Newton
43Simpson's 1/3 Rule
- Fit polynomial through two segments of h (i.e.,
through points (xo,yo), (x1,y1), (x2,y2)). - Retain first 3 terms of Gregory-Newton
44Simpson's 3/8 Rule
- Fit polynomial through three segments of h.
- Retain first 4 terms of Gregory-Newton
45Summary of Newton-Cotes Integration Formula
46Example 4.3
- Numerical integration using Trapezoidal and
Simpsons 1/3 Rules. - trapz.m and Simpson.m are used for nunmerical
integration.
47Gauss Quadrature
- Applied to unequally-spaced data
- Lagrange polynomial used to approximate function.
Orthogonal polynomials applied to locate the
loci of base points.
areaabove areabelow
48Gauss Quadrature
- Transform interval a,b to -1,1
49Gauss Quadrature
- Equivalent to Trapezoid to this point
- Gauss Quadrature eliminates error term by
expanding error in terms of 2nd degree Legendre
polynomial. - Values of z0 and z1 chosen as root of 2nd degree
Legendre polynomial, z0,1 ??1/3½which causes
the R term to vanish.
50Higher-Point Gauss-Legendre
- Replace yf(x) with Lagrange polynomial
Identical to Newton-Cotes, except that Lagrange
polynomial used in place of Gregory-Newton
interpolation
where
51Higher-Point Gauss-Legendre
- substitute
- convert interval
where
polynomials of degree n and n1, respectively
52Higher-Point Gauss-Legendre
- Differs from Newton-Cotes in that error term
eliminated by expanding polynomials in the error
term with Legendre orthogonal polynomials zi
chosen as roots of (n1)th degree Legendre
polynomial. Accuracy increased from n to 2n1.
0
error in Gauss-Legendre(Seinfeld Lapidus)
53Spline Integration
- Sum terms of integrated cubic splines across all
intervals.
54Multiple Integrals
- inner integration first, e.g., Trapezoid Rule
- m ? number of divisions
- k ? integration step in y-direction
- x ? constant
55Multiple Integrals
- Plug result into double integral
- Apply Trapezoid rule to each integral
- n ? number of divisions
- h ? integration step in x-direction
- y ? constant
56Multiple Integrals
57Example 4.4
- Use Gauss-Legendre Quadrature to solve the
temperature profile in a vertical falling film.
T profile
yltlt? near wall
vz profile
58Example 4.4
- Combine
- Boundary conditions for short contact time
where
59Example 4.4
- Analytical Solution
- Must integrate using Gauss-Legendre
where
and