# Polynomial cardinal functionsΒΆ

In Poor conditioning in polynomial interpolation and Piecewise polynomial interpolation we saw a big difference between polynomial interpolation and piecewise polynomial interpolation of some arbitrarily chosen data. The same effects can be seen clearly in the cardinal functions.

using FundamentalsNumericalComputation

n = 18
t = range(-1,stop=1,length=n+1)
y = [zeros(9);1;zeros(n-9)];  # data for 10th cardinal function

scatter(t,y,label="data")

S = FNC.spinterp(t,y)
plot!(S,-1,1,label="spline",
xlabel="x", ylabel="p(x)", title="Piecewise cubic cardinal function")


The piecewise cubic cardinal function is nowhere greater than one in absolute value. This happens to be true for all the cardinal functions, ensuring a good condition number for the interpolation. But the story for global polynomials is very different.

scatter(t,y,label="data")

p = fit(t,y,n)
x = LinRange(-1,1,1000)  # force a lot of points
plot!(x,p.(x),label="polynomial",
xlabel="x", ylabel="p(x)", title="Polynomial cardinal function")


From the figure we can see that the condition number for polynomial interpolation on these nodes is at least 500.