function onedlaplace for n = [10,20,40,80,160,320], h = 1/n; e = ones(n-1,1); A = spdiags([-e 2*e -e], -1:1, n-1, n-1); x = h*(1:n-1)'; f = rhs(x); uapp = h^2*(A\f); u = sol(x); max(abs(u-uapp)) subplot(2,1,1); plot(x,uapp,'r-',x,u,'b-'); title(sprintf('n = %i', n )); makelarge subplot(2,1,2); plot(x,u-uapp,'r-'); title('Fehler'); makelarge pause end function f = rhs(x) f = -12*x.^2 + 6*x; function u = sol(x) u = x.^3.*(x-1);