What is the indefinite sum of the tangent function, that is, the function $T$ for which 


$\Delta\_x T = T(x + 1) - T(x) = \tan(x)$


Of course, there are infinitely many answers, who all differ by a function of period 1. Ideally, I would like the solution to be of the form


$T(x) = $ nice\_function$(x)$ + possibly\_ugly\_periodic\_function$(x)$,
where nice is at least piece-wise continuous.


If any of the following sums can be found, the sum of tan can also be found:


* $\sum \sec x$
* $\sum \csc x$
* $\sum \cot x$
* $\sum \frac{1}{e^{ix} + 1}$


I have tried several methods without success, including using a newton series (which does not converge for non-integer $x$), and trying to guess possible functions. 


I would also appreciate lines of attack if a solution is not known.



What is the indefinite sum of tan(x)?
I add more details for the solution in the distinguished answer due to Anixx. First, we need the **digamma** function  

<http://en.wikipedia.org/wiki/Digamma_function>  

which we will call $\Psi(x)$. Important properties (from that web page) are: $\Psi(x)$ is analytic in the complex plane except at the nonpositive integers where it has simple poles. $\Psi(x+1)-\Psi(x) = 1/x$. $\Psi(x) > 0$ for $x>2$. Asymptotics:
$$
 \Psi(x) = \log x - \frac{1}{2x} - \frac{1}{12x^2} + \frac{1}{120x^4} + O(x^{-6})
\qquad\text{as } x \to \infty .
$$
So, define $T(z) ={}$
$$
 -\sum\_{k = 1}^{\infty} \Biggl[\Psi \Biggl(\pi \biggl(k - \frac{1}{2}\biggr) - z + 1\Biggr) + \Psi \Biggl(\pi \biggl(k - \frac{1}{2}\biggr) + z\Biggr) - \Psi \Biggl(\pi \biggl(k - \frac{1}{2}\biggr) + 1\Biggr) - 
\Psi \Biggl(\pi \biggl(k - \frac{1}{2}\biggr)\Biggr)\Biggr]
$$
For any fixed $z$, only finitely many preliminary terms involve $\Psi$ evaluated at a nonpositive argument, and the asymptotics of the remaining terms are computed (from the asymptotics given above) as
$$
\Psi \Biggl(\pi \biggl(k - \frac{1}{2}\biggr) - z + 1\Biggr) + \Psi \Biggl(\pi \biggl(k - \frac{1}{2}\biggr) + z\Biggr) - \Psi \Biggl(\pi \biggl(k - \frac{1}{2}\biggr) + 1\Biggr) - 
\Psi \Biggl(\pi \biggl(k - \frac{1}{2}\biggr)\Biggr)
$$


$=z(1-z)/(k^2\pi^2) + o(k^{-2})$ as $k \to \infty$. So the series converges absolutely except when we are at a pole of one of the preliminary terms. Now, because of absolute convergence, we may subtract term-by-term and simplify to get


$$
T(z+1)-T(z) = \sum\_{k=1}^\infty\Biggl[\frac{8z}{(-\pi+2\pi k-2z)(-\pi+2\pi k+2z)}\Biggr] = \tan z .
$$


