Exercises for Chapter 3: 1. (a) Implement the Matlab functions IntPoly.m and IntPoly_d.m for the interpolation polynomial and its derivative such that their interfaces are as follows: function p =...

1 answer below »
just problem 1 2 3 4.( problem 5 is not included)


Exercises for Chapter 3: 1. (a) Implement the Matlab functions IntPoly.m and IntPoly_d.m for the interpolation polynomial and its derivative such that their interfaces are as follows: function p = IntPoly(t, x, y) function p = IntPoly_d(t, x, y) here x, y are arrays for the given data, p is the interpolation polynomial evaluated at t. (b) Then apply these Matlab functions to the interpolation polynomial Π4(t) determined by the following data x -55 -25 5 35 65 y -3.25 -3.2 -3.02 -3.32 -3.1 Present your computations in a table as follows: t Π4(t) Π ′ 4(t) 20.25 2. (a) Implement the Matlab function for the k-th Lagrange characteristics polynomial φn,k(x) or its first derivative φ′n,k(x) such that its interface is as follows: function f = lagrange_char(x, x_nodes, k, d_order) where x_nodes is the vector representing the given n+ 1 nodes: x0 < x1="">< x2="">< ·="" ·="" ·="">< xn (b) then, apply your code to the following nodes: x -55 -25 5 35 65 present your computational results in a table as follows: φ2(17.5) φ′2(17.5) φ5(17.5) φ′5(17.5) 3. (a) implement the lagrange method for the interpolation polynomial such that it have the following interface: function p = intpoly_lag(t, x, y, d_order) where t is variable of the interpolation polynomial, x and y provide the data for interpolation, and d_order is the derivative of the interpolation polynomial. this function should employ lagrange_char.m created in the previous problem. (b) apply intpoly_lag.m to the interpolation polynomial π4(t) determined by the following data: x -55 -25 5 35 65 y -3.25 -3.2 -3.02 -3.32 -3.1 present your computations in a table as follows: 18 t π4(t) π ′ 4(t) 17.25 4. let p4(x) be the interpolation polynomial constructed with the temperature data (given in table 3.1 in the textbook) at latitudes −55,−25,−5, 25, 55 for the carbon acid concentration k = 1.5. (a) assume we used newton’s method to solve p4(x)−3.225 = 0 starting from x(0) = −25. compute x(2) in newton’s iteration and present numerical results in the following table: x(2) p4(x (2)) p ′4(x (2)) (b) find the latitude where the temperature is 3.225 by solving p4(x) − 3.225 = 0 with newton’s method. present numerical results in the following table: latitude x(0) used num. of iterations use more rows in the table above to present results if more latitudes are found. also, present the matlab script for computing the first zero listed in the table above 5. (a) implement the matlab function for the cubic spline interpolation s(t) for the given x-y data such that the interface of this function is as follows: function s = intpoly_cs(t, x, y, bdata, conds, d_order) (b) let s(t) be the cubic spline interpolation for the following data x -55 -25 5 35 65 y -3.25 -3.2 -3.02 -3.32 -3.1 with the following boundary condition s′(−55) = 0.1, s′(65) = 0.3 carry out the specified computations to fill in the following table: t s(t) s′(t) s′′(t) 17.25 (c) let s(t) be the cubic spline interpolation for the following data x -55 -25 5 35 65 y -3.25 -3.2 -3.02 -3.32 -3.1 with the following boundary condition s′′(−55) = 0.1, s′′(65) = 0 carry out the specified computations to fill in the following table: t s(t) s′(t) s′′(t) 15.5 19 xn="" (b)="" then,="" apply="" your="" code="" to="" the="" following="" nodes:="" x="" -55="" -25="" 5="" 35="" 65="" present="" your="" computational="" results="" in="" a="" table="" as="" follows:="" φ2(17.5)="" φ′2(17.5)="" φ5(17.5)="" φ′5(17.5)="" 3.="" (a)="" implement="" the="" lagrange="" method="" for="" the="" interpolation="" polynomial="" such="" that="" it="" have="" the="" following="" interface:="" function="" p="IntPoly_Lag(t," x,="" y,="" d_order)="" where="" t="" is="" variable="" of="" the="" interpolation="" polynomial,="" x="" and="" y="" provide="" the="" data="" for="" interpolation,="" and="" d_order="" is="" the="" derivative="" of="" the="" interpolation="" polynomial.="" this="" function="" should="" employ="" lagrange_char.m="" created="" in="" the="" previous="" problem.="" (b)="" apply="" intpoly_lag.m="" to="" the="" interpolation="" polynomial="" π4(t)="" determined="" by="" the="" following="" data:="" x="" -55="" -25="" 5="" 35="" 65="" y="" -3.25="" -3.2="" -3.02="" -3.32="" -3.1="" present="" your="" computations="" in="" a="" table="" as="" follows:="" 18="" t="" π4(t)="" π="" ′="" 4(t)="" 17.25="" 4.="" let="" p4(x)="" be="" the="" interpolation="" polynomial="" constructed="" with="" the="" temperature="" data="" (given="" in="" table="" 3.1="" in="" the="" textbook)="" at="" latitudes="" −55,−25,−5,="" 25,="" 55="" for="" the="" carbon="" acid="" concentration="" k="1.5." (a)="" assume="" we="" used="" newton’s="" method="" to="" solve="" p4(x)−3.225="0" starting="" from="" x(0)="−25." compute="" x(2)="" in="" newton’s="" iteration="" and="" present="" numerical="" results="" in="" the="" following="" table:="" x(2)="" p4(x="" (2))="" p="" ′4(x="" (2))="" (b)="" find="" the="" latitude="" where="" the="" temperature="" is="" 3.225="" by="" solving="" p4(x)="" −="" 3.225="0" with="" newton’s="" method.="" present="" numerical="" results="" in="" the="" following="" table:="" latitude="" x(0)="" used="" num.="" of="" iterations="" use="" more="" rows="" in="" the="" table="" above="" to="" present="" results="" if="" more="" latitudes="" are="" found.="" also,="" present="" the="" matlab="" script="" for="" computing="" the="" first="" zero="" listed="" in="" the="" table="" above="" 5.="" (a)="" implement="" the="" matlab="" function="" for="" the="" cubic="" spline="" interpolation="" s(t)="" for="" the="" given="" x-y="" data="" such="" that="" the="" interface="" of="" this="" function="" is="" as="" follows:="" function="" s="IntPoly_cs(t," x,="" y,="" bdata,="" conds,="" d_order)="" (b)="" let="" s(t)="" be="" the="" cubic="" spline="" interpolation="" for="" the="" following="" data="" x="" -55="" -25="" 5="" 35="" 65="" y="" -3.25="" -3.2="" -3.02="" -3.32="" -3.1="" with="" the="" following="" boundary="" condition="" s′(−55)="0.1," s′(65)="0.3" carry="" out="" the="" specified="" computations="" to="" fill="" in="" the="" following="" table:="" t="" s(t)="" s′(t)="" s′′(t)="" 17.25="" (c)="" let="" s(t)="" be="" the="" cubic="" spline="" interpolation="" for="" the="" following="" data="" x="" -55="" -25="" 5="" 35="" 65="" y="" -3.25="" -3.2="" -3.02="" -3.32="" -3.1="" with="" the="" following="" boundary="" condition="" s′′(−55)="0.1," s′′(65)="0" carry="" out="" the="" specified="" computations="" to="" fill="" in="" the="" following="" table:="" t="" s(t)="" s′(t)="" s′′(t)="" 15.5="">
Answered Same DayOct 12, 2021

Answer To: Exercises for Chapter 3: 1. (a) Implement the Matlab functions IntPoly.m and IntPoly_d.m for the...

Rahul answered on Oct 14 2021
144 Votes
Matlab_141020/intpoly.m
function p = intpoly(t,x,y)
% x = [-55,-25,5,35,65];
% y = [-3.25,-3.2,-3
.02,-3.1];
% t = 20.54;
n = length(x);
a = min(x);b = max(x);
w_1 = ones(n,1);
c = 4/(b-a);
for j_1 = 1:n
for k = 1:j_1-1
w_1(j_1) = w_1(j_1)*(x(j_1)-x(k))*c;
end
for k_1 = j_1+1:n
w_1(j_1) = w_1(j_1)*(x(j_1) - x(k_1))*c;
end
end
w_1 = 1./w_1;
nu = zeros(size(t));
d = nu;
ex = nu;
for j_2 = 1:nu
xdiff = t - x(j_2);
wx = w_1(j_2)./xdiff;
d = d + wx;nu = nu + wx*y(j_2);
ex(xdiff==0) = j_2;
end
p = nu./d;
for i = 1:length(t)
if ex(i)>0
p(i) = y(ex(i));
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here