Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-23 Thread Brian Boutel
[EMAIL PROTECTED] wrote: > > > How about making default method for asin > > asin x = atan(x/sqrt(1-x^2)) > > Can't be worse than the default for (**) ;-) > Oh, it can. As well as its own problems when x is close to 1, it inherits, through the default definition of sqrt, the problems of (**)

RE: Haskell 98 - Standard Prelude - Floating Class

2001-10-23 Thread roconnor
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 How about making default method for asin asin x = atan(x/sqrt(1-x^2)) Can't be worse than the default for (**) ;-) - -- Russell O'Connor[EMAIL PROTECTED] ``This is not a

RE: Haskell 98 - Standard Prelude - Floating Class

2001-10-19 Thread Simon Peyton-Jones
An apparently-innocuous suggestion about adding default methods for sinh and cosh led to a flood of mail. Since no consensus emerged, I plan to leave things as they are in the Haskell 98 Report. Namely, the following default methods for the Floating class are there: x**y = exp (log x *

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-18 Thread Marcin 'Qrczak' Kowalczyk
Thu, 18 Oct 2001 13:49:11 +0200, Karl-Filip Faxen <[EMAIL PROTECTED]> pisze: > There are two solutions that I can see: Annotate classes in class > constraints with exactly which methods were used. Thus for the > expression "x+y" the inference algorithm would record the constraint > "Num{+} a" if

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-18 Thread Karl-Filip Faxen
Hi! Jon Fairbairn wrote: > I agree too, but being able to omit method definitions is > sometimes useful -- would it be possible to make calls to > those methods a /static/ error? I suspect this would be hard > to do. Yes, quite tricky. The problem is that the class constraints (in an inference

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-18 Thread Jon Fairbairn
> On Tuesday 16 October 2001 07:29, Fergus Henderson wrote: > > [...] > > The whole idea of letting you omit method definitions for methods with > > no default and having calls to such methods be run-time errors is IMHO > > exceedingly odd in a supposedly strongly typed language, and IMHO ought >

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-18 Thread Wolfgang Jeltsch
On Tuesday 16 October 2001 07:29, Fergus Henderson wrote: > [...] > The whole idea of letting you omit method definitions for methods with > no default and having calls to such methods be run-time errors is IMHO > exceedingly odd in a supposedly strongly typed language, and IMHO ought > to be reco

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-16 Thread Marcin 'Qrczak' Kowalczyk
Tue, 16 Oct 2001 15:29:36 +1000, Fergus Henderson <[EMAIL PROTECTED]> pisze: > Not giving a default definition is *not* the same as giving a default > definition that calls "error". It's significantly safer. The difference > is that the former makes it much easier for compilers to issue warning

Re: Standard Prelude - Floating Class

2001-10-16 Thread George Russell
I wrote > I'm afraid that I have very little faith in the numerical analysis > expertise of the typical Haskell implementor, so I think it is dangerous > to give them an incorrect "default" implementation. I am reminded of > the notorious ASCII C (very)-pseudo-random number generator . . . Dylan

Re: Standard Prelude - Floating Class

2001-10-16 Thread Lennart Augustsson
Jerzy Karczmarczuk wrote: > Did Joe Fasel include this consciously? If yes, > my respect - already almost infinite, is even bigger now). I'm pretty sure he did, but he can speak for himself. I know he discussed these things with his numerical collegues when designing the prelude. Look at this d

Re: Standard Prelude - Floating Class

2001-10-16 Thread Jerzy Karczmarczuk
George Russell wants to terminate the discussion with Dylan Thurston who corrects some inadequacies of his previous posting : > > ... Surely sinh x is at least 1/2 of exp x, leaving only a > > very narrow range for this to happen. Behaviour of sinh x near 0 is > > more important, unless I'm miss

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Fergus Henderson
On 15-Oct-2001, Simon Peyton-Jones <[EMAIL PROTECTED]> wrote: > > The proposal is only to give "default declarations" > in the class defn for sinh, cosh, and perhaps as Lennart suggests > asinh, acosh, atanh. They give a reasonable first cut if you > don't write definitions yourself. But you

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread George Russell
Dylan Thurston wrote: [snip] > > No. As has been pointed out, this is a bad idea numerically because > > it will give the wrong answer for sinh x for very small values of > > x. As a matter of fact, you will also get the wrong answer for very large > > values of x, where exp(x) can overflow even

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Dylan Thurston
On Mon, Oct 15, 2001 at 06:27:52PM +0200, George Russell wrote: > Simon PJ wrote: > > Fpr the Revised Haskell 98 report, Russell O'Connor suggests: > > =20 > > | Also, I understand you are reluctant to make library changes,=20 > > | but sinh and cosh can easily be defined in terms of

RE: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread George Russell
Simon PJ wrote: > Fpr the Revised Haskell 98 report, Russell O'Connor suggests: > =20 > | Also, I understand you are reluctant to make library changes,=20 > | but sinh and cosh can easily be defined in terms of exp > |=20 > | sinh x =3D (exp(x) - exp(-x))/2 > | cosh x =3D (exp(x) + e

RE: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Lennart Augustsson
> That's a good idea too. > Is there a reason for defining acosh as above instead of > acosh x = log(x + sqrt(x*x-1)) If there is one I can't remember it. :-) -- Lennart ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/

