caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] float type with better precision than the default
@ 2003-12-06  0:44 romildo
  2003-12-06  3:18 ` Brian Hurt
  2003-12-08 10:11 ` Jean-Christophe Filliatre
  0 siblings, 2 replies; 7+ messages in thread
From: romildo @ 2003-12-06  0:44 UTC (permalink / raw)
  To: caml-list; +Cc: mgiv2595

Hello.

A friend of mine needs a type for float numbers
with better precision than the precision offered
in the default float type. He also needs efficiency
in his application.

He is currently looking at the CReal library
that comes with mlgmp. Unfortunatly he is
finding that it is ineficient for his
application.

What he needs is something like a float type with
twice the precision as of the default float type
from OCaml.

Can anyone help with this and indicate a
possible solution?

Regards,

Romildo
-- 
Prof. José Romildo Malaquias        romildo@uber.com.br
Departamento de Computação       malaquias@iceb.ufop.br
Univ. Federal de Ouro Preto  http://uber.com.br/romildo

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] float type with better precision than the default
  2003-12-06  0:44 [Caml-list] float type with better precision than the default romildo
@ 2003-12-06  3:18 ` Brian Hurt
  2003-12-06  3:42   ` skaller
  2003-12-08 10:11 ` Jean-Christophe Filliatre
  1 sibling, 1 reply; 7+ messages in thread
From: Brian Hurt @ 2003-12-06  3:18 UTC (permalink / raw)
  To: romildo; +Cc: Ocaml Mailing List, mgiv2595

On Fri, 5 Dec 2003 romildo@uber.com.br wrote:

> Hello.
> 
> A friend of mine needs a type for float numbers
> with better precision than the precision offered
> in the default float type. He also needs efficiency
> in his application.

Ocaml floats are spec'd to be IEEE 754 double precision.  This gives you 
enough accuracy to measure the distance from here to the moon in microns-
15 decimal digits.  30 decimal digits is enough accuracy to measure the 
distance between here and the Andromeda Galaxy in microns.  Why does he 
need such a ridiculous amount of precision?

But the short answer is he is basically SOL.  The x86 has an 80-bit FP
format (~18 digits of accuracy), and the PA-RISC can do 128-bit FP at a
signifigant performance hit (1/2 the speed of double precision, IIRC).  
But no one else I know of does more than double precision in hardware.  
Which means software emulation, and really slow performance.  You might 
gain a little by hardcoding the precision (GMP implements arbitrary 
precision floats), but not enough to make up the difference.

Especially after, as I predict, you discover that 30 bits of precision 
isn't enough either.

Instead, I'd recommend your friend take his algorithm over some day to 
whatever nearby college you have and find whomever teaches the Numerical 
Analysis class, and talk the algorithm over with that professor.  I'd bet 
dollars to donuts that his algorithm is numerically unstable, and once 
he's done taking that professor's advice, double precision will be more 
than enough precision.

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] float type with better precision than the default
  2003-12-06  3:18 ` Brian Hurt
@ 2003-12-06  3:42   ` skaller
  2003-12-06 11:54     ` Remi Vanicat
  0 siblings, 1 reply; 7+ messages in thread
From: skaller @ 2003-12-06  3:42 UTC (permalink / raw)
  To: Ocaml Mailing List

On Sat, 2003-12-06 at 14:18, Brian Hurt wrote:
> 30 decimal digits is enough accuracy to measure the 
> distance between here and the Andromeda Galaxy in microns.  Why does he 
> need such a ridiculous amount of precision?

Standard eigen problem sometimes needs ridiculous precision:
the scalar product of two vectors:

	sigma (i=1,n) (v1_i * v2_i)

sometimes involves cancellation of large values.
To see why there is a problem here, consider:

	1.000001e20 - 1e20 -
	(1.000001e-20 - 1e-20) 

and you can see you need around 50 digits precision, just to get
an answer with 1 digit of precision.

The eigen problem with large numbers of dimensions
arises in, for example, quantum chemistry. 

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] float type with better precision than the default
  2003-12-06  3:42   ` skaller
@ 2003-12-06 11:54     ` Remi Vanicat
  0 siblings, 0 replies; 7+ messages in thread
From: Remi Vanicat @ 2003-12-06 11:54 UTC (permalink / raw)
  To: caml-list

skaller <skaller@ozemail.com.au> writes:

