3
$\begingroup$

The Dottie number is the solution to the equation

$\cos(x) = x$

It is approximately equal to $0.739085133215160641655312.$

This number can be expressed analytically in the following form (see this link):

$\displaystyle D = 2\sum_{n=0}^\infty \left( \frac{J_{4n+1}(4n+1)}{4n+1} - \frac{J_{4n+3}(4n+3)}{4n+3}\right) = 2\sum_{n=0}^\infty f(n)$

Trying to evaluate the infinite series above with NSum takes a lot of time, and gives numerical results for small finite upper bounds of summation. For example:

2*NSum[BesselJ[4*n + 1, 4*n + 1]/(4*n + 1) - 
   BesselJ[4*n + 3, 4*n + 3]/(4*n + 3), {n, 0, 2100}]

The result found is 0.739027 or

$\displaystyle 2\sum_{n=0}^{2100} f(n) = 0.739027...$

For bigger upper bounds of summation, one gets error messages.

Is there a way to better calculate or evaluate numerically the series with Mathematica?

$\endgroup$
  • $\begingroup$ If possible I want an answer about how to specifically calculate the value of the series mentioned in the question. $\endgroup$ – George Pa1 Feb 6 at 6:49
  • $\begingroup$ People here generally like users to post code as Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful $\endgroup$ – Michael E2 Feb 6 at 11:46
  • $\begingroup$ x /. First[Solve[Cos[x] == x && 0 < x < 1, x]] gives a usable Root[] expression for the Dottie number, which might be more convenient than trying to sum your series. $\endgroup$ – J. M. is away Feb 15 at 3:24
5
$\begingroup$

To specify the desired accuracy.

