Professional Documents
Culture Documents
PROJECT
Submitted by
1
6th August 2023
Table of Content
Content Page Number
Objectives 3
Problem Statement 4
Introduction and Background 6
Methodology of Solution:
1) Regression Analysis 8
a) Linear Regression (LR) 8
b) Nonlinear Regression (NLR) 11
2) Interpolation 14
a) Newton’s Divided Difference Method (NDD) 14
b) Lagrangian Method (LM) 17
3) Error Analysis 19
b) Error Propagation 19
c) Condition Number (CN) 21
Results and Discussion 23
Conclusion 24
References 25
2
Objectives:
The purpose of this project is to apply three numerical methods, using two
different techniques for each method and then comparing the obtained values to
our case study problem mentioned in the problem statement section of this project.
Fitting the given data of the experiment using Linear Regression and Non-
linear Regression.
Application of error analysis to our data using both condition number and
error propagation.
At the end of each Technique / Method, compare and discuss the approximated
values with the true values.
3
Problem Statement
The following experimental data was obtained after an experiment to find thermal
expansion at different temperatures.
T (℃) ∆ L(mm)
-15 21.113
-5 21.187
0 21.755
5 24.230
10 25.988
15 26.435
20 28.221
Table 1: Measured thermal expansion at different temperatures.
The thermal expansion of a Lo=20 m=20× 103 mm long steel rail is measured
to observe it for this experiment.
Temperature Range :{ -15℃ to 20℃ }
The data above in Table 1 shows the change in length {∆ L ( mm ) } with a subjective
zero point at different seven temperatures in {℃ } starting at -15 to 20 and an
initial length of 20 ×103 mm of a steel rail.
The model describes how the steel rail undergoes thermal expansion:
∆ L=α Lo T + ∆ Lo (1)
Where,
∆ L: Change in length of the steel rail due to the change in temperature.
α : Thermal expansion coefficient of the steel rail.
Lo : Length of the steel rail (at reference point) .
4
T : Change of temperature comparing to the reference point.
∆ Lo : Constant value that represents some offset in length that might be
present even when the temperature change is zero.
A. Use least square regression to fit the data into a straight line. Similarly, the
second order polynomial utilizing multi-least square regression.
Determine the steel expansion coefficient (α ¿ where the true value is
11.49 x 10-6 mm/mm.℃
5
Introduction and background
“ Thermal expansion is among the more serious of plumbing concerns, but one
that many homeowners know little about. Because many homes aren't at risk, it
rarely seems to enter the typical plumbing discussion. Of the homes that are, many
6
lack adequate protection since code requirements are often only enforced on new
installations.”1
When a material undergoes thermal expansion its shape, volume, and area can
change. Temperature is a way to measure the average energy of the material's
particles. So, when the material is heated, the particles gain more energy, and they
start to vibrate which can increase the space between the particles. This
temperature driven expansion is typically not very noticeable or significant and it
occurs within a specific temperature range called strain. Scientists and engineers
use the coefficient of thermal expansion to quantify this effect and it usually varies
with temperature.
Where,
Lf : Final length
Li : Initial length
T f : Final Temperature
1
https://www.plumbingsupply.com/thermal-expansion.html
7
T i : Initial Temperature
α : The mean coefficient of linear expansion for a specified material and has
units of (℃)−1 /1 ≈(mm /mm ∙℃)or (℉ )−1/ 1 ≈ (mm/mm ∙ ℉) .
Methodology of Solution
Where b 0and b 1 are coefficients representing the slope and the intercept of the
mathematical equations above { (6), (7) }.
The table below shows necessary calculations to regress the experimental data:
i xi (T) yi ∆ L
( ) x2 x⋅y (yi-y)2 (yi-b0-b1xi)2
1 -15 21.113 225 -316.69 8.33476 2.3211
2 -5 21.187 25 -105.93 7.91296 0.47621
3 0 21.755 0 0 5.04002 1.60247
4 5 24.230 25 121.15 0.05290 4.264 x10-3
5 10 25.988 100 259.88 3.95214 0.46170
6 15 26.435 225 396.52 5.92922 2.998x10-3
8
7 20 28.221 400 564.42 17.8168 0.39046
- - - - - - -
n= ∑T. ∆ L
∑T=30 ∑∆ L =168 ∑T2=1000 ∑=49.0388 ∑=5.259202
7 =919.35
Table 1: Linear Regression Calculation
n=7
∑T 30
T = i=1 = =4.28
n 7
7
∑∆L 168
∆ L= i=1 = =24
n 7
n ST ∆ L−S ∆ L ST
b 1=
2 ( 7 ) ( 919.35 )−(168)(3 0)
n ST −(S ¿¿ T ) =
2 =0 .228762¿
( 7 ) ( 1000 )−(3 0)2
b 1=α Lo
b1 0.228762 −5
α= = 3
=1 .14381× 10
Lo 20 ×10
Hence, the least square fit can be expressed in this linear equation:
∆ L=b0 +b 1 T =0 .228762 T +23.02089
i=1
i=1
9
S y=
√ St
n−1
=2.858869
S y / x=
√ Sr
n−2
=1.02559
Thus, because S y / x < S y , the linear regression model has permit. The extent of the
improvement is quantified by the coefficient of determination:
2 St −Sr
r= =0.89275
St
These results indicate that 89.275 % of the original uncertainty has been explained
by the linear model.
| |
α true value −α
| |
−6 −6
11.49× 10 −1 0.833 ×10
|ϵt|%= α true value
×100 %= −6
× 100 % = 5.7180%
11.5× 10
10
Figure 3: Linear regression plot (∆L versus T) model using MATLAB.
Code:
11
Method (B) : Quadratic Regression (LR)
A nonlinear model includes models where the functional relationship between
variables is not a straight line regarding the unknown parameters. Multiple least
squares regression is a prevalent form of multiple regression that employs the least
squares method to adjust the model to the data by estimating the unknown
parameter values. Explicitly, the second-order polynomial is an example of such a
mathematical expression expressed as :
2
∆ L=b0 +b 1 T +b2 T (6)
¿ b 0 z 0 +b1 z 1+ b2 z 2 (7)
2
Where, the mentioned functions above are monomials { z 0=1/ z 1=T / z 2=T }
12
{ ∆ L }=[ Z ] { A }+ {E }
−1
{ A }= [ [ Z ] [ Z ] ]
T
[ [ Z ] T {∆ L}]
Setting the data inside the matrices :
[ ] []
1 −15 225 21.113
1 −10 100 21.187
1 −5 25 21.755
[Z ]= 1 0 0 {∆ L}= 24.230
1 5 25 25.988
1 10 100 26.435
1 15 225 28.221
[ ]
1 1 11 1 1 1
T
[Z ] = −15 −10 5 0 5 10 15
225 100 25 0 25 100 225
[ ] [ ]
7 0 700 168.949
[ [ Z ]T [ Z ] ]= 0 700 0 [ [ Z ]T {∆ L }]= 179.965
700 0 122500 17060.425
[ ]
−1
0.33333 0 −1.9047 × 10−3
[ [ Z ]T [ Z ] ] = 0 1.4285 × 10
−3
0
−3
−1.9047 × 10 0 1.9047 × 10−5
[ ]
−1 23.821336
{ A }= [ [ Z ] [ Z ] ]
T
[ [ Z ] T {∆ L}]= 0.2570800
0.00315275
b 0=19.84321
b 1=0.2570800
b 2=0.00315275
13
Substituting in equation(6) :
2
∆ L=19.84321+ 0.2570800 T +0.00315275 T
m+1=3
∑T
T = i=1
n
7
∑∆L
∆ L= i=1
n
7
Sr =∑ ( ∆ Li −a0 −a1 T i )
2
i=1
7
St =∑ ( ∆ L−∆ L )
2
i=1
S y / x=
√ Sr
n−(m+1)
S y=
√ St
n−1
2
r =0.942
14
Second Technique : Interpolation
Where,
z 0=f [ x 0 ]
z 1=f [ x 1 , x 0 ]
z 2=f [ x 2 , x 1 , x 0 ]
z 3=f [ x 3 , x2 , x1 , x 0 ]
z 0=f [ x 0 ]
z 1=f [ x 1 , x 0 ]
z 2=f [ x 2 , x 1 , x 0 ]
z 3=f [ x 3 , x2 , x1 , x 0 ]
T 0=15 , ∆ L ¿T=15=26.435
T 1=10 , ∆ L¿ T=10=25.988
T 2=5 , ∆ L¿ T=5=24.230
T 3=0 , ∆ L ¿T =0 =21.755
15
Calculating z 0 , z 1 , z 2 ,∧z 3 values:
That is:
z 0=26.435
z 1=0.0894
z 2=0.05244
−3
z 3=4.452× 10
∆ L(8)=23.626 mm
Truncation Error:
R3=z 4 ( T −T 0 ) ( T −T 1 )( T −T 2 ) ( T −T 3 ) (9)
16
Finding the value of z 4:
T 0=15 26.435
0.08940
0.11360
T 4=−5 21.187
17
|ϵt|%= | ∆ Ltrue value−∆ Linterpolated
∆ Ltrue value |
×100 %
¿|24.0384−23.626
24.0384 |×100 % = 1.70086%
n
x−x
Where, pn , i ( x ) : ∏
j
j=0 xi −x j
j ≠i
Considering : ∆ L=x
3
x (T )=∑ p i ( T ) x ( T i)
i=0
x (T )= p 0 ( T ) x ( T 0 ) + p1 ( T ) x ( T 1 )+ p 2 ( T ) x ( T 2 )+ p 3 ( T ) x (T 3 )
T 0=15 , x ( T 0 )=26.435
T 1=10 , x ( T 1 )=25.988
T 2=5 , x ( T 2 )=24.230
T 3=0 , x ( T 3 )=21.755
Finding the Lagrangian basis polynomials p0, p1, p2, and p3:
18
( )( )( )
3
T −T j T −T 1 T −T 2 T −T 3
p0 ( T ) = ∏ =¿ ¿
j=0 T 0−T j T 0−T 1 T 0 −T 2 T 0−T 3
j ≠0
( )( )( )
3
T −T j T −T 0 T −T 2 T −T 3
p1 ( T ) = ∏ =
j =0 T 1−T j T 1−T 0 T 1−T 2 T 1−T 3
j ≠1
( )( )( )
3
T −T j T −T 0 T −T 1 T −T 3
p2 ( T ) = ∏ =
j =0 T 2−T j T 2 −T 0 T 2−T 1 T 2−T 3
j ≠2
( )( )( )
3
T −T j T −T 0 T −T 1 T −T 2
p3 ( T ) = ∏ =
j=0 T 3 −T j T 3−T 0 T 3−T 1 T 3−T 2
j ≠3
x (T )=
( T −T 1
T 0 −T 1 )( T −T 2
T 0−T 2 )( T −T 3
T 0 −T 3 )
x (T0)+
T −T 0
T 1−T 0 ( )( T −T 2
T 1−T 2 )( T −T 3
T 1−T 3) (
x (T 1)+
T−T 0
T 2−T 0 )( T −T 1
T 2−T 1 )( T −T 3
T 2−T 3)x (T
Evaluating at T =8 ° C :
x ( 8 )= ( 15−10
8−10
)( 15−5
8−5
)( 15−0
8−0
) 26.435+( 10−15
8−15
)( 10−5
8−5
)( 10−0
8−0
) 25.988+( 8−15
5−15 5−10 )( 5−0 )
)( 8−10 8−0
24.230+
¿|24.0384−23.9675
24.0384 |× 100 %
¿ 0.2949 %
19
Third Technique : Error Analysis
(13)
Where,
∆f left (widetilde {x} right ) = left lline f left (x right ) -f left (widetilde {x} right ) right rline
: Shows an estimate of error of the function.
∆ widetilde {x} = left lline x- widetilde {x} right rlin ” : Shows an estimate of the
error of x .
∆ L−∆ Lo
α=
T Lo
x−∆ Lo
α =f (x)=
T Lo
24.230
Given data:
T =5 ℃
∆ Lo =20 mm
20
~
x=24.230 ± 2.000 mm
' 1
f ( x )=
T Lo
1
f (~
' ' −5 −1
x )=f ( 24.230 )= =1× 10 (mm . ℃)
(5 ℃)(20,000 mm)
24.230 mm−20 mm
f (~
−5
x )=f ( 24.230 )= =4.23 × 10 mm/mm ∙ ℃
(5 ℃)(20,000 mm)
Hence,
21
−5
α true value=1.46 ×10 mm/mm . ° C
∆ L−∆ Lo
α=
T Lo
x−∆ Lo
α =f (x)=
T Lo
' 1
f ( x)=
T Lo
Given data:
22
Substituting:
CN =
'
x f (x)
( x)
=
( T1L ) =
o x
=
x
( )
f (x) x−∆ Lo x−∆ Lo x−2.000
T Lo
At first Point:
21.113
CN = =1.10464
21.113−2.000
At second Point:
T =0 ℃ , x (∆ L)=¿ 21.755 mm
21.755
CN = =1.10124
21.755−2.000
At Last Point:
26.435
CN = =1.08184
26.435−2.000
determination indicates the data coverage capability of each curve, with the
23
quadratic regression (94.20%) outperforming the linear regression (89.275%).
Therefore, quadratic regression is preferred for fitting the data.
Determination of ∆L at T=8℃:
Through the Lagrangian and NDD methods, the value of ∆L at T=8℃ was found
to be 23.626 mm, both with a true error of 1.70086%. The accuracy of these
methods is evident as their true errors fall below 5%, which is considered excellent
for approximation mathematical approaches.
Error Analysis of Thermal Expansion Coefficient (α):
Applying the error propagation method at ∆L=2.000 mm, the error at T=5 ℃ and
L=24.230 mm was calculated to be 2×10-5 mm/mm.℃. This error is relatively
small compared to the uncertainty in L. Additionally, the condition number at
T= -15 ℃ was found to be higher than at T=15 ℃, indicating lower stability of
the thermal expansion coefficient at T= -15 ℃. However, both cases are
considered stable and well-conditioned since the condition number values are
close to 1.
Conclusion
In this project, the focus was on studying thermal expansion using different
numerical methods. The main equation we used represents how a material expands
in one dimension as the temperature changes. We wanted to see which numrical
method works best in terms of accuracy and precision.
Firstly, Least-Squares Regression method was applied to fit the data to a straight
line and a second-order polynomial. After analyzing the results it was found that
24
the higher order regression (with a higher determinant coefficient value, r2)
provided a better fit.
Next, we explored cubic interpolating techniques specifically Lagrangian and
NDD. These methods helped us determine the thermal expansion (∆L) at a specific
temperature (T=8℃ ) with smallest error and high accuracy.
To detailed analyzes for the thermal expansion coefficient model, I used two error
analysis numerical methods (Error Propagation and Condition Number). These
methods allowed us to gain deeper understandings into the data.
In conclusion, this project showed that utilizing many numerical techniques in data
analysis can lead to interesting and valuable results. It highlighted the importance
of using multiple approaches to gain a complete understanding of given data.
References
The "MATLAB Code for Newton's Divided Difference Formula" can be
accessed through the following link: https://www.youtube.com/watch?
v=_pbfOxAlH9I.
MATLAB (Online version) accessed through the following link:
https://matlab.mathworks.com/
[1] https://www.plumbingsupply.com/thermal-expansion.html
25
Bergmann, T. L., Laverne, A. S., Incr0pera, F. P., & Dew1tt, D. P.
(2002). Fundementals of heat with mass transfer (sixth Edition). WILEY
Matrices operations were operated using:
https://www.emathhelp.net/en/calculators/linear-algebra/matrix-calculator/?
op=*&p=&c=&a=%5B%5B1%2C1%2C1%2C1%2C1%2C1%2C1%5D
%2C%5B-15%2C-10%2C-5%2C0%2C5%2C10%2C15%5D%2C
%5B225%2C100%2C25%2C0%2C25%2C100%2C225%5D%5D&b=%5B
%5B1%2C-15%2C225%5D%2C%5B1%2C-10%2C100%5D%2C
%5B1%2C-5%2C25%5D%2C%5B1%2C0%2C0%5D%2C
%5B1%2C5%2C25%5D%2C%5B1%2C10%2C100%5D%2C
%5B1%2C15%2C225%5D%5D
https://amarineblog.com/2020/04/09/thermal-expansion-affections-in-
piping-system/
26