# What is the indefinite sum of tan(x)?

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.

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 .$$

• NICE! I have to confess it only became obvious to me only after you wrote the thing out in full. Thanks a lot! Oct 21, 2010 at 0:47
• Yes, thanks for the additional information. Interestingly, it looks like $T(x + \pi) - T(x)$ is also periodic, with period 1. Oct 21, 2010 at 13:08
• Indeed, it is easy to prove that $T(z + \pi) - T(z) = -[\Psi(1 - (\pi/2 + z)) -\Psi(\pi/2 + z)] = -\pi \cot \pi(\pi/2 + z)$. Oct 21, 2010 at 14:28
• Alternatively: note that if you translate by any integer multiple of $\pi$ then you get another solution $T(z+m\pi)$ of the original problem. So the difference between $T(z)$ and this other solution is periodic with period 1. Oct 21, 2010 at 18:49
• The book of N. E. Nörlund: Vorlesungen über Differenzenrechnung, 1923, reprinted by Chelsea, 1954 credites A. Hurwitz with showing, that a meromorphic sum can be found for any meromorphic right hand side in chapter 3, §1 historical remarks, 18. The work of Hurwitz is cited as "Sur l'integrale finie d'une fonction entiere", Acta math. 20 (1897), p. 285 - 312 and Acta math. 22 (1899), p. 197 - 180. May 27, 2014 at 20:26

And here is the plot of indefinite sum of tan(x): Here you can see tan(x) in red and its indefinite sum is in blue.

As you can see, the indefinite sum is fairly continuous. Oleg Eroshkin's conclusion that this function should be discontinuous everywhere apparently came from a false assumption that indefinite sum of a periodic function should also be periodic.

Though it is true that as $|x|$ grows the density of the poles grows, showing the same behavior as in function $f(x)=\tan(x^2)$

The function shown on this plot is

$$T(z)=-\sum _{k=1}^{\infty } \left(\psi \left(k \pi -\frac{\pi }{2}+1-z\right)+\psi \left(k \pi -\frac{\pi }{2}+z\right)-\psi \left(k \pi -\frac{\pi }{2}+1\right)-\psi \left(k \pi -\frac{\pi }{2}\right)\right)+C$$

$$\tan(x)=8x \sum_{k=1}^{\infty} \frac1{(2k-1)^2\pi^2-4x^2}$$

We notice that there is a difference of squares in the denominator and separate the terms so to obtain

$$\tan(x)=-\sum_{k=1}^{\infty}\left(\frac1{x-\pi k+\frac{\pi}2}+\frac1{x+\pi k-\frac{\pi}2}\right)$$

Now we take indefinite sum by each term to obtain the expression for T(x). All simple.

• But the plot was made from a partial sum of the series, I guess? Does the series converge somewhere? Oct 20, 2010 at 17:51
• @Anixx, could you provide the details of the proof of convergence? What is the $\psi$ function? Oct 20, 2010 at 18:07
• Anixx, you might as well put a third answer with full details on exactly what series you are summing, where it converges and why. Meanwhile you might email Herman, using your pseudonym and a separate pseudonymous email account if you like, he is pretty happy and you have much in common. For Mariano, Gerald, Oleg and "J.M." the discussion of convergence of the series is far more interesting, most especially (as you have edited at least once) precisely what the series might be. Meanwhile, as long as Herman accepts one of your answers the relationship between you two is good. Oct 20, 2010 at 19:16
• @Anixx, how can we tell if this is correct or not if we don't even know if the formula you wrote defines a function? Writing down a series does not automatically define a function... Oct 20, 2010 at 19:53
• Close! I get instead by this method $$T(z) := -\sum_{k = 1}^{\infty} \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)$$ The term is asymptotic to $z(1-z)/(k^2\pi^2)$ so we have absolute convergence, and the difference is as claimed. Now, I suppose, the only quibble left is whether to consider this "closed form" or not. Oct 20, 2010 at 21:19

There is no reason to think there is any simple expression for solution $T$ of $$T(x + 1) - T(x) = \tan(x)$$

What we CAN find a simple solution to is this: $$T(x + \pi) - T(x) = \tan(x)$$

• Thank you. I know the solution to $T(x + \pi) - T(x)$, but I am hoping for a solution to the $T(x+1) - T(x)$ case. But if there is no "simple" solution, what avenues can I explore to get some sort of solution? Oct 4, 2010 at 14:53
• It depends what you mean by a solution - do you want asymptotics, for instance? Fast numerical algorithms?
– j.c.
Oct 4, 2010 at 23:34

There are no "nice" functions with such properties. Every solution is discontinuous at a dense subset of $\mathbb{R}$. Just look on poles of $\tan x$. Let $x=\pi/2+\pi m$, $m\in\mathbb{Z}$. Clearly either $T$ is discontinuous at $x$ or at $x+1$. In the latter case it is also discontinuous at $x+k$ for every positive integer $k$. In the former case, $T$ is discontinuous at $x+k$ for every non-positive integer $k$.

