Hi Ken, I would expect that any total ordering on a field, in order to be considered useful, would be consistent with the field's arithmetic. More specifically, I would expect the following to hold. Let A < B Let 0 < C (n.b. 0 + x = x) Thus A < B + 0 Thus A < B + C Agreed?
Now, if we take the ordering given below, with the numbers A = 1 B = 0.25 + 10i C = 0.25 - 10i we get A < B and 0 < C But, B + C = 0.5 which contradicts A < B + C (1 < 0.5) I really hate to burst your bubble, and perhaps this ordering is useful to you in some manner or other, but the fact of the matter is, you simply cannot define a total ordering of the complex numbers which is consistent with arithmetic on complex numbers. This is a mathematical certainty, not just a matter of "nobody's ever figured out how to do it". Regards, Jon Ken Dickey wrote: > ;;============================ > The following <? predicate orders all Scheme numbers including complex > numbers > based on polar coordinates. > ;;============================ > (library (mumble less) > (export <?) > (import (rnrs)) > > (define (<? a b) > (assert (number? a)) > (assert (number? b)) > > (let ( [a^ ((sign a) (magnitude a))] > [b^ ((sign b) (magnitude b))] > ) > (or (< a^ b^) > (and (= a^ b^) > (< (angle a) (angle b)))) > ) ) > > (define (sign num) (if (< (real-part num) 0) - +)) > ) > > (import (rnrs) > (xitomatl srfi lightweight-testing) > (mumble less) > ) > > (check (<? -2 -1) => #t) > (check (<? 1/3 3+2i) => #t) > (check (<? 1/3 3-2i) => #t) > (check (<? 1/3 -3-2i) => #f) > (check (<? 1/3 -3+2i) => #f) > (check (<? 32 +14i) => #f) > (check (<? +14i 32) => #t) > (check (<? -3 +2.5i) => #t) > (check (<? -4 -3-2i) => #t) > (check (<? -4 3-2i) => #t) > (check (<? -4 3+2i) => #t) > (check (<? -4 -3+2i) => #t) > (check (<? -3-2i 4) => #t) > (check (<? 3-2i 4) => #t) > (check (<? 3+2i 4) => #t) > (check (<? -3+2i 4) => #t) > (check (<? 3+4i 5) => #f) > (check (<? 4+3i 5) => #f) > (check (<? 3+4i 5.1) => #t) > (check (<? 4+3i 5.1) => #t) > (check (<? -5 -3+4i) => #f) > (check (<? -5 -4+3i) => #f) > (check (<? -5.1 -3+4i) => #t) > (check (<? -5.1 -4+3i) => #t) > (check (<? -5 -3-4i) => #f) > (check (<? -5 -4-3i) => #f) > (check (<? -5.1 -3-4i) => #t) > (check (<? -5.1 -4-3i) => #t) > > > (check (<? 3 5)=> #t) > (check (<? 3 -5)=> #f) > (check (<? 3 3)=> #f) > (check (<? 1/6 1/3) => #t) > > (check-report) > > ;;; --- E O F --- ;;; > > > _______________________________________________ > r6rs-discuss mailing list > [email protected] > http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
