0

I'm using Python 3.9.15 and trying to get the number (0 + infj), i.e. the imaginary part is infinite and the real part is zero. However, I tried several alternatives but all of them gave (nan + infj) instead of (0 + infj).

>>> float('inf') * 1j
(nan+infj)
>>> float('inf') * 1j + 0
(nan+infj)
>>> import numpy as np
>>> np.inf * 1j
(nan+infj)
>>> np.inf * 1j + 0
(nan+infj)

How do I get the number (0 + infj)?

Firman
  • 928
  • 7
  • 15
  • Does this answer your question? [Complex number in python](https://stackoverflow.com/questions/21572909/complex-number-in-python) – ILS Nov 18 '22 at 11:08

1 Answers1

2

You can use built-in complex function:

complex(0,float('inf'))
Nuri Taş
  • 3,828
  • 2
  • 4
  • 22