%demo1 solves u"=1, u(0)=0, u(1)=1
N=4;
dx=1/(N-1);
ex1=inline('0.5*x.*(x+1)','x');
x=0:dx:1;
Dx=diff(x');
u=0*x';u(N)=1;
A=diag(-2*ones(N-2,1),0)+diag(ones(N-3,1),1)+diag(ones(N-3,1),-1);
b=-u(3:end);b=b+dx^2*ones(N-2,1);%Dx(1:end-1).^2;
u(2:N-1)=A\b;
%plot(x,u,'k-o',x,0.5*x.*(x+1),'s--r','markerfacecolor','k')
plot(x,u,'k-o',x,ex1(x),'s--r','markerfacecolor','k')
xlabel('x');ylabel(' u(x)')
title(' FD solution with zero forcing ')