Consider the following table of data points:
Using least squares fitting, find the polynomial Q(x) of degree 2 that fits the data points given in the table above. Approximate f(0.3) using Q(0.3).
%%Matlab code for least square fit of degree 2 polynomial
clear all
close all
%All data given
xx=[0.000 0.125 0.250 0.375 0.500 0.625 0.750 0.875 1.000];
fx=[1.00000 0.98450 0.93941 0.86882 0.77880 0.67663 0.56978 0.46504
0.36788];
%displaying the data
fprintf(' \t\t\t\tx f(x) \n')
disp([xx' fx']);
%finding degree 2 polynomial
%creating A matrix
for i=1:length(xx)
A(i,1)=1;
A(i,2)=xx(i);
A(i,3)=(xx(i)).^2;
end
%displaying A matrix
fprintf('\ndisplaying A matrix\n\n')
disp(vpa(A,6))
fprintf('\ndisplaying AT*A matrix\n\n')
disp(vpa(A'*A,6))
fprintf('\ndisplaying AT*fx matrix \n\n')
disp(vpa(A'*fx',6))
fprintf('The coefficient for degree 2 polynomials are\n')
c=(inv(A'*A))*A'*fx';
disp(c)
fprintf('Order 2 polynomial function is Q(x)= ')
syms x
Q(x)= c(1)+c(2).*x+c(3).*x.^2;
disp(vpa(Q,6))
fprintf('\tHence f(0.3) using Q(0.3) is %f\n',Q(0.3))
%plotting the data and polynomial
for j=1:length(xx)
fp(j)=double(Q(xx(j)));
end
hold on
plot(xx,fx,'r*')
plot(xx,fp)
xlabel('x')
ylabel('f(x)')
title('f(x) vs. x plot')
legend('Actual data','fitted data')
%%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%
Consider the following table of data points: Using least squares fitting, find the polynomial Q(x) of degree 2 that fit...
Consider the following table of data points: Using least squares fitting, find the polynomial Q(x) of degree 2 that fits the data points given in the table above. Approximate f(0.3) using Q(0.3). Use P(x) = Ax2+Bx +C to find 3 equations and then find A,B,C. f(x) i Xi 0 0.000 1.00000 1 0.125 0.98450 2 0.250 0.93941 0.375 0.86882 4 0.500 0.77880 5 0.625 0.67663 6 0.750 0.56978 0.875 0.46504 8 1.000 0.36788
Faculty of Engineering A standard full time year of study is equivalent to 8 credit points or one Equivalent Full-Time Student Load (EFTSL). Course fee rates for a student commencing in 2020 Credit points EFTSL Course fee 0.125 $4,737.50 0.250 $9,475.00 0.375 $14,212.50 0.500 $18,950.00 0.625 $23,687.50 0.750 $28,425.00 0.875 $33,162.50 1.000 $37,900.00 Write some code to do the following: 1. Write a function calcE3001Fees that takes one parameter, creditPoints. This function should calculate the fees due given the creditPoints...
please write down detailed solution (do not copy 3. [Polynomial interpolation versus least squares fitting, 10pts] Recall how Q7 in HW3 required you to find the cubic best fit to six given data points. This led to a least squares optimization problem. We are given the same points as in HW3: i 01 | 2 | 3 | 4 | 5 X 0.0 0.5 1.0 1.5 2.0 2.5 Y 0.0 0.20 0.27 0.30 0.32 0.33 (a) Write down the least...
Given the data points (xi , yi), with xi 0 1.2 2.3 3.5 4 yi 3.5 1.3 -0.7 0.5 2.7 find and plot (using MATLAB) the least-squares basis functions and the resulting least-squares fitting functions together with the given data points for the case of a) a linear monomial basis p(x)= {1 x}T . b) a quadratic monomial basis p(x)= {1 x x2}T . c) a trigonometric basis p(x)= {1 cosx sinx}T Moreover, determine the coefficients a by the Moore-Penrose...
Problem 6: Interpolation, least squares, and finite difference Consider the following data table: 2 = 0 0.2 0.4 0.6 f(x) = 2 2.018 2.104 2.306 A cubic spline interpolation over these data is constructed as a cubic polynomial interpolating over all 4 data points. None of the above. is constructed by piece-wise locally cubic polynomial interpolation that maintains continuity of the first and second derivatives at the data points is constructed by plece-wise locally cubic polynomial interpolation that has discontinuous...
Problem 2: Interpolation, least squares, and finite difference Consider the following data table: 0 2 0.2 2.018 ti f(x) = 0.4 2.104 0.6 2.306 Using Lagrange linear interpolation between data points 22 = 0.2 and as = 0.4, the value obtained at z = 0.3 is (Chop after 2 decimal places) فو واقع = 2.06 2.09 2.03 None of the above. 2.05
2. Variational method (15 pts each, 30 points total) Fitting of a collection of the data points to a given functional form can be done using variational method. Say, the measured data points are given in the table: 1 0 1 Assuming the fitting function is f(x; α, β, ), where α, β, are the variation parameters, the fitting error functional can be formulated as: F[f-E:(f(xi; α., )-%)2. This function is a mere function of the variational parameters, so the...
C-Programming please. The task is to create second-degree polynomial calculator for the function, its integral and its derivative. A second-degree polynomial is described by the equation f(x) = ax +bx+c. Evaluation of the derivative gives the instantaneous slope or rate of change as (where f'(x) is the derivative of f(x)): f"(x)=2x+b The integral of the function f(x) (let us call it F(x)) indicates the area underneath the curve. Between points x; and the area A is A = F(x)-F(x), where,...
3. (25 pts) Consider the data points: t y 0 1.20 1 1.16 2 2.34 3 6.08 ake a least squares fitting of these data using the model yü)- Be + Be-. Suppose we want to m (a) Explain how you would compute the parameters β | 1 . Namely, if β is the least squares solution of the system Χβ y, what are the matrix X and the right-hand side vector y? what quantity does such β minimize? (b)...
Projections and Least Squares 3. Consider the points P (0,0), (1,8),(2,8),(3,20)) in R2, For each of the given function types f(x) below, . Find values for A, B, C that give the least squares fit to the set of points P . Graph your solution along with P (feel free to graph all functions on the same graph). . Compute sum of squares error ((O) -0)2((1) 8)2 (f(2) -8)2+ (f(3) - 20)2 for the least squares fit you found (a)...