# How can I calculate only the imaginary part of a complex number?

So I have the following function which the x will be the difference between two point:

def complexDis(x): return sqrt((x.real()^2)+((x.imag()*-i)^2))

But it seems like i can’t actually operate the .real or .imag number or at least I can’t print it out with N(conplexDis(b-a)) so im asking how can I achieve my goal?

What goes wrong if you do

`n(complexDis(b-a).imag())`

, or the same with`real()`

?@John-Palmieri same both imag and real after squaring them they both doesn’t output real number

Hi andrewwyg

maybe there is something I'm missing, but i don't see where the problem is?

I think we need more information: what are

`a`

and`b`

, and what are you expecting for your output?Note that

`x.imag()`

is a real number, so`(x.imag()*-i)`

is purely imaginary. Its square will be negative, so your function may certainly end up computing the square root of a negative number.