Ken, Your 1/2 example is hyperbole. As I said earlier, 0.5 and 1/2 are far more related (rationals being dense in the reals and all that) than are 1/2 and 0.5+0.0i. Complex numbers are inherently different from the magnitudes that we normally use, and I think you will come to agree if you think about the various coercions that would naturally follow from what you propose. A well-rounded package for complex numbers would be greatly appreciated, but I fear we would regret fully wiring it into the magnitude hierarchy.
There are times when taking the square root of a negative number means the algorithm has gone wrong and an error is appropriate; other times getting a complex answer is business as usual. Demanding that the programmer use #asComplex to enter a closed system of complex numbers and associated operators solves the problem of deciding between the two worlds. Trying to do their thining for them will backfire. Bill -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Ken.Dickey Sent: Wednesday, August 12, 2009 10:11 AM To: [email protected] Subject: Re: [Pharo-project] Complex neurotic KenD> > Currently: > > > > -1 asComplex isNumber --> true > > ?1 asComplex isNumber -> true > > -1 asComplex < 1 asComplex --> error > > > > -4 sqrt --> error Igor Stasenko <[email protected]>> > and it should. > Not many people using a complex numbers. And -4 is an integer number, > not complex number (i hope this non-objectionable?). And sqrt function > is not defined for real/integer numbers < 0 ,and should lead to error, > period. > If you change this behavior, some of code will fail to work correctly > , definitely. > But you are free to use something like: > -4 asComplex sqrt So you prefer (1 asFraction / 2) -> 1/2 , where (1/2) gives an error because 1 and 2 are not fractions? (-1 sqrt) is the definition of 1i . Other dynamic languages I use [Scheme, Lisp] which define complex numbers all give square roots of negative numbers. I am trying to approach the Principle of Least Surprise here. Computers are very bad at math, but we have learned painfully to work around this. I would like pre-computer high school math to "just work". IEEE Floats only guarantee the wrong answer fast, IMHO. I would like square roots of negative numbers to work like they did before I got a computer! 8^) 8^O 8^{ Cheers, -KenD _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
