[Tutor] Floor and modulus for complex arguments
angusr at bigfoot.com
Fri Jul 3 15:23:12 CEST 2009
I'm a little confused by: (i) the definition of the modulus and
floor division functions for complex arguments; (ii) the fact
that these functions for complex arguments are now "deprecated";
and (iii) the fact that the math.floor() function is not defined
at all for a complex argument.
If I were thinking about this from scratch (in the context of
mathematics, rather than any particular programming language),
I /think/ I would be naturally inclined to define:
floor(x + yj) = floor(x) + floor(y)j for all real x, y
z % w = z - floor(z / w) * w for all complex z, w (!= 0)
These seem like they would be mathematically useful definitions
(e.g. in algebraic number theory, where one has to find the
"nearest" Gaussian integer multiple of one Gaussian integer to
another - I forget the details, but it has something to do with
norms and Euclidean domains), and I don't understand why Python
doesn't do it this way, rather than first defining it a different
way (whose mathematical usefulness is not immediately apparent
to me) and then "deprecating" the whole thing! It seems like
a wasted opportunity - but am I missing something?
Has there been heated debate about this (e.g. in the context
of Python 3, where the change to the division operator has
apparently already provoked heated debate)?
Also, by the way, is there some obvious reason for Python's use
of the notation x + yj, rather than the more standard (except
perhaps among electrical engineers) x + yi?
More information about the Tutor