[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Default magnitude for <complex> should be 1

Dear info-dylan,

I'm a newcomer to the discussion, so please forgive me if this has 
already been discussed.

On page 148 of the Dylan book, it is specified that:

     (make <complex> :angle a)

is interpreted as:

     (make-polar 0 a)
The choice of 0 as the default magnitude seems to me not to be the best 
one.  I think the default magnitude should be 1.


[1] As currently specified, (make <complex> :angle a) is equal to 0
regardless of a.  We don't need another fancy and confusing way to type 0.

[2] It is fairly common when using complex numbers to use a "pure angle"
in the sense of exp(sqrt(-1) * theta).  Defaulting the magnitude to 1
makes (make <complex> :angle theta) accomplish that.

[3] When humans work with complex numbers, rectangular coordinates are easy
to use in additive operations, and polar coordinates are easy to use in
multiplicative operations.  With the mangitude defaulted to 1, the 
following two identities apply and there is a nice symmetry to them:

     (make <complex> magnitude: a angle: b) =
          (* (make <complex> magnitude: a) (make <complex> angle: b))

     (make <complex> x: a y: b) =
          (+ (make <complex> x: a) (make <complex> y: b))


Change the Dylan spec such that

    (make <complex> :angle a)
is interpreted as

    (make-polar 1 a)

Stephen C. Gilardi
SQ Software