RE: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread roconnor
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mon, 15 Oct 2001, Lennart Augustsson wrote: > Why not provide defaults for the inverse functions as well? > > asinh x = log (x + sqrt (1+x*x)) > acosh x = log (x + (x+1) * sqrt ((x-1)/(x+1))) > atanh x = log ((x+1) / sqrt (1 - x*x)) T

RE: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Simon Peyton-Jones
| > 1. Actually, I wouldn't even call that "default | definitions". These ARE | >definitions of sinh and cosh. | | Mathematically, yes. Numerically, no. Even if 'exp' is | implemented with high accuracy, the suggested defaults may | return a very inaccurate (in ulps) result. Take sinh n

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Kent Karlsson
- Original Message - From: "Jerzy Karczmarczuk" <[EMAIL PROTECTED]> ... > Simon Peyton-Jones: > > > > Russell O'Connor suggests: > > > | but sinh and cosh can easily be defined in terms of exp > > | > > | sinh x = (exp(x) - exp(-x))/2 > > | cosh x = (exp(x) + exp(-x))/2 > > > | I sugg

RE: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Lennart Augustsson
> | sinh x = (exp(x) - exp(-x))/2 > | cosh x = (exp(x) + exp(-x))/2 ... > This looks pretty reasonable to me. We should have default methods > for anything we can. Why not provide defaults for the inverse functions as well? asinh x = log (x + sqrt (1+x*x)) acosh x = log (x + (x+1) * sqr

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Lennart Augustsson
> 2. So, they hold for the Complex numbers as well. The gymnastics with >complex sinh and cosh seems to be redundant. Well, I would be a little careful changing these. Some of the definitions in numerical part of the Prelude look more convoluted than they need to be, but it's because they hav

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Jerzy Karczmarczuk
Simon Peyton-Jones: > > Russell O'Connor suggests: > | but sinh and cosh can easily be defined in terms of exp > | > | sinh x = (exp(x) - exp(-x))/2 > | cosh x = (exp(x) + exp(-x))/2 > | I suggest removing sinh and cosh from the minimal complete > | definition, and add the above defaults. > >

RE: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Simon Peyton-Jones
Fpr the Revised Haskell 98 report, Russell O'Connor suggests: | Also, I understand you are reluctant to make library changes, | but sinh and cosh can easily be defined in terms of exp | | sinh x = (exp(x) - exp(-x))/2 | cosh x = (exp(x) + exp(-x))/2 | | (source: Calculus Third E