Greetings,

Since there is some discussion around comparing using#< let me try to explain 
the context of my thinking.


I am approaching this as a programmer and a user of mathematics, not as a 
mathematician.

I prefer the Principle of Least Surprise.

I prefer simple, easy to explain rules and simple implementations.


I expect the following expressions all to answer true.

  1/2 = 0.5.
  1 = 1 asComplex.
  1 = (1 + 0i).  "same as the previous line"
  0 < 1.
  0 < 1 asComplex. 

Every number is-equivalent-to a complex number because 1 = (1 + 0i). 

[In the Scheme language every number _is_ a complex number, BTW].

So to me, saying that 0 and (1 asComplex) are not comparable is saying that 0 
and 1 are also not comparable, because I consider them numerically the same 
as (0+0i) and (1+0i).


My observation is that I don't want to lose properties.  If A and B are 
numbers, I want them to be comparable on the real number line -- no matter 
how many other dimensions I add.

If B is to the right on the real number line from A, then I expect (A < B) to 
answer true.   I expect this to be true NO MATTER HOW MANY DIMENSIONS I ADD.

To put this in context, say that I have an object which is a "basket of 
measurements" at a place and time (say position, density, temperature, 
pressure).  Now if I add a new dimension, say electrical conductivity, I do 
not expect temperature comparisons to stop working.  I can still compare 
temperatures between objects which lack the conductivity slot/measurement and 
those which have them.

OK.  Now to the extension.  I suspect this is the root of the (potential) 
controversy. 

I chose to say that if the real/x component of a 2d number is equal, then one  
number may be considered less than another if the imaginary/y value is less.

This means that (0+0i) < (0+1i) holds.

These are the properties (and test cases) I care about.

Currently, the definition for Complex>>< is just this (see below).  This 
implies that (3+0i) < (3+1i) holds, even though the x/real components are 
equal.

I think that this is OK.  What do you think?  


Are there simpler, least surprising definitions for Complex>>< ?  

What useful properties/invariants/tests would you add?  [As unit tests]


Thanks for your thoughtful input.

-KenD
--------------------------------Complex
< other
        "self < other if other's real-part is to the right or the real-parts 
are 
equal and the oher's imaginary part is larger"
        | otherCpx |
        otherCpx := other asComplex.
        ^self real < otherCpx real
                        or: [self real = otherCpx real  and: [self imag < 
otherCpx imag]]
---------------------------------

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to