100% Guaranteed Results


ESO 208A: Computational Methods in Engineering Solved
$ 20.99
Category:

Description

5/5 – (1 vote)

Programming Assignment 3: Least Squares and Interpolation

Input: Read a set of data points {𝑥𝑘, 𝑦𝑘}; 𝑘 = 0, 1, 2, ⋯ 𝑛 from an input file. The input file should contain the data set in two columns separated by ‘tab’ or ‘comma’.
Write a computer program with the following options sequence:
Asks the user, “What do you want to do?”
A. Fit a least square polynomial
a. If chosen, asks the user to specify the order of the polynomial (an integer < n).
b. Output is sent to a file and consists of the equation of the polynomial; a plot of the data (scatter) and the fitted polynomial; and the r2 value.
B. Fit a Lagrange Interpolation Polynomial
a. Output is sent to a file and consists of the equation of the polynomial and a plot showing the data (scatter) and the fitted polynomial
C. Fit a Newton’s Interpolation Polynomial
a. Output is sent to a file and consists of the equation of the polynomial and a plot showing the data (scatter) and the fitted polynomial D. Fit Cubic splines:
a. Gives the options to choose:
i. Linear spline
ii. Quadratic spline
iii. Natural Spline
iv. Not-a-knot
v. Periodic
vi. Clamped Spline: if chosen, ask for two first derivative values at two end points.
b. Output is sent to a file and consists of the equation of the polynomial in each interval (coefficients in a tabular form); values of the first derivative and the 2nd derivative at each node; a plot showing the data (scatter) and the fitted polynomials
Test Problems: Use the data in Problems 6 of Tutorial 8 and Problems 1-4 of Tutorial 9.
Make a single zip folder with all your program file(s) name it roll_number.zip (e.g., If your roll no. is 123456, the folder name should be ‘P3_123456.zip’). The folder should include –
(i) All the computer program file(s), input file(s) and output file(s)
(ii) A PDF file of the plots and the solution of the test cases given in this assignment.
Send the zip file by e-mail to: eso208.sec*@gmail.com, where * is section number 1-10. Example: for section O5, it is eso208.sec5@gmail.com; for section O10, it is
eso208.sec10@gmail.com
Additional Test Data: Part A:
Sample input file
0.051 0.287
0.073 0.983
0.089 0.857
0.798 9.997
0.943 18.345
0.684 6.233
0.132 0.994
0.723 6.805
0.110 0.845
0.117 1.578
0.641 4.122
0.329 1.633
0.654 5.462
0.749 7.621
0.583 4.249
0.740 7.610
0.235 0.935
0.735 7.564
0.971 20.224
0.867
12.940

Sample output files
Linear : coefficients -1.890 15.364
: R-sq = 0.7572

Quadratic : coefficients 2.907 -22.626 40.279
: R-sq = 0.9765

Cubic : coefficients -0.010 12.917 -40.710 50.262
: R-sq = 0.9965

Quartic : coefficients 0.466 4.773 -4.973 -4.250 26.747
: R-sq = 0.9968

Sample Figure

Part D: Sample input file input x and y
-1.000 0.0385
-0.500 0.1379
0.000 1.0000
0.500 0.1379
1.000 0.0385

points where function has to be evaluated (x*)
-0.8000
-0.2000
0.2000
0.8000

slope at the first (s0) and the last node (sn)
-1.0000 1.5000

Sample output files
Interpolated values y* at give x*

Linear spline
-0.800 0.0782
-0.200 0.6552
0.200 0.6552
0.800 0.0782

Quadratic spline
-0.800 0.0782
-0.200 0.4721
0.200 1.2520
0.800 -0.7016

Natural spline
-0.800 -0.0363
-0.200 0.7716
0.200 0.7716
0.800 -0.0363

Not-a-knot spline
-0.800 -0.2520
-0.200 0.8024
0.200 0.8024
0.800 -0.2520

Periodic spline
-0.800 0.0042
-0.200 0.7658
0.200 0.7658
0.800 0.0042

Clamped spline
-0.800 -0.0793
-0.200 0.7748
0.200 0.7868
0.800 -0.1222

Reviews

There are no reviews yet.

Be the first to review “ESO 208A: Computational Methods in Engineering Solved”

Your email address will not be published. Required fields are marked *

Related products