Proving $ \sum^{\infty}_{k=1}\frac{\textrm{sin}(\frac{k\pi}{2})\textrm{cos}(k\delta)}{k}=1/4({\pi}+gd(i\delta)+gd(-i\delta))$ In Mathematica, we can show that 
\begin{equation}\label{gd}
\sum^{\infty}_{k=1}\frac{\textrm{sin}(\frac{k\pi}{2})\textrm{cos}(kx)}{k}=\frac{1}{4}\big({\pi}+\textrm{gd}(ix)+\textrm{gd}(-ix)\big),
\end{equation}
where $x \in \mathbb{R}$ and $\textrm{gd}$ is the Gudermannian function. How does one show this analytically?
Attempted solution:
Using $\textrm{cos}(kx)=\frac{e^{ix}+e^{-ix}}{2}$, the series is 
\begin{equation}
\frac{1}{2}\bigg(e^{ix}+e^{-ix}-\frac{e^{i3x}}{3}-\frac{e^{-i3x}}{3}+\frac{e^{i5x}}{5}+\frac{e^{-i5x}}{5}+\ldots\bigg).
\end{equation}
Assuming we can rearrange the terms in this series, we have
\begin{equation}
\frac{1}{2}\bigg(e^{ix}-\frac{e^{i3x}}{3}+\frac{e^{i5x}}{5}+\ldots+e^{-ix}-\frac{e^{-i3x}}{3}+\frac{e^{-i5x}}{5}+\ldots\bigg).
\end{equation}
Recall the expansion
\begin{equation}
\textrm{arctan}(z)=z-\frac{z^3}{3}+\frac{z^5}{5}-\frac{z^7}{7}+\ldots,~ ~ |z|\leq 1, ~ z\neq i, -i.
\end{equation}
Hence, 
\begin{equation}
\sum^{\infty}_{k=1}\frac{\textrm{sin}(\frac{k\pi}{2})\textrm{cos}(kx)}{k}=\frac{1}{2}\textrm{arctan}(e^{ix})+\frac{1}{2}\textrm{arctan}(e^{-ix}),~~ x\neq \pm \frac{\pi}{2}+2\pi n,~ n\in \mathbb{Z}.
\end{equation}
The arctan function is related to the Gudermannian via
\begin{equation}\label{gdar}
\textrm{gd}(x)=2 \textrm{arctan}(e^{x})-\frac{\pi}{2 }.
\end{equation}
Assuming that this generalizes to
\begin{equation}
\textrm{gd}(ix)=2 \textrm{arctan}(e^{ix})-\frac{\pi}{2 },
\end{equation}
we arrive at
\begin{equation}
\sum^{\infty}_{k=1}\frac{\textrm{sin}(\frac{k\pi}{2})\textrm{cos}(kx)}{k}=\frac{1}{4}\big({\pi}+\textrm{gd}(ix)+\textrm{gd}(-ix)\big).
\end{equation}
I have made two assumptions above. The first one requires us to show that the series is absolutely convergent, but I am unsure of how to do this. 
The second one seems to be correct, as long as we analytically continue the Gudermannian correctly. Note that
\begin{equation}
\begin{aligned}
\textrm{gd}(x)&=\int_0^x\frac{1}{\textrm{cosh}(t)}dt=2\int_0^x\frac{e^t}{e^{2t}+1}dt\\
&=2\int^{e^x}_1\frac{1}{y^2+1}dy
\end{aligned}
\end{equation}
using $y=e^t$. It seems to me that we can analytically continue this integral as long as we avoid the singularities at $y=\pm i$. If this is indeed the case then integration should give $
\textrm{gd}(z)=2 \textrm{arctan}(e^{z})-\frac{\pi}{2 }$ within the disk bounded by $y=\pm i$, which gives us 
$$\textrm{gd}(ix)=2 \textrm{arctan}(e^{ix})-\frac{\pi}{2 }$$ for $$-\frac{\pi}{2}<x<\frac{\pi}{2}.$$ But I am unsure if I have overlooked any subtleties.
 A: Your summation is the Fourier series of a shifted square wave. More precisely,
$$ \sum_ {k=1}^\infty  \sin(k\pi/2)\cos(k x)/
   k = (\pi/4)\text{sgn} (\cos (x)) $$ where sgn(x) is the sign function. The Wikipedia article on Fourier series uses the square wave as an example in the section on Convergence. By the way, the Mathematica code:
sum = Sum[Sin[k Pi/2] Cos[k x]/k, {k, Infinity}] // FullSimplify; sum // InputForm

which returns
(Pi + Gudermannian[(-I)*x] + Gudermannian[I*x])/4

or more readably in TeXForm instead:
$$ \frac{1}{4} (\text{gd}(-i x)+\text{gd}(i x)+\pi ) $$
is an example of why computer generated results can not always be trusted to be valid or useful without further investigation.
Since it seems that the Gudermannian is an odd function, just like sine or cosine, why didn't Mathematica simplify the expression to just $\,\pi/4?\,$ 
The answer is that the Gudermannian is multi-valued and hence has branch cuts. Because of this, and the choice of principal values used by Mathematica, the value of the expression
$\,\text{gd}(-i x)+\text{gd}(i x)\,$ is not always equal to $\,0.\,$ It can also be $\,-2\pi$ depending on the real part of $x$.
Because of this we have the equation
$$ (\pi/4)\text{sgn} (\cos (x)) =
(\text{gd}(-i x)+\text{gd}(i x)+\pi )/4 $$
valid for all complex values of $x$.
NOTE Despite the fact that ArcSin and ArcTan are odd and also multi-valued, the choice of principal values used by Mathematica allows it to evaluate the expression
ArcSin[x] + ArcSin[-x] == ArcTan[x] + ArcTan[-x] == 0

as True which was not possible for the Gudermannian.
