
Issue 10562: Change 'j' for imaginary unit into an 'i' - redacted
http://bugs.python.org/issue10562
======
bobds
My favourite part:

"That could work; it's a bit late to do this in 3.2, though. How about the
following transition strategy for the complex output.

Python 3.3: Introduce PYTHONIMAGINARYSYMBOL environment variable (and possibly
also a related command-line option to the interpreter?).

Python 3.4: Show a warning on startup if this environment variable isn't used.

Python 3.5: Make the environment variable mandatory.

Python 3.6: Make the environment variable optional again, but this time with
the default output being 'i' rather than 'j'.

Python 3.7: Deprecate use of PYTHONIMAGINARYSYMBOL. (Warning on startup if
it's set.)

Python 3.8: Error on startup if PYTHONIMAGINARYSYMBOL is set.

Python 3.9: Go back to ignoring PYTHONIMAGINARYSYMBOL."

~~~
mgedmin
Mine was

"This deterministic approach has the advantage that migration of code from one
imaginary symbol to another is as easy as:

sed -e 's/k/l/' -e 's/j/k/' -e 's/i/j/' -e 's/l/i/'

provided that you restrict yourself not to use the characters i, j, k or l in
identifiers, keywords or strings in the source code."

------
podperson
It's surprising to me that a programming language would have started out
following engineering conventions rather than mathematical conventions, even
if there's a strong overlap between EE and CS. That said (and speaking as a
mathematician) I think it's foolish to use j over i, especially since in some
cases (e.g. quaternions) it will be very confusing.

~~~
hugh3
Physicists, on the other hand, have come to terms with the fact that they have
fewer letters in the English and Greek alphabets than concepts they need to
express, and so happily overload _i_ and everything else, hoping to always
figure it out from context.

~~~
treo
just add a hat ^ or squiggle ~ over it, or maybe a point, or something else. I
always wondered when the Hebrew alphabet would come up.

~~~
eru
Chinese is the future.

~~~
Natsu
Simplified or traditional?

~~~
eru
Yes. We need all the symbols we can get.

~~~
Natsu
We'll need mathematics professors with neater handwriting if you ever hope to
be able to distinguish one hanzi from another, though...

------
cap10morgan
That page could be added to the list of classic examples of bike-shedding.

~~~
gjm11
Except that the bikesheddiest bits are deliberate satire.

------
camtarn
j vs i gets really confusing when you're doing a dual electrical engineering /
computer science degree, since you have to remember which classes use which:
electrical engineering uses j (since i is already taken to mean current), CS
math uses i :)

~~~
rikthevik
I said something about j in my number theory class after 3 years of EE and my
professor looked at me like I was an idiot. He apparently had never heard of j
once in his life.

------
adambyrtek
What happened to "there should be one-- and preferably only one --obvious way
to do it"?

PS. I've also posted this as a comment to the bug report.

~~~
random42
This is python's philosophy. However the ambiguity is due to different
representation in other known fields, namely engineering and mathematics.

PS - I agree, (and upvoted) to your comment. I like this approach
<http://bugs.python.org/issue10562#msg123135>

------
jacobolus
I feel a bit bad for Retro, and half hold out the hope that he’s an invented
character just playing a role.

~~~
briancurtin
A lot of the issues he creates are very low priority or invalid , but he
aggressively, un-cooperatively, and repeatedly pushes that they be fixed.

------
jcdreads
I know that cooler heads will prevail, and that python won't get this silly
syntax change, but...

...everyone seems to be forgetting that i == -j (either squared is 1).
Physicists usually describe traveling waves (of whatever) as something
proportional to exp(kx-iwt) where that's an omega, not a w, and electrical
engineers for whatever reason prefer the notation exp(kx+jwt) (note the minus
sign difference). Except ee's sometimes write exp(kx-jwt), depending on the
convention in use at the time.

~~~
juiceandjuice
What are you talking about? i == j, and either squared are equal to negative
one. You can use them interchangeably.

