





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






1. Piecewise-Cubic Spline Interpolation a. Piecewise-Polynomial Approximation b. Spline c. Cubic Spline Interpolation i. Figure 1 2. Problems 3. generate_spline a. MATLAB Code 4. Problem 1 a. MATLAB Code b. Generated Graph i. Figure 2 5. Problem 2 a. MATLAB Code b. Generated Graphs i. Figure 3 ii. Figure 4 iii. Figure 5 iv. Figure 6
The techniques earlier used for interpolation were the approximations of arbitrary functions on closed intervals by the use of polynomials. However we experienced two problems there:
The oscillatory nature of high degree polynomials and The property that a function over a small portion of the interval can induce large fluctuations over the entire range restricts their use.
Piecewise-Polynomial Approximation:
An alternative approach is to divide the interval into a collection of subintervals and construct a different approximating polynomial on each subinterval. Approximation of functions by this type is called piecewise-polynomial approximation.
Spline:
A piecewise polynomial function that can have a locally very simple form, yet at the same time be globally flexible and smooth. Splines are very useful for modeling arbitrary functions, and are used extensively in computer graphics.
Cubic Spline Interpolation:
We start from a table of points [xi,yi] for i = 0,1, … n , for the function y = f(x). That makes n+1 points and n intervals between them. The cubic spline interpolation is a piecewise continuous curve, passing through each of the values in the table. There is a separate cubic polynomial for each interval, each with its own coefficients:
A cubic spline is a spline constructed of piecewise third-order polynomials which pass through a set of control points. The second derivative of each polynomial is commonly set to zero at the endpoints, since this provides a boundary condition that completes the system of equations. This produces a so-called "natural" cubic spline and leads to a simple tridiagonal system which can be solved easily to give the coefficients of the polynomials. (^) Figure 1:
l(i) = 2(x(i+1)-x(i-1)) - (h(i-1)u(i-1));
u(i) = h(i)/l(i);
z(i) = (alpha(i)-(h(i-1)*z(i-1)))/l(i);
end
% Step 5:
l(n) = 1;
z(n) = 0;
c(n) = 0;
% Step 6:
for j = n-1:-1:
c(j) = z(j) - (u(j)*c(j+1));
b(j) = ((a(j+1) - a(j))/h(j)) - h(j)(c(j+1)+2c(j))/3;
d(j) = (c(j+1)-c(j))/(3*h(j));
end
% Step 7:
s = [];
for i=1:n-
xx = x(i):0.001:(x(i+1)-0.001);
s = [s a(i)+b(i)(xx-x(i))+c(i)(xx-x(i)).^2+d(i)*(xx-x(i)).^3];
end
Regenerate the data points given in table 3.16 using algorithm 3.4 and its polynomial approximation (See example 1(ruddy duck in flight) page 149).
% Values from Table: x = [0.9 1.3 1.9 2.1 2.6 3.0 3.9 4.4 4.7 5.0 6.0 7.0 8.0 9.2 10.5 11.3 11.6 12.0 12.6 13.0 13.3];
a = [1.3 1.5 1.85 2.1 2.6 2.7 2.4 2.15 2.05 2.1 2.25 2.3 2.25 1.95 1.4 0.9 0.7 0.6 0.5 0.4 0.25];
n = 21;
% Function Call:
s = generate_spline(n,x,a);
plot(s), title('Natural Spline Plot For Problem # 1')
Figure 2 :
figure, plot(s3), title(‘curve 3 ’)
% Concatenating the three curves:
s = [s1 s2 s3];
figure, plot(s), title(‘Upper portion of the Nobel Beast’)
Figure 3 :
Figure 4 :
Figure 5 :