% ALTTST % % example of alternating Schwarz iteration % for -u_xx - u_yy = f % % stats=zeros(10,3); for p=1:3 mp=p+4; m=2^mp-1; h=1/(m+1); x=1:m; x=x'*h; y=x; % % overlap = fraction of m means convergence rate is independent of h % = constant means convergence rate increases as h decreases % %overlap=floor(m/10); overlap=3; % % Fix the right side so that the solution is % % u(x,y) = sin(pi x) sin(pi y) e^x % wx=sin(pi*x); wxp=pi*cos(pi*x); wxpp=-pi*pi*wx; wy=wx; wypp=wxpp; u=(wx.*exp(x))*wy'; wxx=(wx + 2*wxp + wxpp).*exp(x); uxx=wxx*wy'; wyy=wypp; uyy=(wx.*exp(x))*wyy'; rhs2d=-(uxx+uyy); % % % uin=zeros(m,m); [u2d,stats(:,p)]=altsw(m,rhs2d,uin,overlap); u1=u2d(:); r1=rhs2d(:); err=norm(lapmf(u1)-r1,inf) end % % look at the convergence reates % stats(2:10,:)./stats(1:9,:)