Trying to establish the following identity involving sums using residues If $2z - 1 $ is not an integer, then 
$$ \frac{1}{\cos( \pi z) } = 1 + \frac{4}{\pi} \sum_{n=1}^{\infty} \left[ \frac{ 2z -1}{(2z-1)^2-4n^2} + \frac{4}{1-4n^2} \right]$$

################Attempt################.

I consider $f(z) = \frac{1}{\cos \pi z} -1 = \frac{ 1 - \cos \pi z}{\cos \pi z}$. We know $\cos \pi z = 0 \iff \pi z = (2n +1) \frac{ \pi}{2} \iff z = n + \frac{1}{2}$. So $f(z) $ has simple poles at $a_n = n + \frac{1}{2} $. The residues at $z = a_n$ are given by $b_n = (-1)^n $ and consider square $C_k$ with corners $ \pm k \pm ki $. Then by residue theorem 
$$ \int_{C_k} f(z) dz = 2 \pi i \sum_{n= - \infty}^{\infty} \{ b_n : b_n \in C_n \} $$
But, then I feel like this wont lead me anywhere. Am I on the right track?
 A: I think what you want to prove is that
$$\sum_{n=-\infty}^{\infty} f(n) = -\sum_k \operatorname*{Res}_{\zeta=\zeta_k} \left [\pi \, \cot{(\pi \zeta)} \, f(\zeta)\right ] $$ 
where $\zeta_k$ are the non-integer poles of $f$.  You do this by showing that
$$\lim_{N \to \infty} \oint_{C_N} d\zeta \, \pi \, \cot{(\pi \zeta)} \, f(\zeta) = 0$$
on the square $C_N$ with vertices $(\pm N \pm 1/2 )(1+i)$.
Once you show that, then you can evaluate
$$\sum_{n=-\infty}^{\infty} \left [\frac{2 z-1}{(2 z-1)^2-4 n^2} + \frac{4}{1-4 n^2} \right ] = \frac{\pi}{4} \sum_k \operatorname*{Res}_{\zeta=\zeta_k} \left ( \cot{(\pi \zeta)} \,  \left [\frac{2 z-1}{\zeta^2-(z-1/2)^2} + \frac{4}{\zeta^2-1/4} \right ]\right ) $$
where $\zeta_{1,2} = \pm (z-1/2)$.  (Note that singularities at $\zeta=\pm 1/2$ are removable.)  Thus, the double infinite sum is equal to
$$\frac{\pi}{4} [-\tan{(\pi z)}] \left (1+\frac{4}{z(z-1)} \right ) + \frac{\pi}{4} \tan{(\pi z)} \left (-1+\frac{4}{z(z-1)} \right )= -\frac{\pi}{2} \tan{(\pi z)}$$
The sum, however, is also equal to $2 S + 4 + \frac1{2 z-1} $.  Thus,

$$\sum_{n=1}^{\infty} \left [\frac{2 z-1}{(2 z-1)^2-4 n^2} + \frac{4}{1-4 n^2} \right ] = -\frac12 \left [\frac{\pi}{2} \tan{(\pi z)} + 4 + \frac1{2 z-1} \right ]$$

This agrees with numerical results I derived in Mathematica.  I am not sure where your result comes from, but it is not correct.
