ndiv=500;
length=1;
h=length/ndiv;
v=ones(ndiv-1,1);
a=-(2-h^2)*eye(ndiv)+diag(v,1)+diag(v,-1);
a(ndiv,ndiv-1)=2;
b=zeros(ndiv,1);
b(1)=-1;
y=a\b;
x=h:h:length;
plot(x,y)
analyt=tan(1)*sin(x)+cos(x);
error=abs(analyt'-y);
max(error)

