... Windows calculator does e ^ 15863.8668285308 in the blink of an eye. I wonder why it's so much faster
It's so much faster because it uses an executable that was built from optimized C (and perhaps also assembly) routines.
The pure perl Math::BigFloat can't compete with that.
<plug> In perl, use Math::MPFR in order to get the same (perhaps even better) performance compared to the Windows calculator. </plug>
# 53 bit precision, rounding to nearest
C:\>perl -MMath::MPFR -le "print exp(Math::MPFR->new('15863.8668285308
+'))"
3.8888865970333893e6889
# 64 bit precision, rounding to nearest
C:\>perl -MMath::MPFR=":mpfr" -le "Rmpfr_set_default_prec(64);print ex
+p(Math::MPFR->new('15863.8668285308'))"
3.88888659703546523928e6889
# 113 bit precision, rounding to nearest
C:\>perl -MMath::MPFR=":mpfr" -le "Rmpfr_set_default_prec(113);print e
+xp(Math::MPFR->new('15863.8668285308'))"
3.88888659703546395686515111487812115e6889
You can, of course, additionally do the inversion in one step:
C:\>perl -MMath::MPFR -le "print 1 / exp(Math::MPFR->new('15863.866828
+5308'))"
2.5714300868604479e-6890
NOTE: Math::MPFR requires both the gmp and mpfr libraries.
You could also do the same arithmetic (without the fine grained control over precision) using Math::GMPf - which requires the gmp library only.
However, the gmp project recommends mpfr over the floating point gmp routines.
Cheers, Rob |