n=20;
h=1/(n+1);
x=linspace(h,1-h,n);


c= -ones(n,1); %c(1) = 0, brauch ma net
e=c;
d=2*ones(n,1);
b = sin(pi*x)/(n+1)^2;

e(1) = e(1)/d(1); %initialisation
b(1) = b(1)/d(1);

for i=2:n  %elimination: overwrites e-vector
    e(i) =e(i)/(d(i)-c(i)*e(i-1));
      b(i) =(b(i)-c(i)*b(i-1))/(d(i)-c(i)*e(i-1));
end
%Backsubstitution: Solution overwrites b-vector
for i= n-1: -1:1
    b(i) = b(i)-e(i)*b(i+1);
    
end

exact = sin(pi*x)/pi^2;
plot(x,b-exact)