Computational Methods in Engineering

User Generated

Wbar111

Engineering

Description

Hi

How are you

I need you to do it by using matlab code

Thanks

Unformatted Attachment Preview

4. Fit a cubic polynomial to the following data and compute the r- and standard deviation of the regression, Sy/x. . 3 1.6 4 3.6 5 4.4 7 3.4 8 2.2 9 2.8 11 3.8 12 4.6 у 5. The temperature in a pond varies approximately sinusoidally over the course of a year. Use least-squares regression to fit the equation, y = A, + A, cos(wot) + B, sin(Wt) + e, to the data below. Use your fit to determine the mean, amplitude, and date of maximum temperature. Note that the period is 365 days (d). t, d 15 45 75 105 135 165 225 255 285 315 345 T°C 3.4 4.7 8.5 11.7 16 18.7 19.7 17.1 12.7 7.7 5.1 1. Use a third order Newton's interpolating polynomial to determine y at x = 3.5 to the best possible accuracy with the data below. Compute the finite divided differences, and order your points to attain optimal accuracy and convergence. That is, the points should be centered around and be as close as possible to the unknown. x 0 2. 1 2.5 3 4.5 5.4375 7.3516 7.5625 8.4453 5 6 9.1875 12 y 2. Given the data below, (a) Calculate f (3.4) using Newton's interpolating polynomials of order 1 through 3. Choose the sequence of the points for your estimates to attain the best possible accuracy. That is, the points should be centered around and be as close as possible to the unknown. (b) Repeat (a) but use the Lagrange polynomial. r f(x) 1 0 2 5 2.5 7 3 6.5 4 2. O 07 3. Given the data below, Calculate f (4) using Lagrange interpolating polynomials of order 1 through 4. Choose your base points to attain good accuracy. That is, the points should be centered around and be as close as possible to the unknown. What do your results indicate regarding the order of the polynomial used to generate the data in the table? . 4.75 1 4.75 2 4 3 5.25 5 19.75 6 36 f(x)
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Hi, here is your assignment together with matlab files :).

1
Computational Methods in Engineering
Problem 1:
Matlab Code:
% Problem 1:
x=[0 1 2.5 3 4.5 5 6];
y=[2 5.4375 7.3516 7.5625 8.4453 9.1875 12];
newton_interpolation(x, y, 3.5)

function fp = newton_interpolation(x,y,p)
% x and y are two Row Matrices and p is point of interpolation
n = length(x);
a(1) = y(1);
for k = 1 : n - 1
d(k, 1) = (y(k+1) - y(k))/(x(k+1) - x(k));
end
for j = 2 : n - 1
for k = 1 : n - j
d(k, j) = (d(k+1, j - 1) - d(k, j - 1))/(x(k+j) - x(k));
end
end
d
for j = 2 : n
a(j) = d(1, j-1);
end
Df(1) = 1;
c(1) = a(1);
for j = 2 : n
Df(j)=(p - x(j-1)) .* Df(j-1);
c(j) = a(j) .* Df(j);
end
fp=sum(c);
end

Output:
d = 6×6
3.4375
-0.8646
1.2761
-0.4271
0.4218
0.0834
0.5885
0.4479
1.4844
0.8854
2...

Related Tags