I am looking for the first positive solution $x_n$ of the equation $$f_n(x)=\sum_{k=1}^n\tan(kx)=0 \qquad \qquad (n\geq 2)$$ It is simple to show that $$\frac \pi{2n}<x_n <\frac \pi{2(n-1)}$$ The numerical solution is very easy (and inexpensive in terms of computer resources) to obtain using Newton, Halley or Householder methods but the analytical solution does not seem to be possible as soon as $n\geq 7$ (up to $n=6$, using $x=\tan^{-1}(t)$, the equation factors as products of polynomials of low degree). For example solving $f_6$ reduces to the problem of finding the first positive root of $$t \left(t^2-3\right) \left(t^6-21 t^4+35 t^2-7\right) \left(23 t^8-202 t^6+136 t^4-22 t^2+1\right)=0$$ (which is feasible even if tedious) while for $f_7$, the root which is looked for is solution of $$44 t^{16}-763 t^{14}+4375 t^{12}-10067 t^{10}+9199 t^8-3593 t^6+589 t^4-41 t^2+1=0$$ (the other factors were not printed).

Looking at the numerical results for $2\leq n\leq 10000$, my surprise has been to notice that the solution is $$x_n\approx \frac \pi{2n-1}\tag 1$$ which the reciprocal of the harmonic mean of the bounds ( this is exactly true for $n=2$ ).

For $x_4$, the approximation gives $\approx 0.448799$ while the exact solution is $\cos ^{-1}\left(\frac{\sqrt{9+\sqrt{17}}}{4}\right)\approx 0.437896$.

For $x_{10000}$, the approximation gives $0.000157087$ while the "exact" solution is $0.000157097$.

Using $y_n=\frac \pi{2n-1}$, polynomial regressions $$x_n=\sum_{i=1}^m a_i y^i$$ lead to extremely good fits with highly significant parameters. As an example, for $m=4$ $$\begin{array}{clclclclc} \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\ a & +0.997756 & 0.0000157 & \{+0.997726,+0.997786\} \\ b & -0.125612 & 0.0001336 & \{-0.125874,-0.125350\} \\ c & +0.202807 & 0.0002973 & \{+0.202224,+0.203390\} \\ d & -0.077174 & 0.0001766 & \{-0.077520,-0.076828\} \\ \end{array}$$ Even with a single term in the regression, $R^2=0.999886$.

My attempts based on Taylor series around the approximation were totally unsuccessful.

My questions are :

1.Is there any way to justify $(1)$ and/or to obtain a better approximation ?

2.Could an asymptotics of the solution be derived ?


After @Did's very interesting comment, I generated the solutions $x_n$ for $1000\leq n\leq 250000$ $(\Delta n =1000)$ and made a curve fit to the model $$x_n=\frac{\pi }{a n+b+\frac{c}{\log (n)}}$$ The fit is extremely good (all residuals being smaller than $2\times 10^{-12}$) and the parameters are highly significant $$\begin{array}{clclclclc} \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\ a & +2.00000 & 5.8\times 10^{-9} & \{+2.00000,+2.00000\} \\ b & -0.02216 & 0.000108935 & \{-0.02237,-0.02194\} \\ c & -1.74434 & 0.000719344 & \{-1.74576,-1.74293\} \\ \end{array}$$

This is almost exactly what @Did suggested !!


After Daniel Fischer's answer and Did's comment, I restarted the fitting work for the range $5\times 10^4\leq n\leq 5\times 10^5$ $(\Delta n =10^3)$ and used, as a model, $$x_n=\frac{\pi }{a n+\frac{b}{\log (n)}}$$ $$\begin{array}{clclclclc} \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\ a & +2.00000 & 6.02 \times 10^{-9}& \{+2.00000,+2.00000\} \\ b & -1.95234 & 0.00545 & \{-1.96306,-1.94162\} \\ \end{array}$$ I also considered separately $y_n=\frac{2n_n}{2n x_n-\pi}$ for which $$\begin{array}{clclclclc} \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\ c & 1.02127 & 0.00008 & \{1.02112,1.02142\} \\ \end{array}$$ This confirms the previous fit. In order to double check, I also minimized the sum of the squares of relative errors : this lead to the same result $(a=2.00000,b=-1.96355)$.

