in reply to Re: Fun Question: Square Root of 5 to 10000 digits
in thread Fun Question: Square Root of 5 to 10000 digits

You can do essentially the same with Math::MPFR:
perl -MMath::MPFR=:mpfr -e "Rmpfr_set_default_prec(10000); $foo = Math +::MPFR->new(5); $bar = $foo ** 0.5; print $bar, $/, $bar ** 2, $/"

With Math::MPFR, setting a default precision of 10000, means you have 10000 bits of precision, not 10000 decimal digits of precision. To be guaranteed 10000 decimal digits of precision I think you need to ask for 33220 bits - ie ceil(10000 / log(2)). I haven't checked whether Math::PARI sets its precision in bits or decimal digits.

Cheers,
Rob

Replies are listed 'Best First'.
Re^3: Fun Question: Square Root of 5 to 10000 digits
by zentara (Cardinal) on Feb 28, 2007 at 12:41 UTC
    With Math::MPFR, setting a default precision of 10000, means you have 10000 bits of precision, not 10000 decimal digits of precision.

    Doh! You are right, I was wondering last night why I was getting a 1/3 factor of digits. 10000 gave me ~ 3000 decimal places, while 100000 precision gave me ~30000 decimal places. I thought it might be the print accuracy needed to do the inverse, but I was wrong. Thanks for clearly that up. :-)


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum