The partial fraction expansion of $\frac{1}{\cos z}$ According to the Mittag-Leffler partial fraction expansion theorem for meromorphic functons, $$
\frac{1}{\cos z}= 1+\sum_{n=-\infty}^{\infty}(-1)^{n+1}\Big (\frac{1}{z-\frac{\pi}{2}-\pi n}+\frac{1}{\frac{\pi}{2}+\pi n}\Big). $$
But how does one rearrange terms (and justify the rearrangement) to show that  $$\frac{1}{\cos z}  = \sum_{n=0}^{\infty}(-1)^{n+1}\frac{(2n+1)\pi}{z^{2}-(\frac{2n+1}{2})^{2}\pi^2} \ ? $$
EDIT:
An alternative version of the theorem (which requires showing that $\int \frac{\sec w}{w-z} \ dw$ vanishes around an appropriate contour) allows one to conclude that 
$$ \begin{align} \frac{1}{\cos z} &= \sum_{n=-\infty}^{\infty} \frac{(-1)^{n+1}}{z - \frac{\pi}{2}- \pi n} \\ &= \sum_{n=0}^{\infty} \frac{(-1)^{(-n-1)+1}}{z - \frac{\pi}{2} - \pi (-n-1)} + \sum_{n=0}^{\infty} \frac{(-1)^{n+1}}{z - \frac{\pi}{2} - \pi n} \\ &= \sum_{n=0}^{\infty} (-1)^{n+1} \left( \frac{-1}{z+ \frac{\pi}{2} + \pi n} + \frac{1}{z- \frac{\pi}{2} - \pi n} \right) \\ &= \sum_{n=0}^{\infty} (-1)^{n+1} \frac{(2n+1) \pi}{z^{2}- (\frac{2n+1}{2})^{2}\pi^{2}}. \end{align}$$

The terms in
$\Big (\frac{1}{z-\frac{\pi}{2}-\pi n}+\frac{1}{\frac{\pi}{2}+\pi n}\Big)$
are not absolutely convergent,
since
$\sum_{n=1}^{\infty} \frac1{z-\frac{\pi}{2}-\pi n}$
diverges.
So you may have problems.
