With MATLAB code Calculate the linear Lagrange polynomial to find the temperatur
ID: 3108839 • Letter: W
Question
With MATLAB code
Calculate the linear Lagrange polynomial to find the temperature at 45 degrees. Plot all the data points and the polynomial on a single figure. (Recall Linear Lagrange Polynomial Fit utilizes the two closest data points to the desired value) Calculate the quadratic Lagrange polynomial to find the temperature at 45 degrees. Plot all the data points and the polynomial on a single figure. (Recall Quadratic Lagrange Polynomial Fit utilizes the three closest data points to the desired value) Which Lagrange Fit method has the lowest maximum error across all data points? Which Lagrange Fit method has the lowest average error across all data points?Explanation / Answer
%Created by myclassbook.org %lagrange interpolation formula % Question: Given set of values of x and y (80,6.47),(60,6.36),(40,6.24),(20,6.12), (0,6.00) % Find the value of y corresponding to x=45 using lagrange interpolation clc; clear all; close all; y=[6.47 6.36 6.24 6.12 6.00]; %Change here for different function x=[80 60 40 20 0]; a=6.47; %Applying Lagrange's Interpolation: ans1=((a-y(2))*(a-y(3))*(a-y(4)))*x(1)/((y(1)-y(2))*(y(1)-y(3))*(y(1)-y(4))); ans2=((a-y(1))*(a-y(3))*(a-y(4)))*x(2)/((y(2)-y(1))*(y(2)-y(3))*(y(2)-y(4))); ans3=((a-y(1))*(a-y(2))*(a-y(4)))*x(3)/((y(3)-y(1))*(y(3)-y(2))*(y(3)-y(4))); ans4=((a-y(1))*(a-y(2))*(a-y(3)))*x(4)/((y(4)-y(1))*(y(4)-y(2))*(y(4)-y(3))); m=ans1+ans2+ans3+ans4; y x fprintf('the value of x corresponding to y=15 is %f',m);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.