Developing a correct Ansatz and solving the Laplace equation on a rectangle I am trying to find a way to efficiently solve the Laplace equation, by generating a rule for making Ansatz. However, once this ansatz is found, I struggle with finding the coefficients and the structure of the solution.
The problem is:
\begin{equation}
u_{xx}+u_{yy}=0  \ \ \ \ \ \ \Omega: \{0<x<1, 0<y<3\} \\
u_x(0,y)=u_x(1,y)=0   \ \ \ \ \  \       \\
u(x,0)=0, u(x,3)=x 
\end{equation}
From this problem, we can actually see the form of the solution, by looking at the IC:

*

*$u_x(0,y)=u_x(1,y)=0$
This is a Neumann condition on x, thus the x-part of the solution must be in the form $u(x)=A_n\cos(\frac{n\pi}{a})x$.


*$u(x,0)=0, u(x,3)=x $
This is a Dirichlet condition on y, and note that the second condition suggests that the function is $x$ at the point 3, so this is clearly not a trigonometric behavior, therefore we can conclude that since it is Dirichlet, it must be a sine function, but since it is not trigonometric, it must be hyperbolic sine. So the form must be $u(y)=B_m\sinh\frac{m\pi}{b}y$.
Since the boundary is rectangular, we need an additional constant in front of the Ansatz, hence we  can form the Ansatz as
\begin{equation}
u(x,y)=C_n +  \sum_{n=0}^\infty A_n\cos\frac{n\pi}{a}x \sum_{m=0}^\infty B_m\sinh\frac{m\pi}{b}y
\end{equation}
But at this stage, is there an equally rapid way to find the coefficients? Evidently, only the cosine term can be subjected to series expansion, but here we have a zero in the Neumann conditions, so how is that done?
Thanks
 A: The separation of variables technique starts with looking for solutions of the form $X(x)Y(y)$. The sum of such solutions is rarely going to be another separated function of the form $X(x)Y(y)$. Plugging $X(x)Y(x)$ into the original PDE, and separating variables, gives
$$
                  X''(x)Y(x)+X(x)Y''(y)=0 \\
                  \frac{X''(x)}{X(x)}+\frac{Y''(y)}{Y(y)}=0 \\
                 \frac{X''(x)}{X(x)}=-\frac{Y''(y)}{Y(y)}
$$
The left side does not depend on $y$ and the right side does not depend on $x$. So both sides must be constant in $x$ and in $y$. Therefore, in order for such a solution $X(x)Y(y)$ to exist, it must be the case that there is a constant $\lambda$ such that
$$
                        \frac{X''(x)}{X(x)}=-\lambda,\; \frac{Y''(y)}{Y(y)}=\lambda.
$$
If the constant $\lambda$ is positive, you end up with solutions
$$
                 X(x)=A\cos(\sqrt{\lambda}x)+B\sin(\sqrt{\lambda}x), \\
            Y(y)=C\cosh(\sqrt{\lambda}y)+D\sinh(\sqrt{\lambda}y)
$$
If the constant $\lambda$ is negative, you end up with solutions
$$
                 X(x)=A\cosh(\sqrt{-\lambda}x)+B\sinh(\sqrt{-\lambda}x), \\
            Y(y)=C\cos(\sqrt{-\lambda}y)+D\sin(\sqrt{-\lambda}y)
$$
The only way to tell which form is needed is to look at the endpoint conditions. If there are two homogenous endpoint conditions in $x$, then the $x$ solutions will involve the ordinary trigonometric functions because the hyperbolic ones cannot satisfy homogeneous endpoint conditions at $x=a$ and at $x=b$, unless you're dealing with the $0$ solution. In your case, you have $a=0$, $b=1$, and
$$
              X'(0)=0,\;\; X'(1)=0.
$$
This dictates solutions $X_n(x)=\cos(\sqrt{\lambda}x)$ where $\lambda=n^2\pi^2$ for $n=0,1,2,3,\cdots$ (the solution $X_0(x)=1$ is a solution.) The corresponding solutions in $Y$ have the form $\sinh(\sqrt{\lambda}x)$ because you need $u(x,0)=0$. So, the general solution becomes
$$
               u(x,y)=E_0+\sum_{n=1}^{\infty}E_{n}\cos(n\pi x)\sinh(n\pi y),
$$
where the $E_n$ are chosen to satisfy
$$
               x = u(x,3)=E_0+\sum_{n=1}^{\infty}E_n\cos(n\pi x)\sinh(3n\pi)
$$
So the problem is reduced to an ordinary Fourier cosine series problem, where the Fourier coefficients are $E_n\sinh(3n\pi)$. And these coefficients are determined by the function $x$ through the usual Fourier orthogonality conditions.
