Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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 »
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 a
ays 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 XXXXXXXXXX
y XXXXXXXXXX XXXXXXXXXX
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 XXXXXXXXXX
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 XXXXXXXXXX
y XXXXXXXXXX XXXXXXXXXX
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 ca
on 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 XXXXXXXXXX
y XXXXXXXXXX XXXXXXXXXX
with the following boundary condition
S′(−55) = 0.1, S′(65) = 0.3
Ca
y 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 XXXXXXXXXX
y XXXXXXXXXX XXXXXXXXXX
with the following boundary condition
S′′(−55) = 0.1, S′′(65) = 0
Ca
y out the specified computations to fill in the following table:
t S(t) S′(t) S′′(t)
15.5
19
Answered Same Day Oct 12, 2021

Solution

Rahul answered on Oct 14 2021
135 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