%%Matlab code for Lagrange interpolating Polynomial
clear all
close all
xi=[2.5 3.5 5 6 7.5 10 12.5];
yi=[7.0 5.5 3.9 3.6 3.1 2.8 2.6];
plot(xi,yi,'r*','linewidth',5)
%lagrange interpolating polynomial for yi
n=length(xi)-1;
syms x;
S=0;
for i=1:n+1
L=1;
for j=1:n+1
if j~=i
L=L*(x-xi(j))/(xi(i)-xi(j));
end
end
S=S+yi(i)*L;
end
%Printing the polynomial
S=expand(S);
fprintf('\n\tThe interpolating function y(x) using Lagrange
polynomial is\n')
disp(vpa(S,2))
%Creating the function for that polynomial
syms x
l(x)=S;
hold on
x1=2.5:0.1:12.5;
for i=1:length(x1)
y1(i)=double(l(x1(i)));
end
plot(x1,y1,'linewidth',2)
xlabel('x')
ylabel('f(x)')
title('Plotting of f(x) vs. x')
%Finding 2nd order polynomial
%matrix for 2nd order polynomial
for i=1:length(xi)
A(i,1)=1;
A(i,2)=xi(i);
A(i,3)=(xi(i)).^2;
b(i,1)=yi(i);
end
%coefficient matrix
c=A\b;
P(x)=c(1)+c(2)*x+c(3)*x^2;
fprintf('\n\tThe interpolating function y(x) using 2nd order
polynomial is\n')
disp(vpa(P,2))
x2=2.5:0.1:12.5;
for i=1:length(x2)
y2(i)=double(P(x2(i)));
end
plot(x2,y2,'linewidth',2)
legend('Actual data','Lagrange fit','2nd order polynomial')
fprintf('\tValue of f(x) at x=5.4 using Lagrange interpolation
is %f.\n',double(l(5.4)))
fprintf('\tValue of f(x) at x=5.4 using 2nd order interpolation is
%f.\n',double(P(5.4)))
%%%%%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%%%%
Using the Excel, fit a second-order polynomial to the data in Table Q2. Using the MATLAB. findfX)...
IN MATLAB
Write a MATLAB function that can be used by a user to perform polynomial interpolation using Lagrange Interpolation Method on a set of data. You should name your function as YourInitials_Lagrange_interpolation. 1. FUNCTION INPUT: . The input data pairs x and f(x) should be expressed as vectors and are used to construct the interpolation polynomials The interpolating data points/value The order of interpolating polynomials to be used. For this project you code should handle first order, second order...
USING MATLAB.
For given data, estimate the length when time is at 3.5 seconds and at 13 seconds by utilizing the maximum number of data given, and provide the equation for the best fit curve, and plot the curve against the data. (a) Linear regression method (b) Exponential Function (c) Power Function (d) Saturation Function (e) Polynomial regression (f) Lagrange polynomial (8) Newton's divided-difference polynomial Time (sec) Length (in) 10 17 18 25 28 30 30 10 15 36 38
The data is below and am only asking for the second portion (finite differnce approximation to find reaction order, aplha, and rate constant. If you would like to do the first portion then please do. I'm working on it now myself. Question: Find (dP/dt) using (a) interpolating polynomial fit (in Excel) and (b) finite difference approximations, and use these values to calculate the reaction order , alpha, and rate constant, k using an appropriate relationship between (dP/dt) and P. Data: ...
Write a code in Matlab for fit of y=αxβ to the data
in the following table by using a logarithmic transformation of the
data.
1 1.21.95 2 2 1 4 2.5 2.4 2.7 2.6
**********************matlab code please*******************
1. Interpolation error of polynomial fit Using 11 equi-distributed points (10 equal segments) in the interval [-1 1], Using Newton's form find and plot the interpolating polynomial p(x) for the function f(x) -1/(125x2). Comment on the large discrepancies between p(x) and the function f(x) that the data came from Write down an expression for the error in the interpolating polynomial above? Which part of the expression is responsible for the large errors observed?
1. Interpolation error of...
4. For the following table, answer the questions.
(1) Find the cubic Newton’s interpolating polynomial using the
first four data points and estimate the function value at x=2.5
with the interpolating polynomial.
(2) Find the quartic Newton’s interpolating polynomial using the
five data points and estimate the function value at x=2.5 with the
interpolating polynomial.
(3) Find the bases functions of Lagrange interpolation, Li(x)
(i=1,2,…,5), and estimate the function value at x=2.5 with the
Lagrange interpolating polynomial.
3 5 1...
please show all excel spreadsheets please
Fit the data below to their respective models by using an appropriate transformation and linear regression. Determine the constants A and B, provide the R2 for your linear regression analysis, and comment on the goodness of the fit using residual analysis Data Set 3 0.5 1 0.8889 0.5 2 0.32 2.5 0.2222 3 0.1633 3.5 0.125 4 0.0988 4.5 0.08 5 0.0661 1.5 2 x-
Question 1 The following algorithm fits a polynomial for the given data by using Lagrange polynomials. Fill in the blanks. co clear all syms pbx) LDX) X0-12-2.3 2.5 2.9 3.1]: y-10.0931470.832909 0.916291 1.064711 1.1314021; n-lengthys: p(x)=0 for in L(x)-1; for-1 if LIX end end PIXI-plx+y)(x: end
3) A 2nd-order Lagrange Interpolating Polynomial is to be fit to the following data points:(1)-1,1(2)4, 1(3)-9. Determine the polynomial term corresponding to the data point f(3) 8. Be sure to simplify as much as possible. (Don't take time to write the other two terms.) (1 point)
MATH 220 Project 1 Polynomial Curve Fitting It desired to fit a polynomial curve through evenly spaced (x-direction) points. The general form of a polynomial is: f(x) = 4,x" +47-1X2-1 + + ax + ao If one wishes to fit a curve through, say 4 points, one would need a 3rd degree polynomial (n = 3) such that 4 unknown constants could be evaluated. In the absence of availability of many wathematical programming tools (Matlab, etc., Mathematica is available as...