• It's interesting that a simple setup can lead to a complicated function like this. Thanks for your answer. (I am still interested if this is somehow a studied function). Oct 8, 2010 at 8:53
• For all those who voted for this answer, please notice that there is a counter-example to Eroshkin's claims. Such functions exists, mostly continuous and its plot is shown. See the currently selected answer. Oct 21, 2010 at 15:38
• Oleg's argument would only work if there were more "mixing" of the two cases. For example, if the former case happened for infinitely many negative numbers then the argument would go through. But as long as all sufficiently negative numbers are in the latter case and all sufficiently positive ones are in the former case, then there's a hole in the argument. Oct 21, 2010 at 16:06
• Oleg's argument's claims are fairly correct until the final conclusion. He correctly noted that the function should have poles at x+1+k or x-k for any natural k. The key word here is "either". The continuous sum function can be arranged so that for any pole right of zero all consecutive poles would be in x+1+k points, so to the right of the first one and for each pole in the left of zero all poles would be in the points x-k, so to the left of it. Thus in the neighbourhood of zero itself the number of poles is limited. Oct 21, 2010 at 17:30
• Besides this is is from general considerations evident that for any continuous analytic function on the interval from $(-\pi/2, \pi/2)$ can be constructed an indefinite sum function, continuous and analytic on the same interval plus a unit range. Oct 21, 2010 at 17:43

$$\sum_x \tan(x)=ix-\psi _{e^{2 i}}^{(0)}\left(x+\frac{\pi }{2}\right)+C$$

I have verified it with difference operator and it gives tan(x). The function involved is the q-digamma function http://mathworld.wolfram.com/q-PolygammaFunction.html .

You can verify the result yourself.

• Is the q-polygamma well-defined at $q=e^{2i}$? Oct 17, 2010 at 15:34
• @Mariano: of course not. The series (2) that "defines" it diverges for almost all real $x$ Oct 17, 2010 at 21:11
• I have always confused an infinite sum with a sum over an infinite range. How may I deconfuse the two? Oct 17, 2010 at 22:40
• By the way: ask Wolfram Alpha to plot the function $ix-\psi _{e^{2 i}}^{(0)}\left(x+\frac{\pi }{2}\right)$ or to numerically evaluate it for some real number $x$. Oct 17, 2010 at 23:17
• @Anixx: See (1) and (2) in the Mathworld page mathworld.wolfram.com/q-PolygammaFunction.html Note that (2) involves an INFINITE series, and (1) -- if you follow the link involved -- involves an INFINITE product. Both of these are DIVERGENT for almost all real x in the case of $e^{2i}$. Oct 17, 2010 at 23:18

The indefinite integral of tan(x) is -ln |cos(x)|, so find out how that expression was arrived at and see if this can be adpated to the discrete case.

http://en.wikipedia.org/wiki/Indefinite_sum

http://en.wikipedia.org/wiki/Table_of_integrals#Trigonometric_functions

Or go for an approximate answer: truncate the taylor series and find the indefinite sum of that polynomial. From http://en.wikipedia.org/wiki/Taylor_series tan(x) = x+x^3/3+... and sum(x+x^3/3,x) = (7/12)x^2-(1/2)x+(1/12)x^4-(1/6)x^3

The problem with this is tan(x) is periodically discontinuous and the taylor series is only valid for one period.

• The indefinite integral (typically) requires the use of substitution, which exists because of the "nice" chain rule for differentiation. Differencing does not have a nice chain rule (there are some variants, but they do not help in this case). I'll play with truncated Taylor series and see where it gets me (I guess I should have tried that already). Oct 4, 2010 at 16:05
• Ok, a few quick tests in Matlab shows that even in the range $[0 \pi/2]$ that the indefinite sum of Taylor series does not converge. In light of what Oleg Eroshkin said below, this makes sense, so this method cannot be used for finding an approximation. Oct 5, 2010 at 7:49

It's not in Jolley's Summation Of Series, which is pretty close to saying it doesn't exist. Have you tried Euler-Maclaurin summation to get an asymptotic series?

Consider T(x) in T(x+1)-T(x)=tan(x) to be defined only on the integers>=0 and write it as the recurrence relation :

T(n+1)-T(n)=tan(n) and set the initial value at T(0)=0,

and then without needing a closed form expression for T(n) in terms of n,

but just plotting the values of T(n+1)=T(n)+tan(n)

we can see what the function looks like when restricted to the integers: The top-left image shows the function plotted from n=..750

The left column of images is the plot, the middle images join the dots to get a look at the shape, and the right column shows were the image is zoomed to get the images on the next row.

The function T(n) appears to be almost periodic with period about 355.5