Why is np.exp(5*1j)**1j not equal to np.exp(1j*5*1j)?

62 Views Asked by At

I'm trying to get theta in $\exp (i \theta)$ without wrapping it back to $-\pi$. Couldn't I simply raise it to $i$? I'm thinking $-(\ln((\exp(i\theta))^i))$ should give me $\theta$? What am I doing wrong here. For example using Python's numpy library np.exp(5*1j)**1j is not equal to np.exp(1j*5*1j). 1j here is $i$.

1

There are 1 best solutions below

0
On BEST ANSWER

This is basically a complex exponentiation problem, you're asking about $\left ( e^{5i} \right )^i$ vs. $e^{5i(i)}$. The problem is that complex exponentiation is actually ambiguous: $\left ( e^{5i} \right )^i$ is by definition $e^{i \log \left ( e^{5i} \right )}$ and there are an infinite number of logarithms of $e^{5i}$, given by $5i+2\pi i k$ for any integer $k$. Presumably numpy is picking a logarithm other than $5i$ which is why you aren't getting $e^{-5}$. $e^{5i(i)}$ meanwhile is just $e^{-5}$ and that's it.

I don't have a Python install handy, but when I do this in Matlab I find log(exp(5*j)) is giving me $5i-2\pi i$ which means that exp(5*j)^(1*j) ends up giving $e^{-5+2\pi}$. (Ignoring floating point errors all around.) The explanation is that Matlab is using the principal logarithm so the imaginary parts go from $-\pi$ to $\pi$ and the principal logarithm of $e^{5i}$ is indeed $5i-2\pi i$.