Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are complex numbers in Python denoted with 'j' instead of 'i'?

Tags:

python

I know this is an electrical engineering convention, but I'm still wondering why it was chosen for Python. I don't know other programming languages with complex-number literals, so I don't have anything to compare against, but does anyone know any that do use i?

like image 683
Eli Rose Avatar asked Jul 17 '14 19:07

Eli Rose


People also ask

Why does Python use j instead of i for complex numbers?

I is the variable, and A is the unit. i is only ever used for imaginary numbers. j as a suffix is actually more confusing, because J as a suffix is actually used in physics and engineering (Joules). i is sometimes used to represent AC current in order to distinguish from DC values (for example).

Why is j used for complex numbers?

A number with the letter ” j ” in front of it identifies it as an imaginary number in the complex plane. Imaginary numbers can be added, subtracted, multiplied and divided the same as real numbers. In Rectangular Form a complex number is represented by a point in space on the complex plane.

What does i and j stand for in complex numbers?

Its the magnitude or "length" of the complex number, (3+4j) where j is the imaginary unit. j, the imaginary unit is the square root of -1. The solution of the equation x^2 + 1 = 0. An Imaginary number is a real number times the imaginary unit. Complex numbers have both a real part and an imaginary part.

Is j the same as i in complex numbers?

For example, in electrical engineering and control systems engineering, the imaginary unit is normally denoted by j instead of i, because i is commonly used to denote electric current.


2 Answers

It appears to be, as you guessed, because Python follows the electrical engineering convention. Here's an exchange from the Python bug tracker Issue10562:

Boštjan Mejak: In Python, the letter 'j' denotes the imaginary unit. It would be great if we would follow mathematics in this regard and let the imaginary unit be denoted with an 'i'.

Michael Foord: We follow engineering which uses j.

(I was about to close this as wontfix but Antoine is particularly keen that Mark deals with this issue...)

Mark Dickinson: Just to add my own thoughts: 'j' for a (not the ) square root of -1 has, as Michael points out, a history of use in engineering (particularly electrical engineering) and physics. Personally, I would have preferred 'i' to 'j' here, but changing it now would cause (IMO) gratuitous breakage. It really doesn't seem a big enough issue to be worth making a fuss about.

...

Much later:

Guido van Rossum: This will not be fixed. For one thing, the letter 'i' or upper case 'I' look too much like digits. The way numbers are parsed either by the language parser (in source code) or by the built-in functions (int, float, complex) should not be localizable or configurable in any way; that's asking for huge disappointments down the road. If you want to parse complex numbers using 'i' instead of 'j', you have plenty of solutions available already.

like image 142
Bill the Lizard Avatar answered Sep 27 '22 21:09

Bill the Lizard


Python adopted the convention used by electrical engineers. In that field, i is used to represent current and use j as the square root of -1.

There was a bug logged to change it to i in Python 3.3. It was resolves as a "WONTFIX" with this reasoning by Guido van Rossum:

This will not be fixed. For one thing, the letter 'i' or upper case 'I' look too much like digits. The way numbers are parsed either by the language parser (in source code) or by the built-in functions (int, float, complex) should not be localizable or configurable in any way; that's asking for huge disappointments down the road. If you want to parse complex numbers using 'i' instead of 'j', you have plenty of solutions available already.

like image 41
Andy Avatar answered Sep 27 '22 20:09

Andy