... 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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.