Why is imaginary part of complex number negative when it is divided?
a= 6/5j
print(a)
It prints -1.2j
. Why it is a negative value in Python?
More of a math question, but the answer is
6/(5j) = 6j/(5jj) = 6j/(-5) = -1.2j
In general, 1/j = j/(jj) = -j
In python, a complex literal is (floatnumber | digitpart) ("j" | "J")
with an optional real part in front of it. Therefore in
6/5j
5j
is interpreted as a complex literal, which makes the calculation result correct (see other answers). To have a "lonely" j in your calculation, you always need to add a 1
in front of it:
6/5*1j
This does differ from how e.g. wolframalpha would handle the same input.