~~~
YuriNiyazov
Take a look at quaternions (<http://en.wikipedia.org/wiki/Quaternion>) where
ii == jj == -1, but i != j

~~~
juiceandjuice
This discussion is talking about the notation ambiguity of i and j in denoting
a classical complex number with only one real and one imaginary part. As far
as I can tell, this python bug report has absolutely nothing to do with
quaternions, which is an extension on complex numbers.

i == j, not i == -j in most applications. If you take the number z = a + ib
and turn it into z = a - jb, and just take Im(z), you end up with two
different answers otherwise.

~~~
YuriNiyazov
What does Mark Dickinson mean in <http://bugs.python.org/issue10562#msg122672>
when he says

    
    
      'j' for *a* (not *the* </pedantry>) square root of -1 has...

~~~
juiceandjuice
j is often used instead of i in engineering and physics.

When you start talking about charge density, current, phase and frequency, you
almost always start reverting back to engineering notation (i == j). In QM we
used i. In Complex Analysis, we used i. In CM, with regards to
oscillators/harmonic motion, we used i.

The wikipedia article on imaginary units talks about interchanging i and -j
denoting the reversal of plane waves, but we never did that in advanced
electrodynamics. However, I wouldn't be surprised if some people do, but as
far as I know it's not that common. It's probably find for determining the EM
field at some point for some time, but for the problems where you have to find
the charge density on a surface of conductor induced by a EM wave, this
notation would start to get confusing.

------
wnoise
It's an imaginary number, not a jimaginary number.

------
colinprince
I love this:

 _I'm personally -0.small on it_

even though I don't understand it. Anyone?

~~~
jacobolus
In the Python community, agreement with a proposed change (“this is a good
idea”) is indicated by +1, disagreement (“this is a bad idea”) is indicated by
-1, and mostly indifference leaning slightly for or against (as in “I
(dis)approve but don’t really care”) is indicated by +0 or -0. My guess is
that -0.small is intended to mean something like “I slightly disapprove but
this is utterly insignificant”.

Edit: much more amusing is Antoine’s comment “[...] Otherwise +11j from me”

------
ez77
What module are they talking about? Could someone give an example? For
instance, the following doesn't work:

    
    
      import math
      math.sqrt(-1)

~~~
vault_
That would be the 'cmath' module.

~~~
ez77
Thank you. Clearly a python noob here...

------
joss82
Who ever use imaginary/complex numbers anyway?

~~~
CamperBob
If you rotate your phone's keypad 90 degrees, you can call Hogwarts!

To actually answer your question, complex numbers make signal processing
algorithms much more tractable, and also make it easy to visualize many
commonplace quantities and phenomena in electrical engineering. Anytime a
value has both a magnitude and a time- or phase-based aspect, chances are you
can use complex numbers to represent it.

Put another way: just as negative numbers allow you to specify movement along
an axis, complex numbers allow you to specify rotation around an axis. Both
are obviously pretty fundamental.

~~~
tomjen3
Wouldn't the same advantage be obtained by x and y coordinates?

~~~
phamilton
This something I found quite interesting:

The complex numbers form a ring that is isomorphic to the cross product of the
ring of real numbers and itself....

C≅R×R

For those who haven't done abstract algebra:

This means your can map a complex number to (x,y), that every complex number
maps to a unique (x,y), and that if you add or multiply two complex numbers
and then convert the result to (x,y), you can convert the two complex numbers
to (x,y) and then multiply getting the same answer. (it is also bijective,
meaning it works both ways).

Importance: Complex numbers can be dealt with as coordinates and coordinates
can be dealt with as complex numbers.

~~~
waqf
That's not true: the multiplication is different. (x1,y1) × (x2,y2) would have
to be (x1x2 - y1y2, x1y2 + y1x2), not (x1y1, x2y2).

The addition _does_ work as you suggest, so a more correct formal statement
would be: the complex numbers form an _additive group_ that is isomorphic to
the cartesian product of the additive group of real numbers and itself; the
complex numbers also happen to form a ring (indeed a field).

~~~
phamilton
the mapping function doesn't need to be a direct translation.

But I believe you are right.... curse you Hungerford for teaching rings and
groups simultaneously....

