American University of Sharjah: NGN 509 - Computational Methods Professor Nai-Shyong Yeh Assignment #2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

American University of Sharjah

College of Engineering

NGN 509 – Computational Methods


Professor Nai-Shyong Yeh
Assignment #2

Mostafa Mohamed Moussa - 59665

Submitted on 21st of March 2019


Q1.
Code is in m-file. Figures are as shown: (not done on same graph for visibility)

Plot of data w/out approx & fitting Plot of data, n=1


3 2.6

2.4

2.5
2.2

2
2
1.8

f(x)
1.6
f(x)

1.5

1.4

1
1.2

1
0.5
0.8

0 0.6
0 2 4 6 8 10 12 14 0 2 4 6 8 10 12 14

x x
Plot of data, n=5
Plot of data, n=3 2.5
2.5

2
2

1.5
1.5
f(x)
f(x)

1
1

0.5
0.5

0
0 0 2 4 6 8 10 12 14
0 2 4 6 8 10 12 14
x
x

Cubic Spline
3

2.5

2
f(x)

1.5
Q2.
1

0.5

0
0 2 4 6 8 10 12 14
x
Code is in the m-file. From the code, you get: a0 = 0.0033, a1 = 0.4970, a2 = -0.2738, a3 = 0.0511
so the third-order polynomial is: p3(x) = 0.0033 + 0.4970 x - 0.2738 x2 + 0.0511 x3
n
Standard deviation = 0.0099. σ =
√ S
n−m i=1
2
|
, S=∑ e ei=Yi-yi | n=6, m=3.
Q3.
1 & 3)
2)

Plots of y vs x and the fitting function f(x)


300
y
f(x)

250

200
y/f(x)

150

100

50

0
1 2 3 4 5 6 7 8
x

You might also like