Optimal Design of Energy Systems
Chapter 4 Equation Fitting
Min Soo KIM
Department of Mechanical and Aerospace Engineering
Seoul National University
Equation Development
• Performance characteristics of equipment
• Behavior of processes
• Thermodynamic properties of substances
Key elements
• To facilitate the process of system simulation
• To develop a mathematical statement for optimization
Purposes
Chapter 4. Equation fitting
4.1 Mathematical modeling
11 12 1
1 2
n
m m mn
a a a
a a a
Order of matrix
m n
A
T Transpose of a matrix [A] => interchanging rows & columns ex>
12 453 6 A
1 2 34 5 6
A T
Chapter 4. Equation fitting
4.2 Matrices
• Multiplying two matrices
# of columns of the left matrix = # of rows of the right matrix
𝑎
11⋯ 𝑎
1𝑛⋮ ⋱ ⋮
𝑎
𝑚1⋯ 𝑎
𝑚𝑛×
𝑏
11⋯ 𝑏
1𝑙⋮ ⋱ ⋮
𝑏
𝑛1⋯ 𝑏
𝑛𝑙⇒ 𝑚 × 𝑙 𝑚𝑎𝑡𝑟𝑖𝑥
Chapter 4. Equation fitting
4.2 Matrices
• Simultaneous linear equations
1 2 3
1 2
1 2 3
2 3 6
3 1
4 2 0
x x x
x x
x x x
1
2
3
2 1 3 6
1 3 0 1
4 2 1 0
x x x
Chapter 4. Equation fitting
4.2 Matrices
• Determinant (scalar)
11 12 13
21 22 23
31 32 33
a a a
D a a a
a a a
11 22 33 12 23 31 13 21 3231 22 13 21 12 33 11 23 32
a a a a a a a a a a a a a a a a a a
cofactor of
22 33 23 32
a a a a
a11 [( 1) ]
i
[ ]
i j ij
submatrix formed by striking out A
th row and j th column of A
Cofactor of 𝒂𝒊𝒋
Chapter 4. Equation fitting
4.2 Matrices
= 𝑎11𝐴11 + 𝑎21𝐴21 + 𝑎31𝐴31
Example 4.1 : Matrices
Evaluate
1 0 3 4
2 1
−1 2
−1 2 1 1
0 0 2 5
(Solution)
Find row which has many zeros if possible => second row!
det
Chapter 4. Equation fitting
= 𝑎21𝐴21 + 𝑎22𝐴22 + 𝑎23𝐴23 + 𝑎24𝐴24
= 0 𝐴21 + 1 −1 2+2
1 −1 0
3 1 2
4 1 5
+ 2 −1 2+3
1 2 0
3 −1 2
4 2 5
+ (0)𝐴24
= 0 + 10 + 46 + 0 = 56
11 12 13 1 1
21 22 23 2 2
31 32 33 3 3
[ ][ ] [ ]
a a a x b
A X a a a x b B
a a a x b
11 1 12 2 13 3 1
21 1 22 2 23 3 2
31 1 32 2 33 3 3
a x a x a x b a x a x a x b a x a x a x b
Simultaneous linear equations
Matrix form
Chapter 4. Equation fitting
4.3 Solution of simultaneous equation
[ ] [ ] i
i
A matrix with B matrix substituted in th column
x A
• Crammer’s rule
Chapter 4. Equation fitting
4.3 Solution of simultaneous equation
Example 4.2
Using Cramer’s rule, get 𝑥2
2 1 −1
1 −2 2
−1 0 3
𝑥1 𝑥2 𝑥3
= 3 9 0
(Solution)
𝑥2 =
2 3 −1
1 9 2
−1 0 3
2 1 −1
1 −2 2
−1 0 3
= 30
−15 = −2
Coefficient matrix [A]
Triangular matrix
Back substitution
• Gaussian elimination
Chapter 4. Equation fitting
4.3 Solution of simultaneous equation
2
0 1 2
n
y a a x a x a x
n• degree of the eq = highest exponent of x
• # of data point = degree + 1 → exact expression
> → best fit
Chapter 4. Equation fitting
4.4 Polynomial representations
Points are equally spaced
Derive 4th degree polynomial
n=4
2
0 1 0 2 0
3 4
3 0 4 0
( ) ( )
( ) ( )
n n
y y a x x a x x
R R
n n
a x x a x x
R R
1 0 n n 1
x x x x x
2
0 1 2
n
y a a x a x a xn
(next page) Eq. (4.16)
4
x
Chapter 4. Equation fitting
4.6
Simplifications when the independent variable is uniformly spaced2 3 4
1 0 1 0 1 0 1 0
1 1 2 3 4
1 2 3 4
4(x x ) 4(x x ) 4(x x ) 4(x x )
y a a a a
R R R R
a a a a
0 0
1 1 1 2 3 4
2 2 1 2 3 4
3 3 1 2 3 4
4 4 1 2 3 4
, ,
, 2 4 8 16
, 3 9 27 64
, 4 16 64 256
x x y y
x x y y a a a a
x x y a a a a
x x y a a a a
x x y a a a a
if substitute (x1,y1)
Substitute all the points to Equation (4.16)
Chapter 4. Equation fitting
4.6
Simplifications when the independent variable is uniformly spacedChapter 4. Equation fitting
4.6
Simplifications when the independent variable is uniformly spaced2
0 1 2
y a a xa x
1( 2)( 3) 2( 1)( 3) 3( 1)( 2)
y c x x x x c x x x x c x x x x
1, 1 1( 1 2)( 1 3)
x x y c x x x x
2, 2 2( 2 1)( 2 3)
x x y c x x x x
3, 3 3( 3 1)( 3 2)
x x y c x x x x
1 1
( ) ( )
( ) ( )
n n
j i
i
i j i j i i
x x ommiting x x
y y
x x ommiting x x
Chapter 4. Equation fitting
4.7 Lagrange interpolation
2
1 : 1 1 1 1
S P a b Q c Q
2
2 : 2 2 2 2
S P a b Q c Q
2
3 : 3 3 3 3
S P a b Q c Q
2
0 1 2
2
0 1 2
2
0 1 2
( ) ( ) ( )
a S A A S A S b S B B S B S c S C C S C S
( ) ( ) ( ) 2
P a S b S Q c S Q
Chapter 4. Equation fitting
4.8 Function of two variables
Example 4.3 : Function of two variables
The range is the difference between the inlet and outlet temperatures of the water. In table below, for example, when the wet-bulb temperature is 20℃
and the range is 10℃, inlet and outlet temperature are 35.9℃ and 25.9℃
each. Express the outlet temperature 𝒕 in Table below as a function of the wet-bulb temperature (WBT) and the range R
Chapter 4. Equation fitting
Wet-bulb temperature, ℃
Range, ℃ 20 23 26
10 25.9 27.5 29.4
16 27.0 28.4 30.2
22 28.4 29.6 31.3
(Solution)
For 3 WBTs, get parabola that represents (R,t) i) For WBT = 20℃
(R,t) : (10,25.9), (16,27.0), (22,28.4)
⇒ 𝑡 = 24.733 + 0.075006𝑅 + 0.004146𝑅2 ii) For WBT = 23℃
⇒ 𝑡 = 26.667 + 0.041659𝑅 + 0.0041469𝑅2 iii) For WBT = 26℃
⇒ 𝑡 = 28.733 + 0.024999𝑅 + 0.0041467𝑅2
Example 4.3 : Function of two variables
Chapter 4. Equation fitting
(Solution)
Set 2nd degree equation (constant terms(C) , WBT) ∶ 24.733,20 , 26.667,23 , 28.733,26
⇒ 𝐶 = 15.247 + 0.32637𝑊𝐵𝑇 + 0.007380𝑊𝐵𝑇2
Set 2nd degree equation (coefficient of 𝑅 , WBT) and (coefficient of 𝑅2 , WBT) as well
𝑡 = 15.247 + 0.32637𝑊𝐵𝑇 + 0.007380𝑊𝐵𝑇2 + 0.72375 − 0.050978𝑊𝐵𝑇 + 0.000927𝑊𝐵𝑇2 𝑅 +
(0.004147 + 0𝑊𝐵𝑇 + 0𝑊𝐵𝑇2)𝑅2
Chapter 4. Equation fitting
4.9 Exponential forms
ln ln ln
y bxm
y b m x
Log-log plot (y=bxm)
If y approaches some value b, as orx x
Estimate b
Calculate m with log-log plot (y-b vs. x) Fitting (y vs. xm)
Correct value of b
Curve y=b+axm
y b axm
Chapter 4. Equation fitting
4.9 Exponential forms
Misuse of least square method Example of least square method
Misuses of least square method (a) Questionable correlation
(b) Applying too low degree
Chapter 4. Equation fitting
4.10 Best fit : Method of least squares
The sum of the squares of the deviation is a minimum
y a bx
2( i i) 0
z a bx y
a
2 1
( ) min
m
i i
i
z a bx y
2( i i) i 0
z a bx y x
b
i i
ma b x y
2
i i i i
a x b x x y
Chapter 4. Equation fitting
4.10 Best fit : Method of least squares
• Method of least square for
Example 4.4 : Best fit : Method of least squares
Determine 𝑎0 and 𝑎1 in the equation 𝑦 = 𝑎0 + 𝑎1𝑥 to provide a best fit in the sense of least-squares deviation to the data points (1, 4.9), (3, 11.2), (4, 13.7), and (6, 20.1)
(Solution)
Chapter 4. Equation fitting
𝑥𝑖 𝑦𝑖 𝑥𝑖2 𝑥𝑖𝑦𝑖
1 4.9 1 4.9
3 11.2 9 33.6
4 13.7 16 54.8
6 20.1 36 120.6
∑ 14 49.9 62 213.9
𝑚 = 4
4𝑎0 + 14𝑎1 = 49.9 14𝑎0 + 62𝑎1 = 213.9
i i
mab
x
y2
i i i i
a
x b
x
x y𝑦 = 1.908 + 3.019𝑥
4.10 Best fit : Method of Least Squares
• Method of least squares for y a bxcx2
2
2 3
2 3 4 2
1 i i i
i i i i i
i i i i i
a b x c x y
a x b x c x y x
a x b x c x y x
𝑖=1 𝑚
(𝑎 + 𝑏𝑥𝑖 + 𝑐𝑥12 − 𝑦𝑖)2 → 𝑚𝑖𝑛
Chapter 4. Equation fitting
4.11 Method of Least Squares Applied to Nonpolynomial Forms
• Method of least squares
→ apply to equation with constant coefficients cf)
y sin 2 ax bx
cChapter 4. Equation fitting
4.12 The art of equation fitting
• Choice of the form of the equation
Polynomials with negative exponent(1) Exponential eq.(2)
Gompertz eq(3) combination
, 1
cx
y ab where b c
(1) (2) (3)