> On Sat, 2003-12-06 at 14:18, Brian Hurt wrote:
>> 30 decimal digits is enough accuracy to measure the 
>> distance between here and the Andromeda Galaxy in microns.  Why does he 
>> need such a ridiculous amount of precision?
>
> Standard eigen problem sometimes needs ridiculous precision:
> the scalar product of two vectors:
>
> 	sigma (i=1,n) (v1_i * v2_i)
>
> sometimes involves cancellation of large values.
> To see why there is a problem here, consider:
>
> 	1.000001e20 - 1e20 -
> 	(1.000001e-20 - 1e-20) 
>

[...]


This is what is called a numerical unstable algorithm...
-- 
Rémi Vanicat

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] float type with better precision than the default
  2003-12-06  0:44 [Caml-list] float type with better precision than the default romildo
  2003-12-06  3:18 ` Brian Hurt
@ 2003-12-08 10:11 ` Jean-Christophe Filliatre
  2003-12-08 11:29   ` Jean-Christophe Filliatre
  2003-12-08 11:57   ` romildo
  1 sibling, 2 replies; 7+ messages in thread
From: Jean-Christophe Filliatre @ 2003-12-08 10:11 UTC (permalink / raw)
  To: romildo; +Cc: caml-list, mgiv2595


romildo@uber.com.br writes:
 > 
 > He is currently looking at the CReal library
 > that comes with mlgmp. Unfortunatly he is
 > finding that it is ineficient for his
 > application.

Creal implements  *exact* real  arithmetic (i.e. all  computations are
exact and digits are computed later on demand). This is not to be used
when efficiency is really needed, but only when exactness is.

As Brian  already suggested, arbitrary  precision floats from  the GMP
library may  be useful in  your situation (but  as far as  I remember,
this part of GMP is not (yet) interfaced in mlgmp.)

Best regards,
-- 
Jean-Christophe

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] float type with better precision than the default
  2003-12-08 10:11 ` Jean-Christophe Filliatre
@ 2003-12-08 11:29   ` Jean-Christophe Filliatre
  2003-12-08 11:57   ` romildo
  1 sibling, 0 replies; 7+ messages in thread
From: Jean-Christophe Filliatre @ 2003-12-08 11:29 UTC (permalink / raw)
  To: caml-list


 > arbitrary precision floats from the GMP library may be useful in
 > your situation (but as far as I remember, this part of GMP is not
 > (yet) interfaced in mlgmp.)

My mistake: they are implemented in mlgmp latest release
(http://www.di.ens.fr/~monniaux/download/mlgmp.tar.gz)

-- 
Jean-Christophe

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] float type with better precision than the default
  2003-12-08 10:11 ` Jean-Christophe Filliatre
  2003-12-08 11:29   ` Jean-Christophe Filliatre
@ 2003-12-08 11:57   ` romildo
  1 sibling, 0 replies; 7+ messages in thread
From: romildo @ 2003-12-08 11:57 UTC (permalink / raw)
  To: Jean-Christophe Filliatre; +Cc: romildo, caml-list, mgiv2595

On Mon, Dec 08, 2003 at 11:11:57AM +0100, Jean-Christophe Filliatre wrote:
> 
> romildo@uber.com.br writes:
>  > 
>  > He is currently looking at the CReal library
>  > that comes with mlgmp. Unfortunatly he is
>  > finding that it is ineficient for his
>  > application.
> 
> Creal implements  *exact* real  arithmetic (i.e. all  computations are
> exact and digits are computed later on demand). This is not to be used
> when efficiency is really needed, but only when exactness is.

Right. So Creal is not for him.

> As Brian  already suggested, arbitrary  precision floats from  the GMP
> library may  be useful in  your situation (but  as far as  I remember,
> this part of GMP is not (yet) interfaced in mlgmp.)

The latest mlgmp implements arbitrary precision floats. But some important
functions he needs (transcendental functions like sin and cossin) are not
available in mlgmp. Will he be able to find such functions implemented
elsewhere for arbitrary precision floats from gmp?

Regards.

Romildo

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-12-08 11:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-06  0:44 [Caml-list] float type with better precision than the default romildo
2003-12-06  3:18 ` Brian Hurt
2003-12-06  3:42   ` skaller
2003-12-06 11:54     ` Remi Vanicat
2003-12-08 10:11 ` Jean-Christophe Filliatre
2003-12-08 11:29   ` Jean-Christophe Filliatre
2003-12-08 11:57   ` romildo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).