%Program that loops over values in x using our lip.m file to
%implement linear interpolation.
clear all
x1=.80;
x2=1.2;
fx1=log(x1);
fx2=log(x2);
step=.0001; %step between grid points
xlb=x1+step; %lower bound of grid
xub=x2-step; %upper bound of grid
x=[xlb:step:xub]';
tic 
for i=1:length(x)
    [fhat(i,1),xpoint(i,1)]=lip(x1,x2,fx1,fx2,x(i));
end

display('Time to Completion in Secs (Loop)')
toc
tic
[fhatvec,xvec]=lipvec(x1,x2,fx1,fx2,x);
display('Time to Completion in Secs (Vec)')

toc
%plot interpolated and actual values below
plot(x,fhat,x,log(x))
title('Real Function versus Interpolated Values')
legend('fhat','f(x)')
xlabel('x')
ylabel('fhat,f(x)')

