Solution of a 2 dimensional laplace equation I have the solution to $u_{xx}+u_{yy}=0$, $$u(x, y) = \sum^{\infty}_{n=1}\left(\left(\dfrac{2}{\pi}\int^{\pi}_{0}f(x)\sin{nx}\,{\rm d}x\right)\Big/\left(\sinh{2n\pi}\right)\right)\sinh{(ny)}\sin{(nx)}$$ which satisfies the boundary conditions $u(0, y)=u(\pi, y)=u(x,0)=0$, and $u(x,2\pi)=f(x)$. Suppose now that $$f(x)=\begin{cases}1,&\text{if $x\in(0,\pi/2)$}, \\ 0, & \text{if $x\in(\pi/2, \pi)$}.\end{cases}$$ Then the integral within the solution becomes $$\int^{\pi}_{0}f(x)\sin{nx}\, {\rm d}x=\int_{0}^{\pi/2}\sin{nx}\,{\rm d}x= -\frac{1}{n}\begin{cases}0, &\text{if $n=4k$,}\\-1,&\text{if $n=2k+1$,}\\-2,&\text{if $n=4k+2$.}\end{cases}$$ Where $k\in\mathbb{Z}^{+}\cup\{0\}$. Now my question is, if I want to substitute this back into my solution, would I represent it as: $$u(x, y) =\sum^{\infty}_{k=0}\left\{\left[\left(\frac{2}{\pi}\cdot0\right)\Big/\sinh{(2(4k)\pi)}\right]\sinh{4ky}\sin{4kx} \\ + \left[\left(\frac{2}{\pi}\cdot\left(\frac{1}{2k+1}\right)\right)\Big/\sinh{(2(2k+1)\pi)}\right]\sinh{((2k+1)y)}\sin{((2k+1)x)}\\+\left[\left(\frac{2}{\pi}\cdot\left(\frac{2}{4k+2}\right)\right)\Big/\sinh{(2(4k+2)\pi)}\right]\sinh{((4k+2)y)}\sin{((4k+2)x)}\right\}$$Simplifying yields: $$u(x, y) =\frac{2}{\pi}\sum^{\infty}_{k=0}\left(\frac{1}{2k+1}\right)\left\{\Big[\sinh{((2k+1)y)}\sin{((2k+1)x)}\Big]\Big/\sinh{(2(2k+1)\pi)}\\
+\Big[\sinh{((4k+2)y)}\sin{((4k+2)x)}\right]\Big/\sinh{(2(4k+2)\pi)}\Big\}$$

We first have:
$$\sum_{n=0}^{\infty}F(n)=\sum_{k=0}^{\infty}\left[F(4k)+F(4k+1)+F(4k+2)+F(4k+3)\right]\tag{1}$$
We then have:
\begin{align}\cos{\left(\frac{n\pi}{2}\right)}-1=\begin{cases}0, &\text{if $n=4k$,}\\-1,&\text{if $n=4k+1$,}\\-2,&\text{if $n=4k+2$,}\\-1,&\text{if $n=4k+3$.}\end{cases}\tag{2}\end{align}
Now you can substitute your formulas for $F(4k),F(4k+1),F(4k+2),F(4k+3)$.
The potential problem with your original approach is that you may miss case (4) (n=4k+3), because its value (-1) is the same as that for case (2). In other words, you need to show that the sum over $k$ is identical to the sum over $n$.
