function P3()
% Checks out Cubic values
% generate a random cubic...
a = randn(4,1);
% Sample it across [-2 2]
h = .01;
x0 = -2;
n = 401;

% Generate the first 4 values and turn it over to CubicValues...
p = [c(x0,a) c(x0+h,a) c(x0+2*h,a) c(x0+3*h,a)]';
q = CubicValues(p,n);

% Plot using q and a more conventional approach
x = linspace(x0,x0+(n-1)*h,n)';
plot(x,q,'c',x,c(x,a),'m')
title(sprintf('max(abs(q-c(x,a))) = %10.3e ',max(abs(q-c(x,a)))),'fontsize',14)
shg

function y = c(x,a)
y = ((a(4)*x+a(3)).*x+a(2)).*x + a(1);