s = NestWhile[Cos, 0, (Abs[#2 - #1] > 10^-500) &, 2];
N[s, 500]
$\endgroup$
  • 4
    $\begingroup$ FixedPoint[Cos, 1``20, SameTest -> (Abs[#1 - #2] < 10^-500 &)] to avoid error messages on N::meprec. $\endgroup$ – Roman Feb 6 at 9:46
5
$\begingroup$

Amplifying @JM's comment, you can use Solve to get an exact expression for the Dottie number:

dottie = x /. First @ Solve[Cos[x]==x, x, Reals]

Root[{-Cos[#1] + #1 &, 0.73908513321516064166}]

This expression is exact, and can be numericized to any desired precision, e.g.:

N[dottie, 200]

0.73908513321516064165531208767387340401341175890075746496568063577328465488354759459937610693176653184980124664398716302771490369130842031578044057462077868852490389153928943884509523480133563127677223

$\endgroup$
5
$\begingroup$

If you insist on using the Bessel function summation, you could sum the exact terms for $n=0,1,2,\ldots,N$ and then use the series expansion

$$ J_n(n) = \frac{\Gamma(\frac13)}{2^{2/3}\cdot 3^{1/6} \cdot \pi}n^{-1/3} - \frac{1}{35\cdot 6^{1/3}\cdot\Gamma(\frac13)}n^{-5/3} - \frac{\Gamma(\frac13)}{225 \cdot 2^{2/3}\cdot 3^{1/6}\cdot \pi}n^{-7/3} +\mathcal{O}(n^{-11/3}) $$

to approximately sum the remaining terms $n=N+1,N+2,\ldots$ all the way to infinity:

f[n_] = BesselJ[n, n]/n;
fa[n_] = (Gamma[1/3]/(2^(2/3)*3^(1/6)*π)*n^(-1/3)
          - 1/(35*6^(1/3)*Gamma[1/3])*n^(-5/3)
          - Gamma[1/3]/(225*2^(2/3)*3^(1/6)*π)*n^(-7/3))/n;

With[{nn = 10},
  X = 2*Sum[f[4n+1]-f[4n+3], {n, 0, nn}] +
      2*Sum[fa[4n+1]-fa[4n+3], {n, nn+1, ∞}]] // N
(* 0.739085 *)
Cos[X] - X // N
(* 1.82089*10^-11 *)

In this way you get a much faster convergence in $N$. Using a higher-order series expansion would make it even faster; see math.SE #3162888 for a formula for the higher-order terms.

$\endgroup$
  • $\begingroup$ If I may ask, how did you find this splendid expansion ? $\endgroup$ – Claude Leibovici Mar 26 at 9:23
4
$\begingroup$

Another way to solve for the number $D$ numerically is to iterate the function:

x[n_] := x[n] = Cos[x[n - 1]];
x[0] = 1;

For example:

N[x[500], 200]

shows this to 200 decimal places. You can get bounds on the accuracy of the approximation by looking at terms like

N[x[3000], 1000] - N[x[5000], 1000]

which shows that the error is less than about 10^-500.

$\endgroup$
1
$\begingroup$

Here is a very impractical way to evaluate the Dottie number. Starting from the given Kapteyn series for the Dottie number in the OP, plug in an integral representation of the Bessel function of the first kind, and interchange summation and integration. That is, consider the integral

$$\small D=\frac2{\pi}\int_0^\pi\left(\sum_{n=0}^\infty\frac{\sin((4n+1)u)\sin((4n+1)\sin u)}{4n+1}-\sum_{n=0}^\infty\frac{\sin((4n+3)u)\sin((4n+3)\sin u)}{4n+3}\right)\mathrm du$$

To evaluate the resulting Fourier series, use the trigonometric product (Werner) formulae, which allows an expression in terms of the functions

$$\begin{align*}\sum_{n=0}^\infty\frac{z^{4n+1}}{4n+1}&=z\; {}_2 F_1\left({{\frac14,1}\atop{\frac54}}\middle|z^4\right)\\\sum_{n=0}^\infty\frac{z^{4n+3}}{4n+3}&=\frac{z^3}{3}{}_2 F_1\left({{\frac34,1}\atop{\frac74}}\middle|z^4\right)\end{align*}$$

with arguments $z=\exp(\pm i(u\pm\sin u))$. Performing the (tedious!) algebra with some help from Mathematica, we finally obtain

cc1 = u /. First[Solve[u - Sin[u] == π/2, u, Reals]];
cc2 = u /. First[Solve[u + Sin[u] == π/2, u, Reals]];

NIntegrate[With[{z = Exp[I (u - Sin[u])]}, 
                z Hypergeometric2F1[1/4, 1, 5/4, z^4] + 
                Hypergeometric2F1[1/4, 1, 5/4, z^-4]/z - 
                z^3/3 Hypergeometric2F1[3/4, 1, 7/4, z^4] - 
                Hypergeometric2F1[3/4, 1, 7/4, z^-4]/(3 z^3)] - 
           With[{z = Exp[I (u + Sin[u])]}, 
                z Hypergeometric2F1[1/4, 1, 5/4, z^4] + 
                Hypergeometric2F1[1/4, 1, 5/4, z^-4]/z - 
                z^3/3 Hypergeometric2F1[3/4, 1, 7/4, z^4] - 
                Hypergeometric2F1[3/4, 1, 7/4, z^-4]/(3 z^3)],
           {u, 0, cc2, cc1, π}, WorkingPrecision -> 35]/(2 π)
   0.73908513321516064165531208767387339

where we needed to compute the constants cc1 and cc2 to cope with the branch cut behavior of the hypergeometric function ${}_2 F_1$, which messes with the numerical integration.


As Roman astutely noted in his comment,

z Hypergeometric2F1[1/4, 1, 5/4, z^4] + 
Hypergeometric2F1[1/4, 1, 5/4, z^-4]/z - 
z^3/3 Hypergeometric2F1[3/4, 1, 7/4, z^4] - 
Hypergeometric2F1[3/4, 1, 7/4, z^-4]/(3 z^3) // FunctionExpand // Simplify
   ArcCot[z] + ArcTan[z]

and the integrand can thus be simplified to a piecewise constant function, such that Dottie's number can just be expressed as (cc1 - cc2)/2.

$\endgroup$
  • $\begingroup$ I assume you realize that the method and effort to calculate cc1 and cc2 is identical to calculating the Dottie number directly with @CarlWoll's method. $\endgroup$ – Roman Mar 15 at 7:37
  • $\begingroup$ Exactly why "very impractical" is in the first sentence. $\endgroup$ – J. M. is away Mar 15 at 7:43
  • 1
    $\begingroup$ The hypergeometrics can be simplified dramatically to ArcCot[z] + ArcTan[z], so that for $u\in (0,cc_2)$ the integrand is zero, for $u\in (cc_2,cc_1)$ it is $\pi$, and for $u\in (cc_1,\pi)$ it is zero again; with these, the integral becomes simply $D=(cc_1-cc_2)/2$. So at the end only the branch cuts of the hypergeometric integral remain and determine $D$. $\endgroup$ – Roman Mar 15 at 7:58
  • $\begingroup$ Oh, you're right! I didn't even think to simplify the hypergeometrics at once. At the very least, that verifies the correctness of the Kapteyn series in the OP. $\endgroup$ – J. M. is away Mar 15 at 8:07

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.