calculating exp[-300]
dtashley at aol.com
dtashley at aol.com
Tue Apr 26 18:33:31 CEST 2005
> I'm working on a monte-carlo simulation which requires the
> calculation of probability for rather high energy levels, Boltzmann
> probability defined, exp(-u/T). The quantity u/T is occasionally
> very large, and in some cases always large. I'd like to use GMP
> rational numbers (mpq_t) to represent the probability and partition
> function of the system.
> I think this is a wrong turn. mpq numbers are fractions, and
> operations on them always give exact results (expending whatever
> effort is necessary to do so). Your numbers aren't representable as
> fractions anyway, so you don't get exact answers no matter what you
> do, so you might as well use mpf (floating-point) numbers instead.
> That'll reduce your execution time quite a lot, I think.
In good humor, everyone will agree that exp(-300) is not rational. Since "e" is a transcendental constant (i.e. not an algebraic number), it is not a solution to K_1 x^300 = K2. And since e^300 is not rational, neither is e^(-300).
Humor aside ...
One could obtain quite good aribtrary-precision approximations if one would use rational math but limit the maximum size of the numerator and denominator. Then one gets into Farey series, rectangular regions of the integer lattice, and continued fraction algorithms. This can definitely be done. But the question is why anyone would want to do it when arbitrary-precision floating-point math may provide a better abstraction of the numbers one wants to represent.
I agree with Karl. The direction of using rational numbers to represent these quantities doesn't seem very helpful.
BTW, if anyone wants information about Farey series, continued fraction algorithms, and rectangular portions of the integer lattice, just e-mail me at dashley at e-collab.com.
Dave.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gmplib.org/list-archives/gmp-discuss/attachments/20050426/c6302fdb/attachment.html
More information about the gmp-discuss
mailing list