a(1) = log(1.5), a(n+1) = log(1+a(n)), lim(n(na(n)-2)/log(n) = 2/3. numeric testing calculation

13 views
Skip to first unread message

Elim Qiu

unread,
Nov 16, 2017, 4:48:09 PM11/16/17
to mpmath
I have a sequence {a(n)} defined as a(1) = log(1+1/2.), a(n+1) = log(1+a(n)).
By analysis, I know that lim a(n) = 0,  lim na(n) = 2,  lim (n(na(n) -2))/log(n) = 2/3.

The more interesting property is that in order to have |(n(na(n) -2))/log(n) - 2/3| < 0u.01,
n needs to be greater than 10^140 (maybe more).

I tried to do some testing but Mathematica, Pari/GP cannot handle such recursion
at all. Python is fast enough but not accurate. So I'd like to try mpmath.

Could anyone tell me if I did it right and to what extend can I trust the numeric result?
0001.png

Helmut Podhaisky

unread,
Nov 17, 2017, 6:27:49 AM11/17/17
to mpm...@googlegroups.com
Dear Elim,

you can do those computations with Mathematica,

from

a[n_] := Module[{v, k}, v = 0.5`32;
​ ​
For[k =
​0, k < n, k++, v = Log[1 + v]]; v]
na[n_] := n*a[n]
A[n_] := n*(na[n] - 2)/Log[n]
na[5000]
na[677760]
na[677761]
A[677761]

one gets

​1.9993456813538159268512671629363540
​1.999999999999185463663068650858282264​
​2.000000000000636759504537359683291085​
3.214308654406640522846446*10^-8
​3.214308654406640522846445900750938119463549*10^-8 (same evaluation here, but with 50 digits by v=0.5`50 )

​This seems to indicate that your mpmath code works well.

​Note that the evaluation of log(1+x) ​for small x is a dangerous operation, because adding 1 to x cancels digits. To prevent this
some libraries provide log1p(x) := log(1+x) as a separate function, e.g. https://de.mathworks.com/help/matlab/ref/log1p.html .

Greetings, Helmut
> --
> You received this message because you are subscribed to the Google Groups "mpmath" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mpmath+un...@googlegroups.com.
> To post to this group, send email to mpm...@googlegroups.com.
> Visit this group at https://groups.google.com/group/mpmath.
> For more options, visit https://groups.google.com/d/optout.

Vinzent Steinberg

unread,
Nov 17, 2017, 8:25:08 AM11/17/17
to mpmath

I would recommend to use a loop instead of recursion in your Python implementation. This is more efficient and not limited by Python's stack size.

The most basic test you can do is increasing the precision and redoing the calculation. If the result changes, your precision was too low. If it does not change, it is a good sign, but judging how much you can trust the result requires a more involved analysis.

Vinzent
Reply all
Reply to author
Forward
0 new messages