I want to implement the complex exp, sin and cos function. The problem is the following:
For computing $\exp(z)$ I wanted to use $\exp(z) = \cos(z)+ i\cdot\sin(z)$. Then I first have to implement sin and cos.
For computing sin and cos I wanted to use the power series expansion
$\sin(z) = z - \dfrac{z^3}{3!}+\dfrac{z^5}{5!}-\dfrac{z^7}{7!}+\dots$
same for $\cos(z)$.
So I need to implement first how to compute $(x+iy)^n$. I thought I should use something like $z^n = (re^{i\varphi})^n$. The problem: I need the complex exp first.
Even if I use the power series expansion for exp I need the code for raising a complex number to a power. Where should I start?
I also thougt about $z^n = (re^{i\varphi})^n = r^n(\cos(\varphi n) +i\sin(\varphi n))$ (De Moivre's Formula) which allows me to compute the $n$-th power of $z$ without using exp. You should see the point here. I cant compute sin and cos without computing the $n$-th power of $z$.
If you have $z=a+bi$, you can find $r$ and $\theta$ for $z$ using $$r=\sqrt{a^2+b^2} \quad \text{and} \quad \theta =\arctan(a,b)$$ where $\arctan(a,b)$ gives you an angle from $0$ to $2\pi$ by incorporating the sign of the value of $a$ and $b$. Then you can use the normal exponential since $r$ and $\theta$ are real numbers to obtain $$z^n = r^n \cos(n\theta)+ir^n\sin(n\theta)$$