HaloO,

Moritz Lenz via RT wrote:
On Wed Nov 19 07:35:48 2008, masak wrote:
<masak> what should the behaviour of sign($x) be when $x is complex?

I'd argue that it's a Failure.

This is a bit drastic. If one computes in the complex domain
a complex valued sign function is appropriate.

   multi sub sign(Complex $z --> Complex)
   {
       return $z.abs ?? $z / $z.abs !! 0;
   }

That is, it returns a unit complex number or zero. This nicely
fits the notion that the set {-1,1} is the zero dimensional unit
sphere with 0 as center just like the unit circle is the one
dimensional unit sphere.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Reply via email to