Re: FatRat's falling back to Num's

2019-04-19 Thread Tom Browder
On Fri, Apr 19, 2019 at 17:27 Tom Browder wrote: > On Fri, Apr 19, 2019 at 17:07 Laurent Rosenfeld < > laurent.rosenf...@googlemail.com> wrote: > >> Sure Tom, >> for example, let's print the first 200 digits of pi. >> > ... > >> Ah, part of the secret is to use print! I was using say and not

Re: FatRat's falling back to Num's

2019-04-19 Thread Tom Browder
On Fri, Apr 19, 2019 at 17:07 Laurent Rosenfeld < laurent.rosenf...@googlemail.com> wrote: > Sure Tom, > for example, let's print the first 200 digits of pi. > ... > Thanks, Laurent! -Tom

Re: FatRat's falling back to Num's

2019-04-19 Thread Laurent Rosenfeld via perl6-users
Sure Tom, for example, let's print the first 200 digits of pi. Since I am getting about 1.2 * $n correct digits for a 0..$n range when calling the plouffe subroutine, it is sufficient to use the 0..200 range to get (more than) 200 correct digits. sub plouffe (Int $k) { my $result =

Re: FatRat's falling back to Num's

2019-04-19 Thread Tom Browder
On Fri, Apr 19, 2019 at 08:37 Laurent Rosenfeld via perl6-users < perl6-us...@perl.org> wrote: > Hello, > > in the context of the Perl Weekly Challenge, I was trying to use one of > Franco-Canadian mathematician Simon Plouffe's formulas to compute the > digits of pi. > Laurent, now that you have

Re: FatRat's falling back to Num's

2019-04-19 Thread Laurent Rosenfeld via perl6-users
Yes, Brian, you're right, it seems that it is enough to use a FatRat for the first term, even with an integer input of 400. Thank you very much. Quite likely because the first term's denominator is the only one that is growing very fast with an exponentiation, 16 ** $k, while the others only have

Re: FatRat's falling back to Num's

2019-04-19 Thread Laurent Rosenfeld via perl6-users
Thank you very much, Fernando, I'll try that as soon as I get back home. Cheers, Laurent. Le ven. 19 avr. 2019 à 16:00, Fernando Santagata a écrit : > This one works fine: > > sub plouffe (Int $k) { > my $result = 1.FatRat * (1 / 16 ** $k).FatRat * ((4 / (8 * $k + > 1)).FatRat - (2 / (8 *

Re: FatRat's falling back to Num's

2019-04-19 Thread Fernando Santagata
This one works fine: sub plouffe (Int $k) { my $result = 1.FatRat * (1 / 16 ** $k).FatRat * ((4 / (8 * $k + 1)).FatRat - (2 / (8 * $k + 4)).FatRat - (1 / (8 * $k + 5)).FatRat - (1 / (8 * $k + 6)).FatRat ); } say (plouffe $_).WHAT for ^20 I guess that until a certain point all the terms not

FatRat's falling back to Num's

2019-04-19 Thread Laurent Rosenfeld via perl6-users
Hello, in the context of the Perl Weekly Challenge, I was trying to use one of Franco-Canadian mathematician Simon Plouffe's formulas to compute the digits of pi. For this, I have written the following subroutine: sub plouffe (Int $k) { my $result = (1 / 16 ** $k) * ( (4 / (8 * $k + 1))