Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

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.

share|improve this question

9 Answers 9

up vote 28 down vote accepted

I add more details for the solution in the distinguished answer due to Anixx. First, we need the 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 . $$

share|improve this answer
NICE! I have to confess it only became obvious to me only after you wrote the thing out in full. Thanks a lot! –  J. M. Oct 21 '10 at 0:47
Thank you, Gerald. –  Will Jagy Oct 21 '10 at 1:21
Yes, thanks for the additional information. Interestingly, it looks like $T(x + \pi) - T(x)$ is also periodic, with period 1. –  Herman Tulleken Oct 21 '10 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)$. –  Herman Tulleken Oct 21 '10 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. –  Gerald Edgar Oct 21 '10 at 18:49

Well I found the answer to your question, it is

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

share|improve this answer
@Mariano: of course not. The series (2) that "defines" it diverges for almost all real $x$ –  Gerald Edgar Oct 17 '10 at 21:11
I have always confused an infinite sum with a sum over an infinite range. How may I deconfuse the two? –  Gerry Myerson Oct 17 '10 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$. –  Gerald Edgar Oct 17 '10 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}$. –  Gerald Edgar Oct 17 '10 at 23:18
QUESTION: Is there some sense in which Anixx's other solution, the one I liked, can be interpreted as $ix-\psi _{e^{2 i}}^{(0)}\left(x+\frac{\pi }{2}\right)$ ?? –  Gerald Edgar Oct 21 '10 at 18:58

And here is the plot of indefinite sum of tan(x):

alt text

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

It can be derived from the first formula on this page:

$$\tan(z)=8z \sum_{k=1}^{\infty} \frac1{(2k-1)^2\pi^2-4z^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{z-\pi k+\frac{\pi}2}+\frac1{z+\pi k-\frac{\pi}2}\right)$$

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

share|improve this answer
But the plot was made from a partial sum of the series, I guess? Does the series converge somewhere? –  Mariano Suárez-Alvarez Oct 20 '10 at 17:51
@Anixx, could you provide the details of the proof of convergence? What is the $\psi$ function? –  Mariano Suárez-Alvarez Oct 20 '10 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. –  Will Jagy Oct 20 '10 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... –  Mariano Suárez-Alvarez Oct 20 '10 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. –  Gerald Edgar Oct 20 '10 at 21:19

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:

Image of plot of T(n+1)=T(n)+tan(n), T(0)=0

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

T(n) maximum is about 3.5, T min is about -425.

share|improve this answer
The observed almost periodicity with period about 355 should relate to the fact that pi = 355/113, so that tan(x + 355) ~= tan(x + 113pi) = tan x. Note, though, that this the approximation above is only good when x + 355 and x + 113pi are not close to multiples of pi. If you were to look at this function on a larger scale you'd probably also see something like almost periodicity with longer periods corresponding to better rational approximations of pi (although 355/113 is exceptionally close to pi, so you'dhave to zoom out a lot to get a better one, and it might be less impressive.) –  Alison Miller Oct 20 '10 at 22:01
(er, make that "when x + 355 and x + 113 pi are not close to odd multiples of pi/2, that is, the points of discontinuity of tan x"). –  Alison Miller Oct 21 '10 at 4:13

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

share|improve this answer
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). –  Herman Tulleken Oct 8 '10 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. –  Anixx Oct 21 '10 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. –  Noah Snyder Oct 21 '10 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. –  Anixx Oct 21 '10 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. –  Anixx Oct 21 '10 at 17:43

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?

share|improve this answer

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.



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.

share|improve this answer
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). –  Herman Tulleken Oct 4 '10 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. –  Herman Tulleken Oct 5 '10 at 7:49

The Maple command for indefinite sums (as described on the page http://www.maplesoft.com/support/help/Maple/view.aspx?path=sum/details, found via Google by typing "indefinite sum" maple) is given by


I tried this, but my version of Maple doesn't know the answer when f=tan(x).

For sin(x) it gives sum(sin(x),x);= -(1/2)sin(x)+(1/2)*sin(1)cos(x)/(cos(1)-1)

share|improve this answer
Yes, I am pretty sure if there is a simple expression, it is not an elementary function, which is why these symbolic programs don't know it. But it might still be a studied special function... –  Herman Tulleken Oct 4 '10 at 15:29

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

share|improve this answer
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? –  Herman Tulleken Oct 4 '10 at 14:53
It depends what you mean by a solution - do you want asymptotics, for instance? Fast numerical algorithms? –  j.c. Oct 4 '10 at 23:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.