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] http://www.math.berkeley.edu/~roconnor/ ``This is not a

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 (**) when x

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

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 to be

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 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 x and y

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 warnings

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

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

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 have

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) * sqrt

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 suggest removing sinh

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 near

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

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]

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

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 exp

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 though

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 can

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Dylan Thurston
On Mon, Oct 15, 2001 at 03:52:06PM +0200, Kent Karlsson wrote: 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 ... This looks pretty reasonable to me. We

Re: Haskell 98 - Standard Prelude - Floating Class

2001-10-15 Thread Jon Fairbairn
In general, this is why LIA-2 (Language Independent Arithmetic, part 2, Elementary numerical functions, ISO/IEC 10967-2:2001) [. . .] This sounds like a very interesting standard. I am constantly annoyed by ISO's attempts to hide their standards; one might wonder what the purpose is of