I also consider (as Did asked after Daniel Fischer's answer) $$x_n\approx\frac{\pi}{2n}\left(1+\frac{c}{n\log n}\right)$$ for which was obtained $$\begin{array}{clclclclc} \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\ c & 0.97571 & 0.00123 & \{0.97329,0.97813\} \end{array}$$

Now, considering the two models $$x_n^{(1)}=\frac{\pi }{2 \left(n-\frac{1}{\log (n)}\right)} \qquad x_n^{(2)}=\frac{\pi}{2n}\left(1+\frac{1}{n\log n}\right)$$ over the set of data points the sum of squared errors are respectively $1.24\times 10^{-20}$ and $6.94\times 10^{-23}$.

A friend of mine challenged me asking to show the iterations of the root finding method for $n=10^6$. Here they are

$$x_0= 1.570796440492926 \times 10^{-6}$$ $$x_1= 1.570796438443414 \times 10^{-6} $$ $$x_2= 1.570796438479340 \times 10^{-6} $$ $$x_3= 1.570796438479351 \times 10^{-6}$$

Many thanks to all of you for your contributions.

  • $\begingroup$ I performed some naive computation and it shows $\pi/x_n$ tends to $2n$ instead of $2n-1$. However, I know nothing about numerical methods so probably I am not getting the right results :( $\endgroup$ Oct 10, 2016 at 7:54
  • $\begingroup$ @CaveJohnson. The problem is that this would correspond to the left asymptote. So, it cannot be the solution. If $n\to \infty$ , the $1$ does not matter (as you noticed). Thanks for playing with my junk ! Cheers. $\endgroup$ Oct 10, 2016 at 8:01
  • $\begingroup$ are you certain that $x_3$ is exactly $\pi/5$ ? $\endgroup$
    – mercio
    Oct 10, 2016 at 9:17
  • $\begingroup$ @mercio. Thanks for pointing my mistake ! $\endgroup$ Oct 10, 2016 at 9:22
  • 6
    $\begingroup$ The first positive root $x_n$ happens just after $nx$ crosses the $a=\frac{\pi}2$ boundary since $\tan(u)\to-\infty$ when $u>a$, $u\to a$. Thus, $nx=a+y_n$ where $y_n\to0$ and the negative term $$\tan(nx)=-\cot(y_n)\sim-\frac1{y_n}$$ should compensate the sum of positive terms $$\sum_{k=1}^{n-1}\tan(kx_n)\approx\sum_{k=1}^{n-1}\cot(ka/n)\approx\sum_{k=1}^{n-1}n/(ka)\approx n\log n/a$$ (This equivalent should be checked.) This seems to indicate that $$y_n\approx a/(n\log n)$$ and $$x_n=a/n+a/(n^2\log n)(1+o(1))$$ that is, $$x_n\approx\frac{\pi}{2\left(n-\frac1{\log n}\right)}$$ $\endgroup$
    – Did
    Oct 10, 2016 at 11:49

2 Answers 2


Did is spot on. I'm not surprised, because he usually is, but I had to calculate to be sure that the used approximations were good enough to yield the right result.

For $n \in \mathbb{N}\setminus \{0\}$, let

$$f_n(x) = \sum_{k = 1}^n \tan (kx)$$

and $x_n$ the smallest positive zero of $f_n$. Then $f_n$ is an entire $\pi$-periodic meromorphic function with simple poles at the points of

$$P = \biggl\{ \frac{2m+1}{2k}\pi : m \in \mathbb{Z},\, 1 \leqslant k \leqslant n\biggr\}.$$

On $\mathbb{R}\setminus P$, $f_n$ is real valued, and $f_n' > 0$, so $f_n$ maps each interval between consecutive poles diffeomorphically onto $\mathbb{R}$. The case $n = 1$ is trivial ($f_1 = \tan$), and for $n \geqslant 2$ the two smallest positive poles are at $\frac{\pi}{2n}$ and $\frac{\pi}{2(n-1)}$. Since $f_n(0) = 0$ and $f_n' > 0$ on $\mathbb{R}\setminus P$, we have $f_n(x) > 0$ for $0 < x < \frac{\pi}{2n}$, so it follows that $x_n \in \bigl(\frac{\pi}{2n},\frac{\pi}{2(n-1)}\bigr)$, and $f_n$ has - for $n \geqslant 2$ - no other zeros in that interval. It is easily seen that $x_2 = \frac{\pi}{3}$, so in the following we assume $n \geqslant 3$. Since

\begin{align} f_n \biggl(\frac{\pi}{2n-1}\biggr) &= f_{n-2}\biggl(\frac{\pi}{2n-1}\biggr) + \tan \frac{\pi(n-1)}{2n-1} + \tan \frac{\pi n}{2n-1}\\ &= f_{n-2}\biggl(\frac{\pi}{2n-1}\biggr) + \tan \biggl(\frac{\pi}{2} - \frac{\pi}{4n-2}\biggr) + \tan \biggl(\frac{\pi}{2} + \frac{\pi}{4n-2}\biggr)\\ &= f_{n-2}\biggl(\frac{\pi}{2n-1}\biggr)\\ &> 0, \end{align}

it follows that $x_n \in \bigl(\frac{\pi}{2n}, \frac{\pi}{2n-1}\bigr)$. Write $x_n = \frac{1}{n}\bigl(\frac{\pi}{2} + \delta_n\bigr)$. Then $0 < \delta_n < \frac{\pi}{4n-2}$, in particular $\delta_n < \frac{3}{5} x_n$.

We use $\tan \bigl(\frac{\pi}{2} - x\bigr) = \cot x$, and

$$\frac{1}{x} - \frac{x}{2} < \cot x < \frac{1}{x} - \frac{x}{3}\tag{1}$$

for $0 < x < \frac{\pi}{2}$ in our calculations. First we have

$$-\tan (n x_n) = -\tan \biggl(\frac{\pi}{2} + \delta_n\biggr) = \cot \delta_n = \frac{1}{\delta_n} + O(\delta_n).\tag{2}$$

To determine the asymptotic behaviour of $\delta_n$, we next note that (since $f_n(x_n) = 0$)

\begin{align} -\tan (nx_n) &= \sum_{k = 1}^{n-1} \tan (k x_n)\\ &= \sum_{m = 1}^{n-1} \tan \bigl((n-m)x_n\bigr)\\ &= \sum_{m = 1}^{n-1} \tan \biggl(\frac{\pi}{2} - (mx_n - \delta_n)\biggr)\\ &= \sum_{m = 1}^{n-1} \cot (mx_n - \delta_n). \end{align}

The inequalities $(1)$ now yield

$$\sum_{m = 1}^{n-1} \frac{1}{m x_n - \delta_n} - \frac{1}{2} \sum_{m = 1}^{n-1} (m x_n - \delta_n) < -\tan (n x_n) < \sum_{m = 1}^{n-1} \frac{1}{m x_n - \delta_n} - \frac{1}{3} \sum_{m = 1}^{n-1} (m x_n - \delta_n).\tag{3}$$

We find

$$\sum_{m = 1}^{n-1} (m x_n - \delta_n) = \frac{n(n-1)}{2}x_n - (n-1)\delta_n = (n-1)\frac{\pi - 2\delta_n}{4}$$


\begin{align} \sum_{m = 1}^{n-1} \frac{1}{m x_n -\delta_n} &= \sum_{m = 1}^{n-1} \frac{1}{m x_n} + \frac{\delta_n}{x_n^2} \sum_{m = 1}^{n-1} \frac{1}{m\bigl(m - \frac{\delta_n}{x_n}\bigr)}\\ &= \frac{\log n + \gamma + O(n^{-1})}{x_n} + O(\delta_n x_n^{-2}). \end{align}

With $x_n^{-1} \sim \frac{2}{\pi} n$ it follows that

$$\frac{1}{\delta_n} \sim - \tan (n x_n) = \frac{2}{\pi}n \log n + O(n),$$


$$\delta_n = \frac{\pi}{2n\log n}\bigl( 1 + O\bigl((\log n)^{-1}\bigr)\bigr).\tag{4}$$

With some tedious work, we can get some bounds on the $O\bigl((\log n)^{-1}\bigr)$ term in $(4)$, but since $\frac{\pi}{12} < \frac{2\gamma}{\pi} < \frac{\pi}{8}$, what we have isn't sufficient to even determine whether it is $\Theta\bigl((\log n)^{-1}\bigr)$.

However, $(4)$ suffices to show that

$$\begin{split}x_n &= \frac{1}{n}\biggl(\frac{\pi}{2} + \delta_n\biggr) = \frac{\pi}{2n}\biggl(1 + \frac{1 + O\bigl((\log n)^{-1}\bigr)}{n\log n}\biggr)\\ &= \frac{\pi}{2n\bigl(1 - \frac{1 + O((\log n)^{-1})}{n\log n}\bigr)} = \frac{\pi}{2\bigl(n - (\log n)^{-1} + O((\log n)^{-2})\bigr)}.\end{split}\tag{5}$$

Concerning the difference between the empirical best-fit constants and the exact asymptotic values, recall Legendre's constant. The logarithm is a very slowly varying function, to eliminate effects of constants from empirical estimates, one may need very large numbers. However, it may be that $250000$ is large enough, and the difference between the best-fit and the exact values is caused by the larger deviation from the asymptotic behaviour for the smaller $n$. Try a best-fit for e.g. $200000 \leqslant n \leqslant 250000$ to see what that gives.

  • $\begingroup$ i was working with an very similar approach, but what has bugged me (and was avoiding me from posting an answer) was the justification why we can replace $\cot(x)\sim 1/x $ for any $m$. can you comment on this? Very nice answer btw (+1) $\endgroup$
    – tired
    Oct 12, 2016 at 9:39
  • 1
    $\begingroup$ It turns out that we can do that because of $(1)$. The error made by that replacement is $\Theta(x)$, and it turns out that this is small enough to not influence the asymptotic behaviour (the sum of these errors is $\Theta(n)$, and the sum of the $\frac{1}{x}$ terms is $\Theta(n\log n)$). I wasn't sure that would work before I did the calculations either. $\endgroup$ Oct 12, 2016 at 9:54
  • $\begingroup$ this makes sense, thank you very much! $\endgroup$
    – tired
    Oct 12, 2016 at 10:05
  • $\begingroup$ This is a fantastic answer ! Thank you so much. I shall redo the fit tomorrow morning and let you know. Cheers. $\endgroup$ Oct 12, 2016 at 10:18
  • $\begingroup$ @DanielFischer. Done and impressive ! Have a look to my update. Thanks again. $\endgroup$ Oct 13, 2016 at 4:31

This is not an answer, just a long comment. When you deal with quantities that converge to $0$ you have to be careful with the sence of the approximation. Notice that if we take any two sequences $x_n,y_n$ such that $$ x_n,y_n \in [\frac{\pi}{2n},\frac{\pi}{2n - 1}]$$ then $|x_n - y_n| \leq \frac{\pi}{2n - 2} - \frac{\pi}{2n} = \frac{2\pi}{(2n - 2)(2n)} = \Theta(\frac{1}{n^2})$ hence $$\frac{|x_n - y_n|}{x_n} = \Theta(\frac1n),$$ so even the relative error goes to $0$. So it may seems that $\frac{\pi}{2n- 1}$ is a good approximation but in fact is as good as any other. So to define a good approximation we should require instead $$\frac{|x_n - y_n|}{x_n} = o(\frac1n).$$ With this definition you can see at least numericaly that $\frac{\pi}{2n}$ is the right approximation as Cave jonhson pointed out.

  • $\begingroup$ I would totally agree if we could go to $o(\frac1{n^2})$ since $\frac \pi {2n}$ is the left asymptote. $\endgroup$ Oct 10, 2016 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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