Question

In Matlab, Construct the natural cubic spline (see the LiveScript) to interpolate the Runge funct...

In Matlab,

Construct the natural cubic spline (see the LiveScript) to interpolate the Runge function (see Homework 6) using 10, 15, 20, and 25 equispaced nodes.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Code:

close all
clear
clc

xx = linspace(-1, 1, 1000);
yy = 1 ./ (1 + 25*xx.^2);
figure, hold on
plot(xx, yy), xlabel('x'), ylabel('f(x)')
title('Cubic Spline Interpolation')

N = [10 15 20 25];
for i = 1:length(N)
n = N(i);
x = linspace(-1, 1, n);
f = 1 ./ (1 + 25*x.^2);
yy = spline(x, f, xx);
plot(xx, yy)
end
legend('Actual Function', 'N = 10 nodes', 'N = 15 nodes', 'N = 20 nodes', 'N = 25 nodes')

Plots:

Cubic Spline Interpolation N-15 nodes N 20 nodes 80s 0.3

Zoomed versions of the above plot:

Cubic Spline Interpolation N-15 nodes N 20 nodes 0.85 08 0.75 0.1 0.1 ง.05Cubic Spline Interpolation N-15 nodes N 20 nodes 0.79 0.78 0.77 0.78 0.76 0.74 0.73 0.72 0.09 0.125 0.1

Add a comment
Know the answer?
Add Answer to:
In Matlab, Construct the natural cubic spline (see the LiveScript) to interpolate the Runge funct...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a MATLAB code to construct a natural cubic spline P(x) that passes though the points...

    Design a MATLAB code to construct a natural cubic spline P(x) that passes though the points (1, 1), (4, 1/4), (7, 1/7), (10, 1/10), (13, 1/13) and (16, 1/16). (a) Use the constructed cubic spline to interpolate x = 3; (b) Find the error e_1 = |1/3 - P(3)|;

  • Problem 3: Write a MATLAB function called cubic_spline to compute the natural cubic spline for a...

    Problem 3: Write a MATLAB function called cubic_spline to compute the natural cubic spline for a given data set. The x and y data points and the rdesired values (a vector) should be the inputs, and the corresponding ydesired values (a vector) should be the output.

  • QUESTION 4 (10) (a) A natural cubic spline that fits the data given by f(3.0) =...

    QUESTION 4 (10) (a) A natural cubic spline that fits the data given by f(3.0) = -5.6790, f(3.1) = -3.6674, f(3.2) = -2.2178 is to be constructed. Write down explicitly the system of equations that need to be used to construct the required natural cubic spline. (b) Consider the nonlinear system (10) 2+y=9, 22 + y2 = 25, 2,y> 0. Perform one iteration of Newton's method to approximate the solution, starting with (2, 4) as the initial solution. [20]

  • QUESTION 4 (10) (a) A natural cubic spline that fits the data given by f(3.0) =...

    QUESTION 4 (10) (a) A natural cubic spline that fits the data given by f(3.0) = -5.6790, (3.1) = -3.6674, f(3.2) = -2.2178 is to be constructed. Write down explicitly the system of equations that need to be used to construct the required natural cubic spline.

  • its a numerical analysis question QUESTION 4 (a) A natural cubic spline that fits the data...

    its a numerical analysis question QUESTION 4 (a) A natural cubic spline that fits the data given by (10) f(3.0) = -5.6790, f(3.1) = -3.6674, f(3.2) = -2.2178 is to be constructed. Write down explicitly the system of equations that need to be used to construct the required natural cubic spline. (b) Consider the nonlinear system (10) z+ y = 9, 1² + y2 = 25, 2, y > 0. Perform one iteration of Newton's method to approximate the solution,...

  • Natural Cubic spline If the and Derivatives at the endpoints are known, ine. Pi" (x)= Y,...

    Natural Cubic spline If the and Derivatives at the endpoints are known, ine. Pi" (x)= Y, 4 and Puni (xu) z Yu" for some numbers y," and ya theni 25, + z = 3y[x, 1x23 - į sxy," (al Sunit zou z 3y [xn-1 , xu] + & Sx uni Yu" (6) 10 Derive equations (a) and (b) for the natural cubic Spline

  • QUESTION 4 (a) A natural cubic spline that fits the data given by f(3.0) = -5.6790,...

    QUESTION 4 (a) A natural cubic spline that fits the data given by f(3.0) = -5.6790, F (3.1) = -3.6674, f(3.2) = -2.2178 is to be constructed. Write down explicitly the system of equations that need to be used to construct the required natural cubic spline. (b) Consider the nonlinear system x2 + y = 9, 22 + y2 = 25, x, y > 0. Perform one iteration of Newton's method to approximate the solution, starting with (2, 4) as...

  • Linear Algebra A natural cubic spline for a function f(x) is defined by ſax° +15x² –...

    Linear Algebra A natural cubic spline for a function f(x) is defined by ſax° +15x² – 21.75x +14.5 15x521 S(x) = ayx? + 3x² + 2.25x-1.5 25 x 3] Find the value of a1.

  • 10-16 DETERMINATION OF SPLINES Find the cubic spline g(x) for the given data with ko and...

    10-16 DETERMINATION OF SPLINES Find the cubic spline g(x) for the given data with ko and kn as given. using MATLAB. 15. fo f(O)4, fi = f(2) 0, f3f(6) 80, ko= k3 = 0 f2 f(4) 4 10-16 DETERMINATION OF SPLINES Find the cubic spline g(x) for the given data with ko and kn as given. using MATLAB. 15. fo f(O)4, fi = f(2) 0, f3f(6) 80, ko= k3 = 0 f2 f(4) 4

  • Consider polynomial interpolation of the function f(x)=1/(1+25x^2) on the interval [-1,1] by (1) ...

    Consider polynomial interpolation of the function f(x)=1/(1+25x^2) on the interval [-1,1] by (1) an interpolating polynomial determined by m equidistant interpolation points, (2) an interpolating polynomial determined by interpolation at the m zeros of the Chebyshev polynomial T_m(x), and (3) by interpolating by cubic splines instead of by a polynomial. Estimate the approximation error by evaluation max_i |f(z_i)-p(z_i)| for many points z_i on [-1,1]. For instance, you could use 10m points z_i. The cubic spline interpolant can be determined in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT