Haskell 98 - Standard Prelude - Floating Class
Kent Karlsson
kentk@md.chalmers.se
Tue, 16 Oct 2001 12:03:28 +0200
----- Original Message -----
From: "Dylan Thurston" <dpt@math.harvard.edu>
...
> cos x = (exp (i*x) + exp (-i*x))/2 where i = sqrt (-1)
Disregarding that Haskell does not (yet) have Imaginary types (as distinct
from Complex): Any reasonable specification and implementation would
go the other way around: exp(i*x) (exponentiation on Imaginary t, returning
a Complex t) would be defined (exactly) in terms of the cos and sin
operations (on reals, i.e. on the type t here). If you by the above meant
giving a 'default' for cos in general, then as a special case defining
real cos (and sin) in terms of complex exp gives rather low accuracy.
Too low to be used as default definitions in my opinion.
Default definitions may be inefficient, but in my opinion, default definitions
for approximate operations should not give drastically lower accuracy, and
should certainly not violate any other reasonable expectations (like that sin x
returns x for x close to 0).
> > In general, this is why LIA-2 (Language Independent Arithmetic, part
> > 2, "Elementary numerical functions", ISO/IEC 10967-2:2001) rarely
...
> This sounds like a very interesting standard. I am constantly annoyed
> by ISO's attempts to hide their standards; one might wonder what the
Even the few ones that are publically available are hard to find. But see:
http://isotc.iso.ch/livelink/livelink/fetch/2000/2489/Ittf_Home/PubliclyAvailableStandards.htm
(log in as guest). However LIA-2 is not found there, since one has not
gone through the motions of getting it published that way.
> purpose is of having unavailable "standards". Is the content
> available somewhere?
In this particular instance I can offer, without violating ISO copyright
rules, a select few to get draft versions of LIA-2 (post-publication, it's an
editors draft for a possible future second edition; 184 pages) and LIA-3
(post registration ballot; 158 pages, changes to normative text between
published and post-publication draft of LIA-2(!) listed here). Editors drafts
are not copyrighted by ISO. Format:DVI. Those who have a special interest
in these matters, e-mail me. Comments are welcome. LIA-1 and IEC 60559
(a.k.a. IEEE floating point, IEEE 759) are frequently referenced, and
sometimes also of interest here are the Ada95 and C99 standards.
/kent k