Recently I was working a problem of probabilities and resorted to using logarithms for speed of execution. Problem was that I ended up with a logarithm that was too big to be represented in floating point. My solution was to do convert all logarithms to (large) integers, do the calculation, then convert back to log.
This suggests an implementation for big-float: use bignums with a (settable) scale factor (which corresponds to precision).
In article <-0904960524410...@mac1.yost.com> D...@Yost.com (Dave Yost) writes: >We have bignum. Why don't we have big-float? >.... >This suggests an implementation for big-float: use bignums >with a (settable) scale factor (which corresponds to precision).
That sounds like a rational, which "we do have," yes?
Floats are basicaly for speed, not high precision.
~~~~~~~~~~~~~~~~~~~~~~ William D. Gooch RothWell International goo...@rwi.com Texas liaison for the International Programmers Guild For information on IPG, see http://www.ipgnet.com/ipghome.htm ~~~~~~~~~~~~~~~~~~~~~~
| Floats are basicaly for speed, not high precision.
but transcendental functions are usually implemented with floats, even though most of them can be computed with rationals in series. this means that we lose precision in converting from rational to float, and may run into Dave's original question. on the other hand, using series to compute transcendental functions on rationals will require a "cut-off" after a given precision is reached. at this point, we might as well implement "bigflos", and Bruno Haible's CLISP already does that. unfortunately, CLISP is byte-compiled and not particularly fast. it's a tough choice.
(incidentally, several packages exist for C to achieve multiprecision arithmetic. they are not very easy to work with. I think CLISP has done the right thing when using one such package for Lisp's long float.)
#<Erik> -- education is for people who can't handle reality the hard way
Other Common Lisp implementations can get this feature as well. CLISP's bignum and bigfloat library is now available as a separate package, a library which was put together with the intent of being incorporated into Lisp implementations and math packages. ftp://ma2s2.mathematik.uni-karlsruhe.de/pub/gnu/cln.tar.z. `cln' stands for "Common Lisp Numbers".
Bruno Haible <hai...@ilog.fr> wrote: >[Dave Yost] >>| Has anyone implemented big-float?
>[Erik Naggum] >> CLISP has this.
>Other Common Lisp implementations can get this feature as well. CLISP's >bignum and bigfloat library is now available as a separate package, >a library which was put together with the intent of being incorporated >into Lisp implementations and math packages. >ftp://ma2s2.mathematik.uni-karlsruhe.de/pub/gnu/cln.tar.z. `cln' stands >for "Common Lisp Numbers".
There are big-float implementations on top of lisp in Macsyma (There is a paper on Macsyma's implementation Proc. of 1776 Symsac conf.), Reduce,MockMMA (available free from me), also. I have also implemented an interface from AllegroCL to David Bailey's state-of-the-art fpfun package, which is quite fast and includes not only the usual transcendental functions but a set of other number-theoretic bignum facilities. He has both fft-based and conventional multiplication. Instead of building on top of bignums (integers), he uses arrays of IEEE floats. Yes, the exponent space is wasted. The speed is much improved, and on many computers these days can be parallelized explicitly or even automatically the presence of multiple arithmetic units.
> [Dave Yost] > >| Has anyone implemented big-float?
> [Erik Naggum] > > CLISP has this.
> Other Common Lisp implementations can get this feature as well. CLISP's > bignum and bigfloat library is now available as a separate package, > a library which was put together with the intent of being incorporated > into Lisp implementations and math packages. > ftp://ma2s2.mathematik.uni-karlsruhe.de/pub/gnu/cln.tar.z. `cln' stands > for "Common Lisp Numbers".
/* The following is not a proof since it is based on a heuristic procedure which analyzes the constituent parts of expressions and determines the number of digits necessary to compute an expression to such that if the expression is not equivalent to zero you'll get a non-zero result. Obviously this doesn't work for all expressions in which case the procedure punts. */
(c3) sign(expr); (d3) zero
/* But a proof is easy to come by by just simplifying: */
Jeffrey P. Golden (j...@math.math.unm.edu) wrote: : Macsyma has had bigfloats in Lisp for about 21 years, and in Common Lisp : ever since Macsyma was ported to Common Lisp about 11 years ago.
Is there a freeware version of Macsyma (or anything roughly equivalent) around? Something in Common Lisp would be lovely, but I'd be interested in anything that would run on my Linux box. Thanks. -- ------------------------------------------------------------- Will Ware <ww...@world.std.com> web <http://world.std.com/~wware/> PGP fingerprint 45A8 722C D149 10CC F0CF 48FB 93BF 7289