(a)
(b)
(c)
If then .
If then .
(d)
Setting for the first cubic polynomial
(a)
(b)
(c)
(d) Since there are four data points, the (47) gets supplemented with
The solution of these equations are given by
(a) Construct a cubic polynomial
and choose distinct points: . Furthermore, construct points .Then the cubic polynomial (48) is a global interpolation polynomial for the points with .
Does constitutes a cubic spline for these points? Note that
As we learned in class, the cubic spline has a freedom to have two additional conditions. Choosing the clamped spline will specify the derivatives at the beginning and the end. In other words, it will require that and be given. Note that .
Therefore does represent the clamped cubic spline interpolating points for .
Requirement of to be a natural cubic spline means that This requirement translates into . Therefore if , the does constitutes a natural cubic spline. If , then is not a natural cubic spline.
figure(1) X = [0, 0.005, 0.0075, 0.0125, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,0.9, 1.0]; Yu = [0, 0.0102, 0.0134, 0.017, 0.025, 0.0376, 0.0563, 0.0812, 0.0962, 0.1035,0.1033, 0.095, 0.0802, 0.0597, 0.034, 0]; Yl = [0, -0.0052, -0.0064, -0.0063, -0.0064, -0.006, -0.0045, -0.0016, 0.001, 0.0036, 0.007, 0.0121, 0.017, 0.0199, 0.0178 , 0]; x = linspace(0,1,100);yu=spline(X,Yu,x);yl=spline(X,Yl,x); scatter(X,Yl,'filled'); hold on scatter(X,Yu,'filled'); plot(x,yu);hold on; plot(x,yl);hold on; title('airfoil, spline interpolation'); legend('lower','upper','spline1','spline2');
(b)
To build the global polynomial interpolation, let us construct Vandermonde matrix as follows:
A = [X.^0; X;X.^2;X.^3;X.^4;X.^5;X.^6;X.^7;X.^8;X.^9;X.^10;X.^11;X.^12;X.^13;X.^14;X.^15]
This matrix has a condition number about , therefore no global polynomial interpolation is possible for these points. Attempts to make "Matlab Divide" of by leads to values of , and the resulting interpolation function oscillates to between the data points.
figure(1) X = [0:2:24] Y = [ 59 56 53 54 60 67 72 74 75 74 70 65 61] x=linspace(0,24,100); L = polyfit(X,Y,12); T1 =polyval(L,x); scatter(X,Y,'filled');hold on plot(x,T1,'-r'); T2 = spline(X,Y,x);hold on plot(x,T2,'-b');hold off legend('Temperature','global polynomial','spline'); title('Temperature in Troy NY');
Here we used global polynomial interpolation, not Lagrange interpolation. While there are routines for Matlab Lagrange interpolation, the resulting graph is the same. Similarly, we used the spline as oppose to B spline, because the resulting interpolating function is the same.
We observe that spline interpolation is "better" or more physical, as a polynomial interpolation generates wiggles which are unlikely to occur in the temperature dynamic over a single day.
We observe on the Figure 5.23 that the second derivative infinity norm is about 1, i.e. , and that the fourth derivative infinity norm is about 3, i.e. .
a) How many data points for piecewise linear interpolation are needed to guarantee the error is less than ?
According to the Theorem 5.4, the maximum error of PW linear interpolation is given by
(b) How many data points for a clamped cubic spline are needed to guarantee the error is less than ?
According to the Theorem 5.5 the maximum error of the clamped cubic spline interpolation is given by