clear all; close all;
%------------------- demo_fh.m --------------------------------
% This script returns the interpolation error in the
% sup norm made with the F-H interpolant on [-5,5], 
% and the plots of the function f and its F-H interpolant.
% 
% Functions called: fh
% 
%----------------------------------------------------------------
% Authors
%
%      Stefano De Marchi and Cinzia Bandiziol
%      Department of Mathematics
%      University of Padova
%        
% Version: May 2015		
%------------------------------------------------------------------			

n=10;       % number of interpolation points
d=3;        % blending parameter
a=-5; b=5;  % endpoints

x=linspace(a,b,n)';  %interpolation points

% definition of the function to be interpolated

f=inline('1./(1+x.^(2))','x');
%f=inline('abs(x)','x');
%f=inline('sin(x)','x');  
y=feval(f,x);

xi=linspace(-5,5,90)';
yi_exact=feval(f,xi);

[yi,w]=fh(x,y,xi,d);
Err=norm(yi_exact - yi,Inf)  % error in the sup norm


plot(xi,yi_exact,'-b', xi,yi,'-m')
legend('function', 'interpolant');