Jump to content

Talk:Chudnovsky algorithm: Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
SineBot (talk | contribs)
m Signing comment by Eje211 - ""
Kogorman (talk | contribs)
partial answer given
Line 19: Line 19:


Why is this an integer division given that the whole calculation is in arbitrary-precision floats? <!-- Template:Unsigned --><small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:Eje211|Eje211]] ([[User talk:Eje211#top|talk]] • [[Special:Contributions/Eje211|contribs]]) 01:21, 27 May 2018 (UTC)</small> <!--Autosigned by SineBot-->
Why is this an integer division given that the whole calculation is in arbitrary-precision floats? <!-- Template:Unsigned --><small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:Eje211|Eje211]] ([[User talk:Eje211#top|talk]] • [[Special:Contributions/Eje211|contribs]]) 01:21, 27 May 2018 (UTC)</small> <!--Autosigned by SineBot-->

=== possible reason ===
I tried changing '//' to '/' and got an error because '/' is not supported by Decimal objects. The good news is that I checked the output of the longest of the runs, and compared them with the output
of a completely different algorithm, and they were identical. The code (based on https://gist.github.com/markhamilton1/9716714) is much simpler, but also pretty fast (they both run in about a second on my hardware).

q, r, t, k, n, l = 1, 0, 1, 1, 3, 3
while True:
if 4*q+r-t < n*t:
yield n
nr = 10*(r-n*t)
n = ((10*(3*q+r))//t)-10*n
q *= 10
r = nr
else:
nr = (2*q+r)*l
nn = (q*(7*k)+2+(r*l))//(t*l)
q *= k
t *= l
l += 2
k += 1
n = nn
r = nr
[[User:Kogorman|kogorman]] ([[User talk:Kogorman|talk]]) 00:26, 10 October 2018 (UTC)

Revision as of 00:27, 10 October 2018

WikiProject iconMathematics Stub‑class Low‑priority
WikiProject iconThis article is within the scope of WikiProject Mathematics, a collaborative effort to improve the coverage of mathematics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StubThis article has been rated as Stub-class on Wikipedia's content assessment scale.
LowThis article has been rated as Low-priority on the project's priority scale.

Plagiarism

The materials which I saw in this footnote are first wrong and also stolen from another web site. Sunos 6 (talk | contribs) 05:15, 9 April 2008 (UTC)[reply]

Usage

How can the reader use this algorithm - from what point he can certainly know the n-th digit after the decimal dot is correct? 79.179.42.44 (talk) 21:16, 16 February 2012 (UTC)[reply]

The error will be approximately equal to the next term, so by estimating very roughly the size of the next term, you know up to where the approximation is correct. The factor (6k)!/(3k)!k!^3 grows by a factor 693, 982, 1147, 1252 for the first 5 terms, and ~ 1500 for the next 20 terms. This is to be divided by 262537412640768000, which yields a ratio of ~ 1.5e14 between subsequent terms. If this is not wrong, it should yield roughly 14 more digits at each step. — MFH:Talk 17:50, 14 March 2018 (UTC)[reply]

multiple of e ?

The link between 640320 and e^(pi sqrt 163) is given, but is there a simple explanation for 13591409 x 2e-7 = 2.7182818 ~ e? — MFH:Talk 17:32, 14 March 2018 (UTC)[reply]

Integer division in the Python code

In the Python section, on the line

   M = (K**3 - 16*K) * M // k**3

Why is this an integer division given that the whole calculation is in arbitrary-precision floats? — Preceding unsigned comment added by Eje211 (talkcontribs) 01:21, 27 May 2018 (UTC)[reply]

possible reason

I tried changing '//' to '/' and got an error because '/' is not supported by Decimal objects. The good news is that I checked the output of the longest of the runs, and compared them with the output of a completely different algorithm, and they were identical. The code (based on https://gist.github.com/markhamilton1/9716714) is much simpler, but also pretty fast (they both run in about a second on my hardware).

   q, r, t, k, n, l = 1, 0, 1, 1, 3, 3                                                                                               
   while True:
       if 4*q+r-t < n*t:
           yield n
           nr = 10*(r-n*t)
           n  = ((10*(3*q+r))//t)-10*n
           q  *= 10
           r  = nr
       else:
           nr = (2*q+r)*l
           nn = (q*(7*k)+2+(r*l))//(t*l)
           q  *= k
           t  *= l
           l  += 2
           k += 1
           n  = nn
           r  = nr

kogorman (talk) 00:26, 10 October 2018 (UTC)[reply]