BeginPackage["Interpol2`"];
Interpol2::usage="Interpol2[x,data]
returns the value of the piecewise quadratic interpolation function,
determined by the given data"; 
DInterpol2::usage="DInterpol2[x,data]
returns the value of the derivative of the piecewise quadratic interpolation 
function, determined by the given data"; 

Begin["`Private`"];
Interpol2[x_,data_]:= Module[{xp,yp,pos,f},
		{xp,yp}=Transpose[data];
	pos=Floor[(Length[Select[xp,(#<=x)&]]+1)/2];
	f=Interpolation[data[[{2*pos-1,2*pos,2*pos+1}]],InterpolationOrder -> 2];
	f[x]]
DInterpol2[x_,data_]:= Module[{xp,yp,pos,f},
		{xp,yp}=Transpose[data];
	pos=Floor[(Length[Select[xp,(#<=x)&]]+1)/2];
	f=Interpolation[data[[{2*pos-1,2*pos,2*pos+1}]],InterpolationOrder -> 2];
	f'[x]]
End[];
EndPackage[];
