Laplace equation with weird boundary condition So, guys, here's my problem. I have this differential equation
$$
U''_{xx}+U''_{yy}=0
$$
with these boundary conditions:
$$
U'_{y}(x,0)=0
$$
$$
U'_{y}(x,\pi)=0
$$
$$
U(0,y)=0
$$
$$
U(\pi,y)=1+\cos(2y)
$$
Now, I obtain this solution for the first three conditions:
$$
\sum_{n=1}^{\infty} K_n \cdot \sinh(nx) \cdot \cos(ny)
$$
And it has to verify the last condition, so
$$
U(\pi,y)=\sum_{n=1}^{\infty} K_n \cdot \sinh(n\pi) \cdot \cos(ny)=1+\cos(2y)
$$
So, $ K_n \cdot \sinh(n\pi) $ has to be the coefficient of the Fourier series of $ 1+\cos(2y) $. My problem is, how do I calculate $ K_n $?
I tried to obtain the constant by using the following formula
$$
K_n \cdot sinh(n\pi)=\frac{1}{\pi} \int_{-\pi}^{\pi} (1+ \cos(2y)) \cdot \cos(ny) \ dy
$$
But, according to Wolfram Alpha and my own results, it's equal to $0$.
Thank you very much, guys!
 A: This should be nonzero exactly for $n=0,2$, since the function you are decomposing is already in Fourier series form. So $K_n$ is only nonzero for those two values of $n$. They're messing with your head by giving you a finite Fourier series.
A: You have this mostly right.  As @Brian Rushton says, the finite FS in the BC means that you only need contend with the $n=0$ and $n=2$ terms.  The tricky part is getting the $n=0$ term right.  In that case,you may be tempted to set that term to zero identically, but that's not right.  The fact that $U(\pi,0)=2$ means that a different approach is warranted.  In this case, if you imagine that
$$U(x,y) = \sum_{n=0}^{\infty} A_n \sinh{n x} \cos{n y}$$
set $A_n = B_n/(n \pi)$.  Then $\lim_{n \to 0} A_n \sinh{n x} = B_0 (x/\pi)$.  The BC at $x=\pi$ demands that $B_0=1$.  It is then straightforward to write that
$$U(x,y) = \frac{x}{\pi} + \frac{\sinh{2 x}}{\sinh{2 \pi}} \cos{2 y}$$
You may verify that this $U$ satisfies the BCs and the differential equation.
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

*

*Lets $\ds{\on{U}_{y}\pars{x,y} \equiv
-\sum_{n = 1}^{\infty}\on{a}_{n}\pars{x}n\sin\pars{ny}}$ which already satisfies $\ds{\on{U}_{y}\pars{x,0} = \on{U}_{y}\pars{x,\pi} = 0}$.

*Then, $\ds{\on{U}\pars{x,y} \equiv
\sum_{n = 1}^{\infty}\on{a}_{n}\pars{x}\cos\pars{ny} + \on{f}\pars{x}}$.

*The above $\ds{\on{U}\pars{x,y}}$ expression must satisfy the Laplace differential equation:
$$
\sum_{n = 1}^{\infty}\bracks{\on{a}''_{n}\pars{x} - n^{2}\on{a}_{n}\pars{x}}\cos\pars{ny} + \on{f}''\pars{x} = 0
\label{1}\tag{1}
$$
Integrate both sides over $\ds{y \in \pars{0,\pi}}$. It yields $\ds{\on{f}''\pars{x} = 0 \implies \on{f}\pars{x} = bx + c}$ where $\ds{b\ \mbox{and}\ c}$ are constants.

*Multiply both sides of (\ref{1}) by $\ds{\cos\pars{ny}}$ and integrate both sides over $\ds{y \in \pars{0,\pi}}$:
$$
\on{a}''_{n}\pars{x} - n^{2}\on{a}_{n}\pars{x} = 0
\implies
\on{a}_{n}\pars{x} = p_{n}\expo{nx} + q_{n}\expo{-nx}\,,\quad p_{n}, q_{n}:\ \mbox{constants}
$$

*The general solution becomes
\begin{align}
\on{U}\pars{x,y} & =
\sum_{n = 1}^{\infty}
\pars{p_{n}\expo{nx} + q_{n}\expo{-nx}}\cos\pars{ny} + bx + c
\\[5mm]
0 & =
\sum_{n = 1}^{\infty} 
\pars{p_{n} + q_{n}}\cos\pars{ny} + c \implies q_{n} = -p_{n}\,,\ c = 0
\\[5mm]
1 + \cos\pars{2y} & =
\sum_{n = 1}^{\infty} 
\pars{p_{n}\expo{n\pi} + q_{n}\expo{-n\pi}}\cos\pars{ny} + b\pi + \overbrace{c}^{\ds{=\ 0}}
\\[2mm] \implies &
2p_{n}\sinh\pars{n\pi} = \delta_{n2}\,,\quad b\pi = 1 \implies b = {1 \over \pi}
\end{align}

*Finally,
$$
\on{U}\pars{x,y} =
\bbx{{x \over \pi} + {\sinh\pars{2\pi x}\cos\pars{2y} \over \sinh\pars{2\pi}}} \\ 
$$
