You are on page 1of 6

 

 
University of Benghazi
 
Faculty of Engineering
 

 
Civil Engineering Department
 

Numerical Analysis CE 501


Homework No.4
Curve Fitting 
 

Submitted to:
Prof. Salem Alsanusi
07, Nov, 2022

Prepared by:
Bashir A. El-Saadawi
CE 501 Numerical Analysis
 
Q1) Fit the following data using the following approach
1) straight line
2) power
3) exponential

x 2 7 8 12 9

y 8 5 4 3 2
● Solution:
1) straight line
𝑦 𝑎 𝑎 𝑥
𝑛 ∑𝑥 𝑦 ∑𝑥 ∑𝑦
𝑎
𝑛 ∑𝑥 ∑𝑥
∑𝑥 ∑𝑦 ∑𝑥 ∑𝑥 𝑦
𝑎
𝑛 ∑𝑥 ∑𝑥

x y 𝑥𝑦 x2
2 8 16 4
7 5 35 49
8 4 32 64
12 3 36 144
9 2 18 81
𝑥 𝑦 𝑥𝑦 𝑥

38 22 137 342

5 137 38 22
𝑎 0.5677
5 342 38
342 22 38 137
𝑎 8.7143
5 342 38

𝑦 8.7143 0.5677𝑥

 

 
CE 501 Numerical Analysis
 
2) power
𝑦 𝛼 𝑥
𝑙𝑜𝑔 𝑦 𝑙𝑜𝑔 𝛼 𝛽2 𝑙𝑜𝑔 𝑥

x y Log x Log y (Log x)2 Log x Log y


2 8 0.30103 0.90309 0.090619 0.271857
7 5 0.845098 0.69897 0.714191 0.590698
8 4 0.90309 0.60206 0.815572 0.543714
12 3 1.079181 0.477121 1.164632 0.5149
9 2 0.954243 0.30103 0.910579 0.287256
2
𝑥 𝑦 𝐿𝑜𝑔 𝑥 𝐿𝑜𝑔 𝑦 𝐿𝑜𝑔 𝑥 𝐿𝑜𝑔 𝑥 𝐿𝑜𝑔 𝑦

38 22 4.082642 2.982271 3.695592 2.208426

𝑛 ∑ 𝐿𝑜𝑔 𝑥 𝐿𝑜𝑔 𝑦 ∑ 𝐿𝑜𝑔 𝑥 ∑ 𝐿𝑜𝑔 𝑦


𝑎
𝑛 ∑ 𝐿𝑜𝑔𝑥 ∑ 𝐿𝑜𝑔 𝑥
5 2.208426 4.082642 2.982271
𝑎 0.626
5 3.695592 4.082642
𝑙𝑜𝑔 𝛼 𝑙𝑜𝑔 𝑦 𝛽2 𝑙𝑜𝑔 𝑥̅
𝑙𝑜𝑔 𝑥̅ 0.816528
𝑙𝑜𝑔 𝑦 0.596454
𝑙𝑜𝑔 𝛼 0.596454 0.626 0.816528 1.107762
.
𝛼 10 12.816

𝑦 𝛼 𝑥

.
𝑦 12.816𝑥

 

 
CE 501 Numerical Analysis
 
3) exponential
𝑦 𝛼 𝑒
ln 𝑦 ln 𝛼 𝛽 𝑥 ln 𝑒
ln 𝑦 ln 𝛼 𝛽𝑥

𝑌 𝑎 𝑎 𝑥
𝑛 ∑ 𝑥 ln 𝑦 ∑ 𝑥 ∑ ln 𝑦
𝑎
𝑛 ∑𝑥 ∑𝑥
∑𝑥 ∑ ln 𝑦 ∑ 𝑥 ∑ 𝑥 ln 𝑦
𝑎
𝑛 ∑𝑥 ∑𝑥

x y ln y x2 x ln y
2 8 2.079442 4 4.158883
7 5 1.609438 49 11.26607
8 4 1.386294 64 11.09035
12 3 1.098612 144 13.18335
9 2 0.693147 81 6.238325
𝑥 𝑦 ln 𝑦 𝑥 𝑥 ln 𝑦

38 22 6.866933 342 45.93698

5 45.93698 38 6.866933
𝑎 0.118
5 342 38
342 6.866933 38 45.93698
𝑎 2.26649
5 342 38
𝛽 𝑎 0.118
.
ln 𝛼 𝑎 𝛼 𝑒 𝑒 9.6455

.
𝑦 9.6455 𝑒

 

 
CE 501 Numerical Analysis
 

Staight Line
9

8
y = -0.5677x + 8.7143
7

5
y

0
0 2 4 6 8 10 12 14
x

Power
9

7
y = 12.816x-0.626
6

5
y

0
0 2 4 6 8 10 12 14
x

 

 
CE 501 Numerical Analysis
 

exponential
9

8
y = 9.6455e-0.118x
7

5
y

0
0 2 4 6 8 10 12 14
x

The sum of the squares of the errors between the measured y and the y calculated Explained in
the following table

𝑒 𝑦 𝑦 2

Straight Line Power exponential


𝑦 𝑦 𝑒 𝑦 𝑦 𝑒 𝑦 𝑦 𝑒
8 7.578947 0.177285 8 8.303446 0.09208 8 7.625228 0.140454

5 4.740602 0.067288 5 3.789343 1.465689 5 4.237166 0.581915

4 4.172932 0.029906 4 3.485375 0.264839 4 3.767386 0.05411

3 1.902256 1.205043 3 2.703843 0.087709 3 2.354497 0.416674

2 3.605263 2.57687 2 3.23756 1.531556 2 3.34969 1.821663

∑𝑒 = 4.056391 ∑𝑒 = 3.441873 ∑𝑒 = 3.014815

As shown, we can estimate the best fit from the exponential approach.

 

 

You might also like