During the review of some EM exercises I stumbled over a very interesting problem I just can't find the solution for.

Suppose we are looking at a waveguide with side length $\pi$.

[![enter image description here][1]][1]

The boundary condition are given as

$$\phi(x,y=\pm\frac{\pi}{2}) = 0$$
$$\phi(x=\pm\frac{\pi}{2},y) = U\cos(y).$$

The potential is constant in $z$-direction and inside as well as outside are no further charges.
The question is now how the potential looks like inside the area.

My idea was to start with the Laplace-Equation 
$$\Delta \phi(\vec{r}) = \Delta \phi(x,y) = 0$$

To solve the differential equation I chose to split it into a set of separate equations, however I am not sure if this is a good idea.

I ended with this

$$\Delta \phi(x,y) = X''(x)Y(Y)+X(x)Y''(y) = 0. \tag{1}$$

With that I then said,
$$\frac{X''(x)}{X(x)} = \frac{Y''(y)}{Y(y)} = -\alpha^2,\tag{2}$$

where $\alpha$ needs to be constant, otherwise it wouldn't be a solution. I once learned that it is a good idea to choose the constant as $\alpha^2$, because it sometimes can make the ansatz easier to handle. I don't know if this is of any significance here, though.

Splitting eq.(2) up into two ODEs gives
$$X''(x)+\alpha^2X(x) = 0 \tag{3}$$
$$Y''(y)-\alpha^2Y(y) = 0 \tag{4}$$

And this is basically as far as I come. I would usually continue with choosing ansätze in the form of $\{\sin(\alpha x), \cos(\alpha x)\}$ for eq.(3), since it looks like a harmonic equation and $\{\sinh(\alpha y), \cosh(\alpha y)\}$ for eq.(4), since it looks like a modified harmonic equation,
but I am not able to make it fit with the boundary conditions.

For completeness’s sake my potential would look like

$$\phi(x,y) = A\sin(\alpha x)\sinh(\alpha y) + B\sin(\alpha x)\cosh(\alpha y) + C\cos(\alpha x)\sinh(\alpha y) + D\cos(\alpha x)\cosh(\alpha y). \tag{5}$$

Testing this with one of the boundary conditions shows that this can't be right though.
$$\phi(\frac{\pi}{2},y) \overset{!}{=} Ucos(y) \neq eq.(5) $$

I hope someone can help me find a good approach to problems like this in general, since I find non-constant boundary conditions very interesting.

  [1]: https://i.sstatic.net/3MO3z.jpg