Read Chapter 17, \"Polynomial Interpolation,\" from Chapra\'s textbook. The acce
ID: 3718667 • Letter: R
Question
Read Chapter 17, "Polynomial Interpolation," from Chapra's textbook. The acceleration due to gravity at an altitude y above the surface of the earth is given by
y [m] 0 30,000 60,000 90,000 120,000
g [m/s^2] 9.8100 9.7487 9.6879 9.6278 9.5682
Compute g at y = 55,000 m, the Newton polynomial coefficients b_1 through b_5, and the associated Lagrange coefficients, L_1 through L_5, for the fourth-order (quartic) polynomial.
Hint: Develop a modified version of the Lagrange.m function from Figure 17.9 in the textbook, which stores the needed Lagrange coefficients, L_i(y). Notice that Lagrange weighting factors are larger near y = 55,000 m.
Given Code Need Matlab Fuction
function [g,b,L]=Chapra_17p19()
%% Output
% g: gravitational constant at 55,000 m (scalar)
% b: Newton polynomial coefficients (5-by-1 row vector)
% L: Lagrange polynomial coefficients (5-by-1 row vector)
%% Write your code here.
end
Explanation / Answer
The given question lacks a lot of information and variable references, Though, based on the intuitive understanding we have attempted to translate the requested code to matlab code as the following,
%========================================================
function [<enter the list of output variables here>]=Chapra_17p19(g,x,n)
sum =0 ;
for i=1:n
product=g(i);
for j=1:n
if ne(i,j)
product=product*(xx - x(j))/(x(i)-x(j);
end
end
sum=sum+product;
end
%====================================================
User is requested to introduce the required output vriable accordingly to get the desired set of variables. In case of any further clarification please comment!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.