Last mile for Laplace-like PDE with non-homogenous Neumann conditions how do I proceed with separation of variables for this problem:
$$\left\{\begin{matrix}
-\Delta u + 2u=0, \quad in \quad R=\{(x,y)|0<x<\pi,0<y<\pi\}, \\
u_{x}(0,y)=0, \qquad \qquad \qquad 0<y<\pi, \\
u_{x}(\pi,y)=3-\cos(2y), \quad 0<y<\pi, \\
u_{y}(x,0)=u_{y}(x,\pi)=0, \quad 0<x<\pi.
\end{matrix}\right.$$
I'm given separated variables, an eigenproblem and an ODE, which I can solve and put back together, but I can't fit the non-homogeneous condition while keeping the PDE true.
Here's the given eigenvalue problem and my solution
$$Y''+\lambda Y=0, \qquad 0<y<\pi, \\
Y'(0)=Y'(\pi)=0,\\
Y(y)=c_{n}\cos(\sqrt{\lambda}y), \quad \sqrt{\lambda}=n=0,1,2,3, ...$$
The given ODE problem and my solution (I'm using $(2+\lambda)>0$)
$$X''-(2+\lambda)X=0, \qquad 0<x<\pi,\qquad X'(0)=0,\\
X(x)=c_{n} \cosh(x \sqrt{2+n^2}).$$
This gives the solution as
$$u=X(x)Y(y)=c_{n}\cosh(x \sqrt{2+n^2})cos(ny)$$
which solves the PDE with constant $c_{n}$, but how do I determine $c_{n}$? (When I use $n=2$ and solve for $c_{2}$ I break the original PDE, and I'm failing at creating a Fourier expansion of $3-\cos(2y)$).
Thanks!
 A: (Credit to Matteo for this answer, see comment).
You can use the superposition principle to add as many solutions together as you like - including adding one term for each term in the given non-homogeneous boundary condition.
First form the superposition series, differentiate it and use the given data.
$$ u(x,y) = \sum_{n>=0}c_{n}\cosh(\sqrt{n^2+2}x)\cos(ny)$$
$$\frac{d\ u(x,y)}{d\ x}=u_{x}(x,y) = \sum_{n>=0}c_{n} \sqrt{n^2+2}\sinh(\sqrt{n^2+2}x)\cos(ny) \\
u_x (\pi,y)=\sum_{n>=0}c_{n} \sqrt{n^2+2}\sinh(\sqrt{n^2+2}\pi)\cos(ny)=3-\cos(2y)$$
We are free to use only the first and the third terms ($c_0$ and $c_2$):
$$c_{0} \sqrt{2}\sinh(\sqrt{2}\pi)\cos(0) + c_{2} \sqrt{2^2+2}\sinh(\sqrt{2^2+2}\pi)\cos(2y)=3-\cos(2y)\\
\left\{\begin{matrix}
c_{0} \sqrt{2}\sinh(\sqrt{2}x)\cos(0) =& 3\\
c_{2} \sqrt{2^2+2}\sinh(\sqrt{2^2+2}\pi)\cos(2y) =& -\cos(2y)
\end{matrix}\right. $$
Isolating the coefficients, we find
$$ \left\{\begin{matrix}
c_0 = \frac{3}{\sqrt{2}\sinh(\sqrt{2}\pi)}\\
c_2 = \frac{-1}{\sqrt{6}\sinh(\sqrt{6}\pi)}\\
\end{matrix}\right.$$
The solution - as can be checkked - therefore is
$$u(x,y)=\frac{3}{\sqrt{2}\sinh(\sqrt{2}\pi)}\cosh(\sqrt{2}x)+\frac{-1}{\sqrt{6}\sinh(\sqrt{6}\pi)}\cosh(\sqrt{6}x)\cos(2y). $$
