My assignment is to interpolate the sin function using 10 points of the function with 6 decimal correct places with polynomials and splines. The polynomial interpolation gave me at worst 4 correct decimal places, while the splines gave me at worst 2 correct decimal places. Can that happen given a specific set of points or is my implementation wrong?
Here are the points:
x(1, 1) = 0;
x(2, 1) = 0.203056;
x(3, 1) = 0.267584;
x(4, 1) = 0.379246;
x(5, 1) = 0.527854;
x(6, 1) = 0.713500;
x(7, 1) = 0.916740;
x(8, 1) = 1.087621;
x(9, 1) = 1.274532;
x(10, 1) = 1.570796;
y(1, 1) = 0;
y(2, 1) = 0.201663;
y(3, 1) = 0.264402;
y(4, 1) = 0.370220;
y(5, 1) = 0.503681;
y(6, 1) = 0.654484;
y(7, 1) = 0.793622;
y(8, 1) = 0.885524;
y(9, 1) = 0.956434;
y(10, 1) = 1;
If your original function is a polynomial of degree 4 or higher, then polynomial interpolation will give you zero approximation error, but cubic spline interpolation will give a non-zero error. So, in this particular case, the polynomial method will certainly work better.
Polynomial interpolation isn't as bad as many people say, and you shouldn't expect that it will always behave poorly. You'll get oscillation problems if you do interpolation using equally spaced nodes, but not if you use Chebyshev nodes. There's a good discussion of these matters in Trefethen's book, Approximation Theory and Approximation Practice.