Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use this complex number in numpy matrix?

Here's the Python code I'm working on:

def inver_hopf(x,y,z):
    return (1/np.sqrt(x**2+y**2+(1+z)**2))*np.matrix([[1+z],[x+y.j]],dtype=complex)

The problem happens at [x+y.j], where j means complex unit. It returns me the error message AttributeError: 'int' object has no attribute 'j'. If I remove the dot, then it returns NameError: name 'yj' is not defined. How can I correct that? Thanks!

like image 464
ZR- Avatar asked Dec 31 '22 13:12

ZR-


1 Answers

j alone is a variable, you can have the complex number by typing 1j

like image 199
BlackMath Avatar answered Jan 02 '23 03:01

BlackMath