clear;

for i=1:5

n=10*(2^(i-1))-1;
h=1/(n+1);

nodes=((0:(n+1)).')*h;

exactsol=sol217(nodes);

maind=diag(ones(n,1));
lowd=diag(ones(n-1,1),-1);
uppd=diag(ones(n-1,1),1);

A=(-lowd+2*maind-uppd);

discret=((1:(n)).')*h;
b=h^2*f217(discret);

solvect=A\b;
solution=[0;solvect;0];

H(i)=h;
error(i)=max(abs(solution-exactsol));
estimate(i)=10^4*h^2/96;

hold on;
if i==1
plot((0:n+1).'*h,exactsol,'r');
plot((0:n+1).'*h,solution,'g*');
end
if i==2
plot((0:n+1).'*h,solution,'bx');
end
if i==3
plot((0:n+1).'*h,solution,'y+');
end
if i==4
plot((0:n+1).'*h,solution,'c.');
end
if i==5
plot((0:n+1).'*h,solution,'k-.');
end
hold off;

end

H
error
estimate
