clc;
clear all;
sizes = [4, 100, 1000, 10000, 10000] + 1;
condK = zeros(length(sizes),1);
error = condK;
for isize = 1:length(sizes)
  fprintf('%d\n',isize);
  n = sizes(isize);
  h = 1/(n+1);
  K = (1/h^2)*toeplitz([2,-1,zeros(1,n-2)]);
  f = -2*ones(n,1);
  condK(isize) = 4/pi^2*(n+1)^2;
  xapprox = K\f;
  x = (linspace(0,1,n+2))';
  x(1) = [];
  x(end) = [];
  xexact = x.*(x-1);
  error(isize) = norm(xapprox-xexact)/norm(xexact);
endfor
