% Solution Laplace's equation - semi-infinite strip
N1 = 201; N2 = 201; M = 100;
xv = linspace(0,2,N1);
yv = linspace(0,10,N2);
[x1,y1] = ndgrid(xv,yv);
for i = 1:N1
    for j = 1:N2
        c = [x1(i,j),y1(i,j)];
        U2(i,j) = 0;
        for k = 1:M
            U2(i,j) = U2(i,j) + (4*(-1)^(k+1)/(k*pi))...
                *sin(k*pi*c(1)/2)*exp(-k*pi*c(2)/2);
        end
    end
end

set(gca,'FontSize',[12]);
surf(x1,y1,U2);
shading interp
colormap(jet)
xlabel('$x$','Fontsize',12,'interpreter','latex'); 
ylabel('$y$','Fontsize',12,'interpreter','latex'); 
zlabel('$u_2(x,y)$','Fontsize',12,'interpreter','latex');
axis tight
view([110 12])
print -depsc laplace_egu2.eps
print -dpng laplace_egu2.png

figure(2);
clf

wmax = 100;
f = @(w,c) 4*(1-cos(5*w)).*sinh(c(1)*w).*sin(c(2)*w)...
    ./(pi*w.*sinh(2*w));
for i = 1:N1
    for j = 1:N2
        c = [x1(i,j),y1(i,j)];        
        U1a(i,j) = integral(@(w)f(w,c),0,wmax);
    end
end
surf(x1,y1,U1a);
shading interp
colormap(jet)
xlabel('$x$','Fontsize',12,'interpreter','latex'); 
ylabel('$y$','Fontsize',12,'interpreter','latex'); 
zlabel('$u_{1a}(x,y)$','Fontsize',12,'interpreter','latex');
axis tight
view([110 12])
print -depsc laplace_egu1a.eps
print -dpng laplace_egu1a.png

figure(3);
clf

wmax = 100;
f = @(w,c) 4*w.*sinh((2-c(1))*w).*sin(c(2)*w)...
    ./(pi*(w.^2-2*w+2).*(w.^2+2*w+2).*sinh(2*w));
for i = 1:N1
    for j = 1:N2
        c = [x1(i,j),y1(i,j)];        
        U1b(i,j) = integral(@(w)f(w,c),0,wmax);
    end
end
surf(x1,y1,U1b);
shading interp
colormap(jet)
xlabel('$x$','Fontsize',12,'interpreter','latex'); 
ylabel('$y$','Fontsize',12,'interpreter','latex'); 
zlabel('$u_{1b}(x,y)$','Fontsize',12,'interpreter','latex');
axis tight
view([-110 12])
print -depsc laplace_egu1b.eps
print -dpng laplace_egu1b.png

figure(4);
clf

for i = 1:N1
    for j = 1:N2        
        U(i,j) = U2(i,j)+U1a(i,j)+U1b(i,j);
    end
end
surf(x1,y1,U);
shading interp
colormap(jet)
xlabel('$x$','Fontsize',12,'interpreter','latex'); 
ylabel('$y$','Fontsize',12,'interpreter','latex'); 
zlabel('$u(x,y)$','Fontsize',12,'interpreter','latex');
axis tight
view([-85 20])
print -depsc laplace_egu.eps
print -dpng laplace_egu.png

