[HN Gopher] A formula for the nth digit of and ^n ___________________________________________________________________ A formula for the nth digit of and ^n Author : georgehill Score : 198 points Date : 2023-01-15 13:12 UTC (9 hours ago) (HTM) web link (arxiv.org) (TXT) w3m dump (arxiv.org) | tzs wrote: | In "n'th digit of and ^n" are both n the same? | | In other words, for say ^50 does the formula only give me the | 50th digit, or does it give me any arbitrary digit I want? | gnramires wrote: | Mathematicians (and other math subjects) use an interesting | notation that is something like a "semantically local | variable". A symbol like n can be reused multiple times, as | long as the context is clear you're allowed to do that. | coherentpony wrote: | > In "n'th digit of and ^n" are both n the same? | | Yes. | | > In other words, for say ^50 does the formula only give me the | 50th digit | | Yes. | | > or does it give me any arbitrary digit I want? | | It gives you the n-th digit of \pi^n. Here n is arbitrary. | dmurray wrote: | The article title says "powers of ", so presumably an arbitrary | digit. | mattkrause wrote: | I'm not sure that's right. | | The abstract and text say the nth digit of \pi^n, and the | worked example on page 2 uses the same n=1000 to find the | thousandth digit of \pi^{1000}. | dmurray wrote: | Yes, it looks like you're right. But I don't understand the | reasoning - is he actually saying you can use this formula | to compute pi^n to n decimal places? So it doesn't produce | arbitrary digits on their own, but excellent approximations | to pi^n? | | And this was by taking 4 terms of the zeta function | infinite product expansion. 2xn digits would presumably be | given by taking more terms (but quite a few, one for every | prime under 100, so in some sense this method has bad | convergence when you want the mth digit of pi^n and m >> | n). | mattkrause wrote: | Yeah, my sense is that the author knows this is more of a | neat trick than a "practical" way of calculating pi. | | There's a bit on page 5 about how the Chudnovsky method | totally blows this approach out of the water. | dmurray wrote: | Seems like the real breakthrough was computing large | Bernoulli numbers without a very precise value for pi, | and this is a relatively easy corollary for someone to | spot and get a paper out of. | mattkrause wrote: | IOW, the arXiv title might have lost the "nth" because of | some formatting thing. The title inside the PDF says "A | formula for nth digit of \pi and \pi^n" | [deleted] | [deleted] | [deleted] | nyc111 wrote: | Are there measurements of pi calculated by meausuring diameter | and circumference? How many digits can that pi have? | tucnak wrote: | So does it mean that these pi-calculating competitions & record | are now going to devolve to special olympiads in pointless | storage capacity? What will the super computers going to do in | view of this discovery? Fascinating times for humans as well as | for the machines... | imglorp wrote: | pfs: Never worry about data again! - | https://github.com/philipl/pifs | mojomark wrote: | Any file can be represented as a binary string, and a binary | string is just an integer value - which is to say binary | strings are simply indexes of files in binary space (i.e. the | set of all possible permutations of bits). | | Looks to me like nfs is simply transforming a binary space | index into a pi-space index. Some files may compress to a | smaller value than they are in binary space (if you get | lucky), but make no mistake, some files will be much much | larger (i.e. the files you're trying to store don't show up | in pi until an index value that is a virtually infinite | number of digits long). | cmehdy wrote: | From the repo: | | Why is this thing so slow? It took me five minutes to store | a 400 line text file! | | Well, this is just an initial prototype, and don't worry, | there's always Moore's law! | | So I'm guessing they are quite aware of the joke, and props | to them for the dedication to commit and write the code (or | the other way around) :) | pitaj wrote: | Yeah, that's the joke. | mojomark wrote: | Ah, I'm slow. Thanks | oh_sigh wrote: | We just need a formula that finds a sequence of digits in pi | instead of a single one. | amelius wrote: | Yes, we are too much focused on the reverse problem. | | We know exactly how much time we need to compute the nth | digit of pi. But how much time do we need to find a | specific string of digits? Seems like a more interesting | question. | adenozine wrote: | This is one of my favorite software projects of all time. I | remember seeing this several years ago and it has driven my | imagination crazy since then. | WithinReason wrote: | But why? | imglorp wrote: | For me, it stimulates a mental shift that could be good | exercise elsewhere: instead of storing the string, you | find the string somewhere and store its index. | | It also stimulate the imagination: what other | transcendental numbers might this work with? How long do | you have to search in the digits to find your string? | What can you say about the size of the index (how far you | searched) vs your string length? Etc. It's patterns all | the way down. | eapriv wrote: | It doesn't even work with pi. | WithinReason wrote: | I don't want to be a buzzkill, but to me this seems | uninteresting, you need more information to store the | index than the data, end of story. | sterlind wrote: | this is a great motivating example for the definition of | Kolmogorov complexity. | Jerrrry wrote: | It is my favorite fake-counter example. | zamadatix wrote: | It's actually not known if pi contains every combination of | digits (in any base 2 or greater) or not. It feels likely but | really all we know is it's transcendental and seems pretty | random from the parts we've generated. | | The library of babel could be a good "useless" backing though | https://libraryofbabel.info/bookmark.cgi?hnexample | Jerrrry wrote: | You just now convinced me how that site wasn't a sham. | Thank you. | | It takes the input, converts it into N, then calculates | position using the N. | | Thank you. I argued for a long time simply by being | ignorant. | | good bless ya sir. | mkl wrote: | Nothing will change there. There are already much more | efficient methods of calculating p. What this lets you do is | jump straight to the _n_ th digit without calculating all the | ones before it. | tyingq wrote: | Couldn't you "cheat" a bit in a timed competition if you knew | exactly how many digits you would reach, and kick this off in | parallel to extract a few more to tack to the end? Or would | the parallel job be too slow for that? Or the competitions | constrain CPU or other resources to a ceiling? | Someone wrote: | Why would it? Calculating the first few trillion digits may be | (and probably is) a lot faster than doing a trillion | calculations of individual digits, but even if it isn't, people | will simply raise the bar and compute even more digits. | | > What will the super computers going to do in view of this | discovery? | | Whatever they do now. It's not like this is what supercomputers | are built for. Computations like these more are used to get | confidence that the hardware works. | antiquark wrote: | Good ole Plouffe! | commandlinefan wrote: | The paper seems absolutely brilliant, but the grammar is very | strange (there's even what appears to be a typo in the paper | where he says "rand n" instead of "rank n"). Odd that he wouldn't | have worked with somebody with better written English before | publishing. | petschge wrote: | You have no idea how atrocious the English is in papers that I | see as a reviewer. And depending on journal I don't even get to | reject it for that as long as the science is sound. | MaxBarraclough wrote: | Can you insist the writing be improved for publication? | heywhatupboys wrote: | > And depending on journal I don't even get to reject it for | that as long as the science is sound. | | and you shouldn't. As long as it is somewhat legible, forcing | people who are not native English speakers to conform to | another language 100 % in order for their _science_ to be | published is horrendous. | | There was a time 300 years ago, where great thinkers who did | not speak French or German could not publish their thoughts | and answers, and to us now it seems atrocius. Let us not go a | head and redo that with English | Y_Y wrote: | The goal of publishing is that others can read your work. | If it's badly written it will be hard to understand, and | extra hard for non-natives. | heywhatupboys wrote: | actually, sometimes "native" English is much harder to | read for non-natives than a non-native writing, due to 1. | less vocabulary, and 2. more straight forward sentence | structure. | petschge wrote: | The problem is that "somewhat legible" is not a given and | you don't know if the version that comes out of language | editing (if it is still done, a lot of journals skip it to | save money) is still scientifically correct. | | Edit: A possible solution would be to have "good idea, | please language edit and send back for further review" as | an option along with "reject" / "needs major revisions" / | "needs minor revisions" / "accept". | anamexis wrote: | It isn't published, it's a pre-print. | xyzzyz wrote: | If you can download it from arxiv, it is published. | Researchers don't really care whether the paper went through | formal peer review and publication process in some journal, | because that process is of little value: they can figure out | that the author meant rank instead of rand etc. | petschge wrote: | There is definitely a difference between "public(ly | available on arxiv)" and "published (in a peer-reviewed | journal)". Depending what I want to do I may prefer on or | the other for my work as a researcher. | xyzzyz wrote: | Sure, but if the paper is never published in a journal, | and just exist as a pdf on arxiv forever, you won't treat | it any different than if it was published. You'll still | ignore it if it looks crap, still read it if it looks | promising, still tell your friends about it if it has | interesting results, still cite it etc. In short, it | doesn't matter much if the paper was formally published. | eesmith wrote: | The "doesn't matter much" is, I think, the crux of the | matter. | | commandlinefan's earlier negative aside concerned | language quality. | | IMO, I think people hold peer-review journal published | papers to a (slightly?) higher language quality standard | than what may be the first of several preprints. And I | think anamexis was pointing out that difference. | | As Wikipedia says: "The immediate distribution of | preprints allows authors to receive early feedback from | their peers, which may be helpful in revising and | preparing articles for submission." | https://en.wikipedia.org/wiki/Preprint | | I expect that may include identifying and fixing typos. | eesmith wrote: | "Published" in this context is short for "published to a | journal" or more completely for this thread "gone through | the full edit cycle you would expect from a paper published | to a journal". | | For example, https://arxiv.org/help/jref says: | | > When a article is published, the author may wish to | indicate this in the abstract listing for the article. For | this reason, the journal reference and DOI (Digital Object | Identifier) fields are provided for articles. | | This can only make sense if "public abstract on arxiv" is | not the same as "published" in the way you mean. | kwhitefoot wrote: | Don't abbreviate unless you have great confidence that | everyone hearing or reading your words shares the same | dictionary. | eesmith wrote: | And this is not the case here? | | I mean, there's always going to be today's 10,000 [1] who | doesn't know what, say, "VB.NET"[2][3] means. | | [1] https://xkcd.com/1053/ | | [2] https://news.ycombinator.com/user?id=kwhitefoot | | [3] https://en.wikipedia.org/wiki/Visual_Basic_(.NET) | | But explaining or footnoting everything defensively, | rather than pointing out misconceptions as they arise, | seems excessive. | | Further, someone may deliberately use a minority | definition in order to stress a philosophical point. One | valid viewpoint is that a publication is a publication is | a publication. A preprint, a blog post, or a peer- | reviewed journal publication should be given equal weight | as being "published." I'll call this position #1. | | Another valid point is that some works are incomplete, | and may go through multiple drafts before reaching the | final, "published" form, which it's best known by, and is | likely the most polished of the versions. I'll call this | position #2. | | Often people want feedback, and one way to get feedback | is by publishing a preprint. (There are others. I recall | reading of a mathematician, about a century ago, who | would first publish in his home country, and native | language, to get friendly feedback from colleagues, | before publishing in English. He's cited for his later | publication.) | | Someone who holds position #1 might fully understand that | I use the dictionary with position #2, and still | deliberately use position #1 in order to popularize that | #1 dictionary. The difference isn't one of confusion or | lack of knowledge, but one of viewpoints. | | Let me be clear - I'm not saying that that's the case | here. Instead, my example is meant to show it's not | necessarily so simple as "shares the same dictionary" or | not. | xyzzyz wrote: | I understand what it means, which you could have seen by | reading my comment carefully. My point is that this | publication process is of little value these days. | anamexis wrote: | I believe you when you say you understand, but your first | sentence was "If you can download it from arxiv, it is | published." Which is precisely what GP was responding to. | | Furthermore, this thread started with someone complaining | about the lack of polish which the publication process | can provide. | _ache_ wrote: | Plouffe ... | | He used to teach in my university. He is a fantastic man. This is | serious, he is crazy about numbers. He is one of the guy behind | OEIS (oeis.org). | | That is not the first formula he found about pi and some of the | previous one had been used to break world record about the number | of known decimals. | _ache_ wrote: | Ok, so the method is real but will not be used to break the | next world record. Chudnovsky algorithm is better at that task. | lifthrasiir wrote: | Not this one, but algorithms that can calculate the specific | digit positions but nothing else are indeed used for world | records, mainly for the verification. If two radically | different algorithms converge into the same digits at | something like the trillionth position then you will have a | high confidence for the rest of digits. | exmadscientist wrote: | Probably this is a good time for your irregular reminder that | Plouffe has something of a feud with Bailey and Borwein: | https://groups.google.com/g/sci.math.symbolic/c/a3kVKVYJhgc?... | | In my _very personal_ opinion, the overall publication history | of the three provides some rather good evidence for Plouffe 's | claims. | sega_sai wrote: | It is all curious, but it seems that procedure that calculates | the n-th digit using some other functions that require O(n) | calculations (i.e. Bernoulli numbers) is not that exciting, as | it's just a speedup comparing to a naive calculation (maybe a big | one but still). | | Although because pi is a transcendental number maybe it is | impossible to have an algorithm to return the n-th digit in O(1) | operations? Does anyone know ? | | Upd: thinking more about it, just to read all the digits of | number n, one needs log(n) operations, so I guess anything that | has performance of O(log(n)) can be considered easy (i.e. the | digits of rational numbers can be computed in O(logn). | paulpauper wrote: | exactly. this paper is trivial, sorry to say. | kdkdk wrote: | Even rational numbers which have repeating digits at the end | are not O(1) because in order to calculate the n-th digit you | need to calculate n modulo k where k is the length until the | number repeats its digits, which needs to read the entire input | number n (thus runs in O(log(n)). The only exception are | rational numbers with k being a power of two. Take | 0.1010101010..., you can get the n-th digit by reading off the | smallest digit of n and checking whether it is a 0 or a 1. | | There are transcendental numbers where the n-th digit can be | computed in O(log n) like Champerowne constant though. | ur-whale wrote: | The interesting question is: are there real numbers whose N-th | digit provably _cant_ be calculated in O(N)? | yongjik wrote: | Even better: there are (well defined) real numbers whose N-th | digit provably _cannot be computed_ at all. | | https://en.wikipedia.org/wiki/Chaitin%27s_constant | tooltower wrote: | The normal method for computing digits of pi is not O(n), so | this could still be interesting. I think it's probably better | to compare this with the BBP formula [1]. The commonly used | algorithm for pi I think still takes O(n log^3 n) time [2] | | [1] | https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%9... | | [2] https://en.wikipedia.org/wiki/Chudnovsky_algorithm | scythe wrote: | The interesting question, I think, is whether this formula can | help address the question of the normality of pi: | | http://en.wikipedia.org/wiki/Normal_number | | This is particularly exciting because the prevailing opinion had | been that we lack the mathematical tools to attack that problem. | moloch-hai wrote: | Doubting this will help show whether e^pi or pi^e is | transcendental. | lyschoening wrote: | > Note that the calculation of Bernoulli numbers can be done in | several ways, one of which requires knowing p with good precision | | This seems to be the catch. | phyphy wrote: | It's written "one of which," not "all of which." | 867-5309 wrote: | it's like "can find meaning of life" but "must already know | 6*7" | childintime wrote: | Chatgpt, please write a function in python for the nth digit of | pi. Sure, here is a function in Python that | calculates the nth digit of Pi using the Chudnovsky algorithm: | from decimal import * def nth_digit_of_pi(n): | getcontext().prec = n + 1 C = 426880 * | math.sqrt(10005) M = 1 L = 13591409 | X = 1 K = 6 S = L for i in | range(1, n): M = (K ** 3 - 16 * K) * M // i ** 3 | L += 545140134 X *= -262537412640768000 | S += Decimal(M * L) / X K += 12 | return +str(S / C)[n] | | Seems off, but I learned something: | https://www.wikiwand.com/en/Chudnovsky_algorithm | _visgean wrote: | Here is an article with an actual implementation | https://www.craig-wood.com/nick/articles/pi-chudnovsky/ | robinhouston wrote: | Interesting! If you correct the obvious errors, then it appears | to calculate 1/pi: >>> from decimal import | Decimal >>> import math >>> >>> def | nth_digit_of_pi(n): ... getcontext().prec = n + 1 | ... C = Decimal(426880 * math.sqrt(10005)) ... | M = 1 ... L = 13591409 ... X = 1 | ... K = 6 ... S = L ... for i in | range(1, n): ... M = (K ** 3 - 16 * K) * M // i | ** 3 ... L += 545140134 ... X | *= -262537412640768000 ... S += Decimal(M * L) | / X ... K += 12 ... return str(S / | C)[n] ... >>> "".join([ nth_digit_of_pi(i) for | i in range(50) ]) | '0.318309886183790698041462054251035408427213165074' | leoff wrote: | since this is Python, `nth_digit_of_pi(-1)` should give us the | last number of Pi. | manojlds wrote: | But it's not a list | 4gotunameagain wrote: | Traceback (most recent call last): File "<stdin>", | line 1, in <module> AttributeError: 'manojlds' object | has no attribute 'humour'. Did you mean: 'joke'? | manojlds wrote: | [flagged] | [deleted] | mjd wrote: | Genius. | detrites wrote: | Has anyone converted the formula to code? | z3t4 wrote: | here you go: n => Math.PI.toString()[n+2] | Maursault wrote: | But... pi is _in_ the formula. If you already know it, then why | bother? | [deleted] | [deleted] | davesque wrote: | Not sure where you're seeing that. Did you misread a formula? | Maursault wrote: | The very first denominator seen is (2p)^2n, the last | denominator on that line is the same, the first denominator | of the second line is p^2n+1 and the second denominator in | the second line is the same. Are you not seeing that? | rdlw wrote: | Are you talking about the inequality on the first page? | That is at the end of a sentence that starts "The | calculation is made from the two inequalities ...". The | next sentence is "By isolating p in both cases, we can | derive an approximation of the latter." | | That is not the formula. | krick wrote: | It isn't. | Maursault wrote: | Look at the first denominator seen in both lines of the | equation, the last denominator in the first part of the | equation, and the second denominator in the second part of | the equation. | colanderman wrote: | See also Plouffe's earlier (1995) formula to extract hexadecimal | digits of pi: | https://en.m.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80... | userbinator wrote: | ...which Fabrice Bellard improved upon: | https://en.m.wikipedia.org/wiki/Bellard%27s_formula | karmakaze wrote: | We should also have decimal/binary/hex digits of Tau to | complete the set. | cleak wrote: | Decimal is the only tricky one. Given that tau=2pi, simple | use f(n-1) in the original binary formula for pi, and I'm | sure something just as trivial for hex. | craigharley wrote: | Here is another | | const nDigitOfPi = (n) => (22/7).toString()[n+1] | NeutralForest wrote: | Finally, we can find the last digit of pi | sulam wrote: | This also means I can finally crack Jeff Dean's password. | spicybright wrote: | Now we just have to figure out what the last integer is | sidcool wrote: | The last digit of pi is e. | vittore wrote: | I thought it was keleven... | layer8 wrote: | According to most examples I've seen, the last digit of pi is | "...". | detrites wrote: | Spoiler: it's zero, recurring. | bhk wrote: | That would make it a rational number, so we can rule that out | detrites wrote: | Exactly, the only possible "last digit" it _could_ have (in | keeping with the silly premise that it has one), is zero. | tremon wrote: | The only possible "last digit" it could _not_ have is | zero: if the last digit were to be a zero, that digit | would be superfluous and could be discarded, making the | digit before that the real "last digit". | | Proof: the first digit of pi is 3, not zero. | detrites wrote: | _sigh_ It was said in jest, in response to another | comment also said in jest. | | That aside, the apparent "empty space" on the either side | of a number is in reality consisting of infinite zeroes. | | Just because we typically choose to "display" most | numbers without those zeroes, it doesn't mean they aren't | there in a very real, practical and important sense. | | They are there, because if they aren't there, then | something else _might be_ , and then all our numbers | would have to be assumed to be wrong or incomplete... so | instead, we assume the zeroes. | | The terrible reality is the zeroes extend off infinitely | in either direction, and we use empty space as shorthand | for this so we don't have to spend longer than the age of | the universe to write a single number with full accuracy. | delaaxe wrote: | Why is zero different than any other number? | qorrect wrote: | It acts as a terminator or terminal, see | https://news.ycombinator.com/item?id=34391483. | layer8 wrote: | If 0 would act as a terminator, then 1.203 would be equal | to 1.2. | | The thing that is actually special about the digit 0 is | that it is implied for all positions for which no digit | is given. That is, when we write | 1.2 | | we really mean ...00000001.20000000... | Flockster wrote: | I don't think that would be true seeing 1/3 = 0.3333.. , | or am I reading this wrong? | detrites wrote: | 3 recurring represents a particular quantity continuing | forever. | | 0 recurring represents the end of a quantity, and the | absence of any further quantity, forever. | | Eg: 0.012500000000000... | | The significant portion is 0.0125 - the recurring zeroes | serve a mathematical role akin to that of a full-stop in | a sentence. Hence zero being (jokingly, but in a sense | truthfully) _always_ the "last digit". | knome wrote: | This is just an artifact of representing it in base-10. | In base-3 0.0125 has the same value but would have a non- | terminating representation of 0.00010001... | | I will grant that in base-p, p is 10, however. | tedunangst wrote: | Can you prove it's not nine, recurring? | detrites wrote: | Yes... proving that would require an infinite-capacity | rounding mechanism, which cannot exist, because when trying | to build it, you always run out of universe. Thusly, | "impossible" is equivalent to "false", by default. | aqme28 wrote: | Yup, just plug in -1. | ashvardanian wrote: | Looks interesting! Does anyone know a practical application where | something like this would help? | xoa wrote: | > _Does anyone know a practical application where something | like this would help?_ | | It's another way to help verify super long calculations of pi | are correct, and in turn I guess one basic "practical | application" of calculating pi to many digits is as part of the | suite for verifying new hardware. How do you know that fancy | fresh new silicon is actually crunching the numbers correctly, | not producing garbage in some subtle way at enough significant | digits? While there are lots and lots of checks used to avoid a | repeat of hardware bugs of days past (like the forever infamous | Pentium FDIV), one simple sanity check/stress test is | calculating out numbers like pi a bunch of different ways to | huge numbers of digits and making sure the result is always | correct. If it's not there's clearly a problem somewhere. | chrisshroba wrote: | I believe it can be used to verify calculations of new digits | of pi. For example, if you tell me you just computed five | trillion digits of pi, I can ask you for specific digits near | the end and check that they match what this formula produces | CSMastermind wrote: | Wanted to compliment this paper for being well written. I'm not a | practicing mathematician but I was able to easily follow along | here and that was a cool feeling. | | Could someone who is a practicing mathematician speak to the | practical application of this? From what I understand from | reading this seems like an interesting curiosity but the | Chudnovsky formula it refers to seems to be better at doing the | same thing for any practical purpose. | nico wrote: | Is there a physical limit to how many digits of pi can ever be | computed/represented in the universe? | | For example, let's say we need one atom for each digit of pi that | we want to store, the max limit of digits of pi would be | something like the total number of atoms in the universe, minus | the atoms required to compute and store the digits. | | Has that been studied/calculated? | telotortium wrote: | in the title is a character I haven't seen before, [Mathematical | Italic Small Pi](https://unicode-table.com/en/1D70B/). | Sharlin wrote: | Yes, and there's also bold (pi), bold italic (), sans-serif | bold (), and sans-serif bold italic (), all distinct from the | run-of-the-mill Greek Small Letter Pi (p) which is often | rendered quite differently from the "standard mathematical pi" | in addition to, of course, being semantically different. | There's a lot of fun stuff in the Mathematical Alphanumeric | Symbols block (https://unicode- | table.com/en/blocks/mathematical-alphanumeri...) | ars wrote: | This is a type of https://en.wikipedia.org/wiki/Spigot_function | if you want to lookup more info. | saddist0 wrote: | Something like this can be used for "proof of work" in the | blockchain world. | swazzles0 wrote: | That's an interesting point. You could use this to hash 8-bytes | values (assuming int64) with infinitely scaling difficulty by | providing an offset to n where n = difficulty + n | paulpauper wrote: | There is nothing of note here. This paper should be in 'general | math', not number theory. You need to know the Bernoulli numbers | in order for this to work, which is more computationally | difficult than computing pi. So what. Yeah, Plouffe is a famous | person in computer science and math, but this does not measure up | to the hype. It reminds me of the stuff i tinkered with in high | school when i first learned infinite series ..but not | publishable-level, sorry. | dvt wrote: | > but not publishable-level, sorry | | No one's saying it is, this is arXiv, after all (not a | journal). Still a fun little interesting paper, though. | Someone wrote: | I would think the "explicit expression" part is new and enough | to make it publishable, and fail to see why not being useful in | practice ever should be a factor in determining whether | something is number theory. | | Now, for the hype, I don't see any from the authors. ___________________________________________________________________ (page generated 2023-01-15 23:00 UTC)