%This function provides a linear approximation for a function fx
%at the point x.  The user must supply the points x1 and x2 around the
%point x.The user must also supply the value of the function at x1 and x2
%fx1 and fx2.  Our output will be the point x and the linear interpolated
%value fhat. Written by Philip Shaw, Fordham University 2022.

function[fhat,x]=lip(x1,x2,fx1,fx2,x)

%compute the interpolated value below
fhat=fx1+((fx2-fx1)/(x2-x1))*(x-x1); %predicted value 