One of my favorite ways to waste time.

Using the tried and true method of looking up a result rather than calculating it (of course it requires a sufficient set of information) -

iMi7-2:jstuff jkt$ cat pi.ijs

   require 'jmf'
2 map_jmf_ 'pi';'/Users/jkt/Downloads/pi/y-cruncher v0.5.5.9187 (fix 2)/Pi - Dec - Chudnovsky.txt';'';1

   where =: 3 : 'I. (": y) E. pi'

iMi7-2:jstuff jkt$ ja pi.ijs

   NB. http://en.wikipedia.org/wiki/Feynman_point
   (760 + i.12) { pi
134999999837

   where 6666666666   NB. a beastly number...
386980413

   (386980413 + 5 + i: 8) { pi
70566666666669143

   102{. pi
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679

   $pi
500000002

I have amused myself by thinking about the probability of finding a specific number within the random sequence of pi. For example, the probability of any 10 digit sequence is fairly low. But one should certainly find shorter sequences -

   $where 123456789 NB. in the first 5e8 digits of pi
0
   $where 12345678
3
   $where 1234567
42

As I said, a favorite way to waste time.... One of these days I'll get some more memory and calculate more digits (the 5e8 digits required 4 Gbytes of ram - which is reasonably modest when one thinks about it).


On 2015/01/06 13:23 , Roger Hui wrote:
Ah, in that case you can use the formula in the Wikipedia page you cited
<https://en.wikipedia.org/wiki/Approximations_of_%CF%80#Digit_extraction_methods>.
The first formula has the factor (%16)^n .  That factor limits the
contribution to the n-th hex digit both from the left and from the right.

    g=: 3 : '+/ 4 _2 _1 _1 % 1 4 5 6 + 8x * y'
    10^.16
1.20412
    1e4%1.2
8333.33
    t=: g 8334
    t
8335925201r2470518805025963211
    0j_10 ": t
3.3741597854e_9

That is, for the 8334-th hex digit (approximately the 1e4-th decimal
digit), you probably don't need to look at many terms before the 8334-th
one, or any of the terms after it.

    2}.0j100 ": +/ (16x&^ %~ g"0) i.50
1415926535897932384626433832795028841971693993751058209749445922466544481906209319125159482533123957
    1}.":<.@o. 10^100x
1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679

Alternatively, enter

    f 1e4

and wait. :-)





On Tue, Jan 6, 2015 at 1:04 PM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:

to be more specific, a function that gets the 10000th digit of pi?


----- Original Message -----
From: Roger Hui <[email protected]>
To: Programming forum <[email protected]>
Cc:
Sent: Tuesday, January 6, 2015 3:58 PM
Subject: Re: [Jprogramming] nth digit of pi

Answering the letter if not the spirit of your question:

    f=: 3 : '10|<.@o. 10x^y'
    f"0 i.5 20
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4
6 2 6 4 3 3 8 3 2 7 9 5 0 2 8 8 4 1 9 7
1 6 9 3 9 9 3 7 5 1 0 5 8 2 0 9 7 4 9 4
4 5 9 2 3 0 7 8 1 6 4 0 6 2 8 6 2 0 8 9
9 8 6 2 8 0 3 4 8 2 5 3 4 2 1 1 7 0 6 7



On Tue, Jan 6, 2015 at 12:50 PM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:

I don't really understand this well:



http://en.wikipedia.org/wiki/Approximations_of_%CF%80#Digit_extraction_methods
is there a J program for finding the y th digit of pi (any base is ok)
----------------------------------------------------------------------


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to