Solution (source code)

= Solution

Reflecting repeatedly in the two parallel planes creates an infinite <method of images>. For $\mathbf r'=(x',y',z')$, introduce
$$
\mathbf r_n^+=(x'+4n,y',z'),\qquad
\mathbf r_n^-=(-x'-2+4n,y',z'),\qquad n\in\mathbb Z.
$$
The <Dirichlet Green function between parallel planes> is
$$
\boxed{G_{\rm slab}(\mathbf r,\mathbf r')=-\frac1{4\pi}\sum_{n\in\mathbb Z}
\left[\frac1{|\mathbf r-\mathbf r_n^+|}-\frac1{|\mathbf r-\mathbf r_n^-|}\right].}
$$
Each bracket is $O(n^{-2})$, so the paired series converges absolutely away from the sources. At $x=-1$, reflection pairs the positive image indexed by $n$ with the negative image indexed by $-n$. At $x=1$ it pairs that positive image with the negative image indexed by $1-n$. The distances agree in each pairing, making both boundary values zero. This can be checked with symmetric finite partial sums first; the unmatched end terms tend to zero, so no subtraction of separately divergent series is needed. Only $\mathbf r_0^+=\mathbf r'$ lies within the slab, so $\Delta_{\mathbf r}G_{\rm slab}=\delta(\mathbf r-\mathbf r')$. This is the usual Green function decaying at large transverse separation; such a condition selects the physical solution in the unbounded region.