Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

why no big-float?

124 views
Skip to first unread message

Dave Yost

unread,
Apr 9, 1996, 3:00:00 AM4/9/96
to
We have bignum. Why don't we have big-float?

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).

Has anyone implemented big-float?

Dave

--
Dave Yost
@ .com

Erik Naggum

unread,
Apr 9, 1996, 3:00:00 AM4/9/96
to
[Dave Yost]

| We have bignum. Why don't we have big-float?

:
| Has anyone implemented big-float?

CLISP has this.

$ clisp

> (list (lisp-implementation-type) (lisp-implementation-version))
("CLISP" "1996-03-15 (March 1996)")
> (/ 7l0)
0.14285714285714285714L0
> (float-digits *)
64
> (setf (long-float-digits) 128)
128
> (/ 7l0)
0.142857142857142857142857142857142857143L0
> (float-digits *)
128
> (quit)

it is not exactly well documented, but pretty much what you outlined.

#<Erik>
--
education is for people who can't handle reality the hard way

William D. Gooch

unread,
Apr 9, 1996, 3:00:00 AM4/9/96
to
In article <-09049605...@mac1.yost.com> Da...@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
~~~~~~~~~~~~~~~~~~~~~~

Erik Naggum

unread,
Apr 9, 1996, 3:00:00 AM4/9/96
to
[William D. Gooch]

| 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.)

Bruno Haible

unread,
Apr 12, 1996, 3:00:00 AM4/12/96
to
[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".

> > (setf (long-float-digits) 128)
> 128
> > (/ 7l0)
> 0.142857142857142857142857142857142857143L0

This is easy. The "hard" stuff are the transcendental functions:

> (setf (long-float-digits) 1024)
1024
> (- (+ (/ (sin (* 2/7 pi))) (/ (sin (* 4/7 pi)))) (/ (sin (* 6/7 pi))))
-2.225073858507201383090232717332404064219215980462331830553327416887204434
813918195854283159012511020564067339731035811005152434161553460108856012385
377718821130777993532002330479610147442583636071921565046942503734208375250
806650616658158948720491179968591639648500635908770118304874799780887753749
94945158045L-308

(Btw: Can any symbolic computer algebra system prove that the exact value
of sin(2/7*pi)^-1 + sin(4/7*pi)^-1 - sin(6/7*pi)^-1 is zero?)


Bruno Haible email: <hai...@ilog.fr>
Software Engineer phone: +33-1-49083585

Richard J. Fateman

unread,
Apr 13, 1996, 3:00:00 AM4/13/96
to
In article <4kmebv$s...@nz12.rz.uni-karlsruhe.de>,

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.

--
Richard J. Fateman
fat...@cs.berkeley.edu http://http.cs.berkeley.edu/~fateman/

Jeffrey P. Golden

unread,
Apr 13, 1996, 3:00:00 AM4/13/96
to

Reply-To: j...@macsyma.com

> Date: 12 Apr 1996 20:27:43 GMT
> From: hai...@ilog.fr (Bruno Haible)
> Newsgroups: comp.lang.lisp,comp.lang.lisp.mcl,sci.math.symbolic
> Subject: Re: why no big-float?
> Organization: University of Karlsruhe, Germany
> NNTP-Posting-Host: ma2s2.mathematik.uni-karlsruhe.de
> Summary: get CLN
> Keywords: lisp, bignum, cln, gmp, clisp, bigfloat, 7
> Originator: haible@ma2s2


>
> [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".
>

> > > (setf (long-float-digits) 128)
> > 128
> > > (/ 7l0)
> > 0.142857142857142857142857142857142857143L0
>
> This is easy. The "hard" stuff are the transcendental functions:
>
> > (setf (long-float-digits) 1024)
> 1024
> > (- (+ (/ (sin (* 2/7 pi))) (/ (sin (* 4/7 pi)))) (/ (sin (* 6/7 pi))))
> -2.225073858507201383090232717332404064219215980462331830553327416887204434
> 813918195854283159012511020564067339731035811005152434161553460108856012385
> 377718821130777993532002330479610147442583636071921565046942503734208375250
> 806650616658158948720491179968591639648500635908770118304874799780887753749
> 94945158045L-308
>
> (Btw: Can any symbolic computer algebra system prove that the exact value
> of sin(2/7*pi)^-1 + sin(4/7*pi)^-1 - sin(6/7*pi)^-1 is zero?)
>
> Bruno Haible email: <hai...@ilog.fr>
> Software Engineer phone: +33-1-49083585


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.

Moreover Macsyma gives more accurate bigfloat results than you show above:

-----------------------------------------------------------------------------
(c1) expr: sin(2/7*%pi)^-1 + sin(4/7*%pi)^-1 - sin(6/7*%pi)^-1;
1 1 1
(d1) ---------- - -------- + --------
3 %pi %pi %pi
cos(-----) sin(---) cos(---)
14 7 14

(c2) bfloat(expr);
(d2) 0.0b0

/* 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: */

(c4) trigreduce(ratsimp(expr));
(d4) 0
-----------------------------------------------------------------------------

From: Jeffrey P. Golden <j...@macsyma.com>
Organization: Macsyma Inc.
Reply-To: j...@macsyma.com
URL: http://www.macsyma.com

Will Ware

unread,
Apr 14, 1996, 3:00:00 AM4/14/96
to
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

0 new messages