function showspline ( )
%
%% showspline() illustrates CubicSpline with various end conditions,
% some not so good.

  fprintf ( 1, '\n' );
  fprintf ( 1, 'showspline()\n' );

  xvals = linspace(0,4*pi,100);
  yvals = sin(xvals);
  
  for n = 4:3:16
     x = linspace(0,4*pi,n)';
     y = sin(x);
     [a,b,c,d] = CubicSpline(x,y,1,1,1);
     svals = pwCEval(a,b,c,d,x,xvals);
     plot(xvals,yvals,xvals,svals)
     title(sprintf('''Good'' Complete spline interpolant of sin(x). (%2.0f subintervals)',n-1))
    filename = sprintf ( 'showspline_good_%d.png', n );
    print ( '-dpng', filename );
    fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%    pause(1)
  end

  for n = 4:3:16
     x = linspace(0,4*pi,n)';
     y = sin(x);
     [a,b,c,d] = CubicSpline(x,y,1,-1,-1);
     svals = pwCEval(a,b,c,d,x,xvals);
     plot(xvals,yvals,xvals,svals)
     title(sprintf('''Bad'' Complete spline interpolant of sin(x). (%2.0f subintervals)',n-1))
    filename = sprintf ( 'showspline_bad_%d.png', n );
    print ( '-dpng', filename );
    fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%    pause(1)
  end

  for n = 4:3:16
     x = linspace(0,4*pi,n)';
     y = sin(x);
     [a,b,c,d] = CubicSpline(x,y,2,0,0);
     svals = pwCEval(a,b,c,d,x,xvals);
     plot(xvals,yvals,xvals,svals)
     title(sprintf('Natural spline interpolant of sin(x). (%2.0f subintervals)',n-1))
    filename = sprintf ( 'showspline_natural_%d.png', n );
    print ( '-dpng', filename );
    fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%    pause(1)
  end

  for n = 4:3:16
     x = linspace(0,4*pi,n)';
     y = sin(x);
     [a,b,c,d] = CubicSpline(x,y);
     svals = pwCEval(a,b,c,d,x,xvals);
     plot(xvals,yvals,xvals,svals)
     title(sprintf('Not-a-Knot spline interpolant of sin(x). (%2.0f    subintervals)',n-1))
    filename = sprintf ( 'showspline_notaknot_%d.png', n );
    print ( '-dpng', filename );
    fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%    pause(1)
  end

  return
end

