N = 9;
iter=50;
h = 1/(N+1);
A = zeros(N);
b(1) = -h^(4) - 0.02;
b(N) = -N^(2)*h^(4) - 0.12;
for i=1:N
    Exact(i) = -0.1*(i*h)^(2) - 0.02;
    Guess(i) = 0;
    A(i,i) = 2 + 10*h^(2);
    if i ~= N
        A(i,i+1) = -1;
        A(i+1,i) = -1;
    end
    if i~= N && i ~= 1
        b(i) = -h^(4)*i^(2);
    end
end
for k=1:iter
    maxerror(k) = 0;
    for i=1:N
        sum = 0;
        for j=1:N
            if j ~= i
                sum = sum + A(i,j)*Guess(j);
            end
        end
        Placeholder(i) = (1/A(i,i))*(b(i) - sum);
        Error(i,k) = abs(Placeholder(i) - Exact(i));
        if Error(i,k) > maxerror(k)
            maxerror(k) = Error(i,k);
        end
    end
    for a = 1:N
        Guess(a) = Placeholder(a);
    end
end
v = linspace(1,50,50);
plot(v,maxerror);