function hw7()
                                                                                                 
% Exapmle 1 (Page 697)
xmin = 0;
xmax = 2;
ymin = 0;
ymax = 1;
h = 1/3;
k = 0.2;
x = xmin:h:xmax;
y = ymin:k:ymax;
                                                                                                 
n = length(x);
m = length(y);
wNew = zeros(n,m);
wOld = zeros(n,m);
wExat = zeros(n,m);
                                                                                                 
for j = 1:m;
wNew(1,j) = 0;
wNew(n,j) = 2*exp(y(j));
wOld(1,j) = wNew(1,j);
wOld(n,j) = wNew(n,j);
end
                                                                                                 
for i = 1:n;
    wNew(i,1) = x(i);
    wNew(i,m) = exp(1)*x(i);
    wOld(i,1) = wNew(i,1);
    wold(i,m) = wNew(i,m);
end

for i = 1:n,j = 1:m;
wExat(i,j) = x(i)*exp(y(j));
end
                                                                                                 
iter = 0;
M = 1000;
TOL = 10^-10;
                                                                                                 
while (iter < M)
    for i=2:n-1,j=2:m-1;
        wNew(i,j) =((-wOld(i+1,j)-wNew(i-1,j))/h^2-(wOld(i,j+1)+wNew(i,j-1))/k^2+x(i)*exp(y(j)))/(-2/h^2-2/k^2);
    end
    if (norm(wNew-wOld,inf) < TOL)
        display('OK');
        wNew
        wExat
        return;
    end
    iter = iter+1;
    wOld = wNew;
end
