At some point in my python script, I require to make the calculation: 1*(-inf + 6.28318530718j). I understand why this will return -inf + nan*j since the imaginary component of 1 is obviously 0, but I would like the multiplication to have the return value of -inf + 6.28318530718j as would be expected. I also want whatever solution to be robust to any of these kinds of multiplications. Any ideas?
Edit:
A Complex multiplication like x*y where x = (a+ib) and y = (c+id) I assume is handled like (x.real*y.real-x.imag*y.imag)+1j*(x.real*y.imag+x.imag*y.real) in python as this is what the multiplication comes down to mathematically. Now if say x=1.0 and y=-inf+1.0j then the result will contain nan's as inf*0 will be undefined. I want a way for python to interpret * so that the return value to this example will be -inf+1.0j. It seems unnecessary to have to define my own multiplication operator (via say a function cmultiply(x,y)) such that I get the desired result.
The short answer is that the C99 standard (Annex G) on complex number arithmetic recognizes only a single complex infinity (think: Riemann sphere). (inf, nan) is one representation for it, and (-inf, 6j) is another, equivalent representation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With