Formula for raising a complex number to a power

Is there an existing formula to raise a complex number to a power?

That is, I want to compute $(1 + i)^N$.
I basically want to write a function like so:

def raiseComplexNumberToPower(float real, float imag, float power):
    return // (real + imag) ^ power

If $a,b$ are real, then $a+ib = r(\cos\theta+i\sin\theta)$ where $r=\sqrt{a^2+b^2}$ and $\tan\theta = \dfrac b a$, and $$ (a+ib)^N = r^N(\cos(N\theta) + i\sin(N\theta)). $$


If $z=re^{i\theta}=e^{\ln r+i \theta}$ you can raise to the power $w$ in the usual way (multiplication of exponents), even if $w$ is a complex number.

However the expression of $z$ in this manner is far from unique because $\theta +2n\pi$ for integer $n$ will do as well as $\theta$ and raising to a constant power can give an interesting set of "equivalent powers". So for a good definition you need a way of controlling the multiplicity of possible answers, or alternatively of including them all in the definition. Mathematicians think here of principal values (including things like branch cuts) on the one hand, and Riemann Surfaces on the other. It depends a bit what you want to achieve.