How to avoid getting imaginary/complex number pyth

2019-09-21 17:00发布

I am using a python code, where one of the equations got sqrt root of negative value. I use cmath.sqrt to solve it. All answers I got from that equation are shown in imaginary/complex number (e.g. x.xxxxxj). I don't want to get that imaginary/complex number as the code that I use subsequently cannot read those imaginary/ complex number. As such, how can I avoid not to get imaginary numbers? OR in other way, how can I convert those imaginary number into real ones? or how can I remove those "j". Thanks.

1条回答
【Aperson】
2楼-- · 2019-09-21 17:27

If I understand your question you either want

abs(z)

or

z.real
查看更多
登录 后发表回答