[Haskell-cafe] How odd...

Albert Y. C. Lai trebla at vex.net
Sat Aug 4 14:59:39 EDT 2007

Andrew Coppin wrote:
>  > 0^2
> 0
>  > (0 :+ 0)^2
> 0 :+ 0
>  > 0**2
> 0
>  > (0 :+ 0)**2
> NaN :+ NaN

There is nothing wrong AFAIK. (How much do I know? BSc in math, went 
through classes on real analysis and complex analysis.)

There is no reason to expect complex ** to agree with real **.

Real x**y is first defined for natural y (agreeing with x^y), then 
extend to integer y (agreeing with x^^y), then extend to rational y 
(taking nth root when y = m/n), then extend to real y by continuity 
wherever possible. You can still expect real 0**2 = 0^2 = 0.

Complex x**y involves picking a phase angle of x. "Phase angle" is an 
ill notion for 0. Complex 0**y is better left undefined.

You said

> So I'm the only person who was expecting zero squared to be zero?

Are you trying to be sensational, or are you going hyperbole? If you 
want zero squared, you're welcome to use 0^2. Complex 0**2 does not have 
to be related to zero squared.

You said

> (IMHO the standard should try to implement mathematical 
 > operations in a mathematically sensible way...)

But AFAIK it is already a mathematically sensible way - it is what I 
learned from my math classes.

Perhaps you mean highschoolly sensible. I understand that highschool 
math is a bit simple-minded, e.g., you can greatly confuse someone by

1 = ((-1)**2)**0.5 = ((-1)**0.5)**2) = i**2 = -1

"So I'm the only one expecting x square-root squared to be x?"

Thank God complex ** is supposed to be different from real **.

More information about the Haskell-Cafe mailing list