1) Below code is subroutine lagrange, Save this subroutine as lagrange.m. and call the function in the main program.
explanation of the code is in the comments.
function y=lagrange(x,pointx,pointy)
%% In this function x is the points to be calculted, y is the
interpolated value
%% calculate the input size
n=size(pointx,2);
%% Generate the initial values of the x
L=ones(n,size(x,2));
%% Calcaulate the missing points using legranges interpolation
formule
for i=1:n
for j=1:n
if (i~=j)
L(i,:)=L(i,:).*(x-pointx(j))/(pointx(i)-pointx(j));
end
end
end
y=0;
for i=1:n
y=y+pointy(i)*L(i,:);
end
%%Sorting X and Y
X=[x pointx];
Y=[y pointy];
[sortedX, sortIndex] = sort(X)
sortedY = Y(sortIndex)
%% Plot the graph
plot(pointx,pointy,'Color','red');
hold on;
plot(sortedX,sortedY,'Color','blue');
hold off;
legend('original','after Inter polation');
2) Data sets are compared using the below program
close all;
clc;
clear all;
%% Given input data points
pointX=[1,4];
pointY=[3,7];
%% Missing points
x=[2,4];
%% Interpolating using the Sub routine
y=lagrange(x,pointX,pointY);
%% Given input data points
pointX=[-1,0,3];
pointY=[5,8,-10];
%% Missing points
x=[1,2];
figure;
%% Interpolating using the Sub routine
y=lagrange(x,pointX,pointY);
%% Given input data points
pointX=[-10,4,7,12];
pointY=[-2,5,3,20];
%% Missing points
x=[-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,5,6,8,9,10,11];
figure;
%% Interpolating using the Sub routine
y=lagrange(x,pointX,pointY);
Below plots shows the data set before interpolation and after interpolation
a) Below plot is for data point (1,3) (4,7)

b) Below plot is for data point (-1,5) (0,8)(3,-10)

c) below is the plot for(-10,-2) (4,5) (7,3) (12,20)

Use MATLAB or Scilab to solve the following problems 1. Create a MATLAB subroutine called Lagrange.m...
must be done in MATLAB
2. Create a main program that calls the subroutine created on problem 1 and compare results using the following data sets: b. (1 5), (0, 8), (3, -10) С. (-10,-2). ( 4,5), (7, 3), (12, 20) Output: (copy and paste the output in the following box) Use MATLAB or Scilab to solve the following problems 1. Create a MATLAB subroutine called Lagrange.m that receives two set data points, x and y and plots the curve...
2. Create a main program that calls the subroutine created on problem 1 and compare results using the following data sets: b. 1 5), (0, 8), (3,-10) С. (-10,-2), (45), (73), (12, 20) t: (copy and paste the output in the following box) Use MATLAB or Scilab to solve the following problems 1. Create a MATLAB subroutine called Lagrange.m that receives two set data points, x and y and plots the curve by interpolating the missing points (hEX-Xi-1) using Lagrange...
in put and output done in computer please
Use MATLAB or Scilab to solve the following problems 1. Create a MATLAB subroutine called Lagrange.m that receives two set data points, x and y and plots the curve by interpolating the missing points (h=x-X.1) using Lagrange interpolation form.
USE MATLAB
3. Use MATLAB or Scilab to implement cubic spline, and plot the points and the curve for the following data sets. x-[018 12 27) and y=[12345) Input: (copy and paste the MATLAB or Sclla command in the following box) Output: (copy and paste the output in the following box)
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...
Problem 2. Given the data points (xi. yi), with xi 2 02 4 yil 5 1 1.25 find the following interpolating polynomials, and use MATLAB to graph both the interpolating polynomials and the data points: a) The piecewise linear Lagrange interpolating polynomialx) b) The piecewise quadratic Lagrange interpolating polynomial q(x) c) Newton's divided difference interpolation pa(x) of degree s 4
Problem 2. Given the data points (xi. yi), with xi 2 02 4 yil 5 1 1.25 find the following...
i got it incomplete
sorry I put this by mistake. can this be canceled?
4. Use MATLAB or Scilab to implement linear regression, and plot the points and the curve for the following data sets. x [018 12 27) and y [12345 Input: (copy and paste the MATLAB or Sclab commandin the folowing bax) cic X1-101 8 12 271: Y1-11 234 5] Y-transpose(Y1) for n-1:5 X(n,2)-X1(n) end format long ycalc-S(2) X+S(1); scatter(X1,Y1) hold on plot(X,ycalc) xlabel(X) ylabel(Y) title('Linear Regression Relation...
matlab
The error function is a mathematical function that frequently arises in probability and statistics. It also can show up in the solution to some partial differential equations, particularly those arising in heat and mass transfer applications. The error function is defined as 2 e-t dt picture attached This function is actually built-in to MATLAB as the command erf, and here we'll use that function to compute a "true value" with which we can compare results of two interpolation approaches....
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...
**********************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...