go ahead... be a heretic PerlMonks

Re^7: Help me make a test case for Math::BigFloat

by fizbin (Chaplain)
 on Mar 07, 2006 at 13:31 UTC ( #534914=note: print w/replies, xml ) Need Help??

I've never been able to work out an algorithm for calculating exp for rationals.
That's probably because exp(r) is irrational for every rational r except for 0. However, saying use bigrat sprinkles some magic crazy dust over the whole program in a way similar to use bignum; witness:
```use bigrat;
use strict;
my \$lnev = - 7 / (10 ** 17);
print "lnev is \$lnev\n";
my \$ev = exp(\$lnev);
print "ev is \$ev\n";
print "1-ev is ", 1-\$ev, "\n";
Again, both values are 1.
--
```@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/;
map{y/X_/\n /;print}map{pop@\$_}@/for@/

Replies are listed 'Best First'.
Re^8: Help me make a test case for Math::BigFloat
by spiritway (Vicar) on Mar 07, 2006 at 23:20 UTC
That's probably because exp(r) is irrational for every rational r except for 0.

Not quite; what I'd be looking for, of course, would be an algorithm that would *approximate* exp. Basically, any numeric representation in a computer is going to be a sort of "rational", in that it uses a finite number of bytes, bits, digits, or whatever to represent any number.

The problem isn't that approximation algorithms don't exist; it's that I haven't been able to find one that converges rapidly. I know they're out there - I just haven't had the time to dig around and find them.

There is certainly something wrong with bigrat or its friends. I'm not sure who's maintaining the modules any more - it used to be Tels.

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://534914]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2022-08-17 15:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?

No recent polls found

Notices?