All positive solutions of $\tan x=x$ If $x_1,x_2,\cdots$ are all positive solutions of the equation $\tan x-x=0$ Find value of:
$$S=\sum_{k=1}^{\infty}\cos^2(x_k)$$
My try:
The first solution will be in the interval $\left(\frac{\pi}{2}, \frac{3\pi}{2}\right)$ in which $\tan x$ is monotonic. 
So the solution in that interval is given by $$x_1=\tan^{-1}(x_1)$$
So $$\cos(x_1)=\cos(\tan^{-1}(x_1))=\frac{1}{\sqrt{1+x_1^2}}$$
Hence
$$S=\sum_{k=1}^{\infty}\frac{1}{1+x_k^2}$$
Any way to proceed here?
 A: This reminds me of an old AoPS thread. Not exactly the same problem - that was $\sum_k \frac1{x_k^2}$ - but similar ideas should apply. Following my argument over there, we will try to find an analytic function with residues $\frac1{1+x_k^2}=\cos^2 x_k$ at its poles, which also decays in the right places (away from the real axis, and on the vertical segments we'll use).
$$\text{Let }f(z) = \frac{z\sin z}{(z^2+1)(\sin z-z\cos z)}$$
This $f$ has poles at each $x_k$, at $0$, and at $\pm i$. Each of those poles are simple; this is clear for the $x_k$ and $\pm i$, and at zero $f(z)=\frac{z^2+O(z^4)}{(1+O(z^2))(z-\frac16z^3+O(z^5)-z+\frac12z^3+O(z^5))}=\frac{z^2+O(z^4)}{\frac13z^3+O(z^5)}=\frac3z+O(z)$.
Now, the residues. At a root $x_k$, we have $\sin x_k=x_k\cos x_k$, or $x_k=\tan x_k$. The residue of $f$ there is
$$R(x_k) = \left.\frac{z\sin z}{z^2+1}\right|_{z=x_k}\cdot\left.\frac1{\frac{d}{dz}(\sin z-z\cos z)}\right|_{z=x_k} = \frac{x_k\sin x_k}{x_k^2+1}\cdot\frac1{x_k\sin x_k}=\frac1{x_k^2+1}$$
The residue $R(0)$ at zero is $3$ by our power series calculation above. The residues at $\pm i$ are
$$R(\pm i) = \left.\frac{z\sin z}{\sin z-z\cos z}\right|_{z=\pm i}\cdot\left.\frac1{\frac{d}{dz}(z^2+1)}\right|_{z=\pm i} = \frac{\pm i}{1-\pm i\cot\pm i}\cdot \frac1{\pm 2i}=\frac1{2(1-\coth 1)}$$
using $\cos it=\cosh t$ and $\sin it=i\sinh t$ there.
And now, we build a contour integral to take advantage. Consider $I(N,M)=\int_C f(z)\,dz$, where $f$ is the rectangle with vertices at $N\pi+iM, -N\pi+iM, -N\pi-iM, N\pi-iM$ for some large $M$ and large integer $N$. For convenience, also rewrite $f(z)=\frac{z}{z^2+1}\cdot \frac1{1-z\cot z}$. Now, on a vertical segment $N\pi+iy$, $\cot z=\frac{\cos(N\pi)\cosh y}{i\cos(N\pi)\sinh y}=-i\coth y$ and
$$f(N\pi+iy)= \frac{N\pi + iy}{N^2\pi^2-y^2+1+2N\pi yi}\cdot \frac1{N\pi i+1-y\coth y}$$
As long as $M \le N\pi$, $N^2\pi^2>y^2$ and $|z^2+1|>z^2$ on the vertical segment. The first term is then less than $|z|^{-1}<\frac1{N\pi}$ in absolute value, and the second term is less than $\frac1{N\pi}$ in absolute value. Integrating that product over a length of $2M$, we get at most $\frac{2M}{(N\pi)^2}\le\frac{2}{N\pi}$.
On the horizontal segments, we have that $\cot (x+iy)$ tends to $-i$ uniformly as $y\to\infty$ and to $i$ uniformly as $y\to-\infty$. Choose $M$ so that it's within $\epsilon$ on the segments $x+\pm iM$, and we have
$$|f(z)|\le \frac{|z|}{|z|^2-1}\cdot\frac1{(1-\epsilon)|z|-1}$$
By limit comparison to $\frac1{M^2}$, the integral of this is at most a constant times $\frac{N}{M^2}$. As long as $N$ isn't too much larger than $M$ - say, $M=N\pi$ to match the other direction - this goes to zero.
Therefore, $\lim_{N\to\infty}I(N,N\pi) = 0$. And now, we calculate the integral by the residue theorem. Inside the contour, there are $2N+1$ poles: $0,i,-i,x_1,-x_1,\dots,x_{N-1},-x_{N-1}$. The residue at each $x_k$ is equal to that at each $-x_k$, and
$$I(N,N\pi) = 2\pi i\left(3+\frac1{2(1-\coth 1)}+\frac1{2(1-\coth 1)} + \sum_{k=1}^{N-1}\frac1{x_k^2+1}+\sum_{k=1}^{N-1}\frac1{x_k^2+1}\right)$$
$$0 = 3+\frac1{1-\coth 1}+2\sum_{k=1}^{\infty}\frac1{x_k^2+1}$$
$$\sum_{k=1}^{\infty}\frac1{x_k^2+1} = -\frac12\left(\frac{\sinh 1}{\sinh 1-\cosh 1}+3\right)=\frac12\left(e\cdot\frac{e-e^{-1}}{2}-3\right)=\frac{e^2}{4}-\frac74$$
A: We will use techniques similar to those used in this answer.

Consider the function
$$\newcommand{\Res}{\operatorname*{Res}}\newcommand{\Im}{\operatorname{Im}}
f(z)=\frac{\frac{z^2}{1+z^2}}{\tan(z)-z}\tag1
$$
$f$ has $3$ singularities other than those in $S=\{z_n\in\mathbb{C}\setminus\{0\}:\tan(z_n)=z_n\}$: $\{0,+i,-i\}$.

Near $z=0$, we have $\tan(z)=z+\frac{z^3}3+O\!\left(z^5\right)$, thus,
$$
\begin{align}
f(z)
&=\frac{z^2\left(1+O\!\left(z^2\right)\right)}{\frac{z^3}3\left(1+O\!\left(z^2\right)\right)}\\
&=\frac3z+O(z)\tag2
\end{align}
$$
Therefore,
$$
\Res_{z=0}(f(z))=3\tag3
$$

Near $z=i$, we have $\frac1{1+z^2}=\frac1{z+i}\frac1{z-i}$, thus,
$$
\begin{align}
f(z)
&=\frac1{z-i}\frac{\frac{i^2}{2i}}{\tan(i)-i}+O(1)\\
&=\frac1{z-i}\frac1{2(\tanh(1)-1)}+O(1)\tag4
\end{align}
$$
Therefore,
$$
\Res_{z=i}(f(z))=\frac1{2(\tanh(1)-1)}\tag5
$$

Since $f$ is odd,
$$
\Res_{z=-i}(f(z))=\frac1{2(\tanh(1)-1)}\tag6
$$

Near $z=z_n$, where $z_n\in S$, we have
$$
\begin{align}
f(z)
&=\frac1{z-z_n}\frac{\frac{z_n^2}{1+z_n^2}(z-z_n)}{\tan(z)-z}+O(1)\\
&=\frac1{z-z_n}\frac{\frac{\tan^2(z_n)}{1+\tan^2(z_n)}}{\sec^2(z_n)-1}+O(1)\\[6pt]
&=\frac{\cos^2(z_n)}{z-z_n}+O(1)\tag7
\end{align}
$$
Therefore,
$$
\Res_{z=z_n}(f(z))=\cos^2(z_n)\tag8
$$

For each $k\in\mathbb{Z}$,
$$
|\tan(k\pi+iy)|=|\tanh(y)|\lt1\tag9
$$
Furthermore, for $\Im(z)\gt\pi$,
$$
|\tan(z)|\le\coth(|\Im(z)|)\le\coth(\pi)\tag{10}
$$
Therefore, on the square of side $2k\pi$ centered at $0$, we have $|\tan(z)|\le\coth(\pi)$. Thus, on those squares,
$$
\begin{align}
f(z)
&=\frac{1+O\!\left(\frac1{z^2}\right)}{-z\left(1+O\!\left(\frac1z\right)\right)}\\
&=-\frac1z+O\!\left(\frac1{z^2}\right)\tag{11}
\end{align}
$$
Therefore, the sum of all the residues is $-1$.

Pulling together $(3)$, $(5)$, $(6)$, $(8)$, and $(11)$, we get
$$
-1=3+\frac1{\tanh(1)-1}+\sum_{z_n\in S}\cos^2(z_n)\tag{12}
$$
gives
$$
\begin{align}
\sum_{z_n\in S}\cos^2(z_n)
&=-4-\frac1{\tanh(1)-1}\\
&=\frac{e^2-7}2\tag{13}
\end{align}
$$
This includes both positive and negative solutions of $\tan(x)=x$. Thus, the sum over the positive solutions is
$$
\sum_{z_n\in S^+}\cos^2(z_n)=\frac{e^2-7}4\tag{14}
$$
A: If you look at the MathWorld page "du Bois-Reymond Constants", you will see that $S$ is one half of the second du Bois-Reymond constant, $C_2$.  It is somewhat astonishing that an explicit formula for $C_2$ is available in terms of $e$:
$$
C_2 = \frac{e^2 - 7}{2} \approx 0.194528049465
$$
Consequently,
$$
S = \frac{e^2 - 7}{4} \approx 0.097264024733
$$
No hint of a proof is given there, but perhaps one of the references will help.
A: To me, what you wrote is very correct but I am not sure that an explicit solution does exist for the summation you are looking for.
The positive solutions  of the equation $x=\tan(x)$ can be written explicitely in series form as
$$x_k=q-\frac 1q-\frac 2{3\,q^3}-\frac {13}{15\,q^5}-\frac {146}{105\,q^7}-\frac {781}{315\,q^9}-\frac {16328}{3465\,q^{11}}-\cdots\qquad \text{where}\qquad q=(2k+1)\frac \pi 2$$ (have a look here).
If we use  $x_k \sim q$, we can get a lower bound for the sum
$$S_0=\sum_{k=1}^{\infty}\frac{1}{1+x_k^2}>\frac{(4 +\pi ^2) \tanh (1)-8}{2 \left(4+\pi ^2\right)}\approx 0.0923966$$
If we use  $x_k \sim q-\frac 1q$, a second approximation is (this had been given by a CAS)
$$S_1=\sum_{k=1}^{\infty}\frac{1}{1+x_k^2}>\frac{3 e^2+2 \sqrt{3} e \sin \left(\sqrt{3}\right)-3}{6 \left(1+e^2+2 e \cos \left(\sqrt{3}\right)\right)}-\frac{4
   \pi ^2}{16-4 \pi ^2+\pi ^4}\approx 0.0971218$$ For better approximations, I have not been able to get any closed form and only numerical evaluations have been made showinga value just a little greater than $S_1$.
Using all terms of the given expansion and computing, the sum is $\approx 0.0972640$.
