Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The goal of this problem is to draw mount Everest with the help of natural cubic splines. We have a rather poor quality photo of

The goal of this problem is to draw mount Everest with the help of natural cubic splines. We have a rather poor quality photo of the mountain profile, which is given below.

2

You need to set up a coordinate system, and select a set of knots along the edge of the

mountain, and find the coordinates for all these interpolating points. We are aware that

the mountain profiles are not very clear in that photo, so please use your imagination

when you find these approximate points. You may either print out the mountain picture

and work on it on a piece of paper, or send the image to some software and locate the

coordinates of the interpolating points. Make sure to select at least 20 points. You may use more points if you see fit.

After you have generated your data set, you need to find a natural cubic spline inter- polation. Use the functions cspline and cspline_eval , which are available in Section

3.4. Read these two functions carefully, try to understand them before using them. Does it look like there is a smaller peak on the right? Does the peak look rather sharp?

How would you deal with this situation, knowing that a single cubic spline function will generate a smoothest possible interpolation?

image text in transcribed

function S = cspline_eval(t,y,z,x_vec)

% function S = cspline_eval(t,y,z,x_vec)

% compute the value of the natural cubic spline at the points x_vec when

% t,y,z are given

%

% Example: t = [0.9,1.3,1.9,2.1];

% y = [1.3,1.5,1.85,2.1]

% z = cspline(t,y)

% x = [0.9:0.1:2.1]

% v = cspline_eval(t,y,z,x)

m = length(x_vec);

S = zeros(size(x_vec));

n = length(t);

for j=1:m

x = x_vec(j);

for i=n-1:-1:1

if (x-t(i)) >= 0

break

end

end

h = t(i+1)-t(i);

S(j) = z(i+1)/(6*h)*(x-t(i))^3-z(i)/(6*h)*(x-t(i+1))^3 ...

+(y(i+1)/h-z(i+1)*h/6)*(x-t(i)) - (y(i)/h-z(i)*h/6)*(x-t(i+1));

end

image text in transcribed

function z = cspline(t,y)

% function z = cspline(t,y)

% compute z-coefficients for natural cubic spline

% where t is a vector with knots, and y is the interpolating values

% z is the output vector

n = length(t);

z = zeros(n,1);

h = zeros(n-1,1);

b = zeros(n-1,1);

u = zeros(n,1);

v = zeros(n,1);

h = t(2:n)-t(1:n-1);

b = (y(2:n)-y(1:n-1))./h;

u(2) = 2*(h(1)+h(2));

v(2) = 6*(b(2)-b(1));

for i=3:n-1 % solve the tri-diag system

u(i) = 2*(h(i)+h(i-1))-h(i-1)^2/u(i-1);

v(i) = 6*(b(i)-b(i-1))-h(i-1)*v(i-1)/u(i-1);

end

for i=n-1:-1:2

z(i) = (v(i)-h(i)*z(i+1))/u(i);

end

image text in transcribed

cspline eval.m function S = cspline-e va l ( t, y, z , x-vec) % function S = cspline-eval(t, y, z, x-vec) s compute the va Lue of the naturaL cubic spline at the points x_vec When % t, y, z are given Example: t= [0.9,1.3,1.9,2.1]; zcspline(t,y) x [0.9:0.1:2.1] v = cspline-eval(t,y,z,x) m = length(x-vec) ; S zeros(size(x-vec)); nlength(t) for j=1:m for i=n-1:-1:1 if (x-t ( i) ) break >= 0 end end end cspline.m function z = cspline(t,y) % function z cspline (t,y) % compute z-coefficients for natural cubic spline % where t is a vector with knots, and y is the interpolating values % z is the output vector n = length(t); z - zeros(n,1) hzeros (n-1,1); bzeros (n-1,1); u-zeros (n,1) v-zeros (n,1) h t (2:n)-t(1:n-1); for 1-3:n-1 % solve the tri-diag system end for i=n-1 :-1 :2 end You need to set up a coordinate system, and select a set of knots along the edge of the mountain, and find the coordinates for all these interpolating points. We are aware that the mountain profiles are not very clear in that photo, so please use your imagination when you find these approximate points. You may cither print out the mountain picture and work on it on a piece of paper, or send the image to some software and locate the coordinates of the interpolating points. Make sure to select at least 20 points. You may use more points if you see fit. After you have generated your data set, you ned to find a natural cubic spline inter- polation. Use the functions cspline and cspline_eval, which are available in Section 3.4. Read these two functions carefully, try to understand them before using them. Does it look like there is a smaller peak on the right? Does the peak look rather sharp? How would you deal with this situation, knowing that a single cubic spline function will generate a "smoothest" possible interpolation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started