Befunge-98 (PyFunge), 120 bytes
cf*10p'<20p11>00p1+:30p:::*+39**6+:30g39**c-00g*10gv
>:2*1-*00g*a*^
^:p02*g02p01*a*-*g02\+g01*g00-2*5g03,+*86:/*5g02+*5<
Try it online!
This is borderline in terms of the timelimit. 10,000 digits take around 11 seconds on my laptop, but I'm sure there must be a "reasonable" PC that could do it faster than that.
However, if you're trying it out on TIO, note that it won't return anything until it hits the 60 second time limit, since the algorithm is designed to keep going forever. By that time you'll have a lot more than 10,000 digits though.
I'm using the Jeremy Gibbons spigot algorithm, which I think is the same as most other answers here. However, note that this relies on the interpreter having arbitrary precision memory cells, and the only implementation I'm aware of that supports that is PyFunge.
Explanation
cf*10p Initialise r to 180.
'<20p Initialise t to 60.
11 Initialise i and q on the stack to 1.
> Start of the main loop.
00p Save the current value of q in memory.
1+:30p Increment i and save a copy in memory.
:::*+39**6+ Calculate u = 27*(i*i+i)+6.
: Make a duplicate, since we'll need two copies later.
30g39**c-00g*10gv Calculate y = (q*(27*i-12)+5*r)/(5*t).
/*5g02+*5<
,+*86: Convert y to a character so we can output it.
*a*-*g02\+g01*g00-2*5g03 Calculate r = 10*u*(q*(i*5-2)+r-y*t)
p01 Save the updated r.
*g02 Calculate t = t*u
p02 Save the updated t.
>:2*1-*00g*a* Calculate q = 10*q*i*(i*2-1).
^:
^ Return to the start of the main loop.
1By tweetable, do you mean that the code must be less than 140 characters? – Ypnypn – 2015-03-15T19:30:36.287
@Ypnypn That was the idea. I am generally assuming that any golfed answer will be shorter than that in any case. – None – 2015-03-15T19:33:23.063
The challenge would be much more interesting if it was meant to display as many Pi digits as possible in a tweet (140 chars) AND in less than 10s. – xem – 2015-03-15T19:37:35.883
@xem That would be interesting as well. However having to output consecutive digits forever gives its own challenge. – None – 2015-03-15T19:40:10.150
5The problem in itself seems challenging without the character limitation. – BobTheAwesome – 2015-03-15T20:02:48.503
1@BobTheAwesome Removed the character limit by popular demand. – None – 2015-03-15T20:07:57.037
Most methods of calculating pi need some idea of desired accuracy (memory use). Though sums of an infinite series converge, storing the sum with total accuracy means storing it in lossless format (e.g. as
– Level River St – 2015-03-15T20:11:56.193a/b
where a&b are integers.) Can we assume infinite memory? Also, you can only print a digit once you're sure it wont be changed by a carry. Newton-raphson seems to use less memory but see discussion http://mathforum.org/library/drmath/view/65244.html . The BBP algorithm spits out hex digits without needing to remember previous ones, but it seems there's no known equivalent in decimal!@steveverrill Assume finite memory for the first 10,000 digits but you can assume infinite memory for the "must never terminate" part. – None – 2015-03-15T20:13:22.517
Do the digits have to be all after another, or can they be seperated by newlines? Do the digits have to start with
3.141
, or can they start with141
or even3141
? – orlp – 2015-03-15T23:50:41.483It's Pi, of course it needs the first digit, and of course it should print the decimal point. It wouldn't be Pi otherwise... it'd be
Pi - 3
, orPi * 10^n
. – mbomb007 – 2015-03-16T00:54:14.9701@mbomb007 It's not obvious at all that the decimal point must be printed, or that the digits may not be seperated by whitespace. The challenge is merely to "output consecutive digits of pi". The decimal dot is not a digit.
3141...
is that - consecutive digits of pi. – orlp – 2015-03-16T12:03:01.3871It would be best if the number printed out was Pi so there was no space between digits for example. It would be even better if it included the decimal point. – None – 2015-03-16T12:06:20.250