I'm trying to implement the exponentiation of numbers in my Scheme interpreter. I'm wondering how one Scheme implementation (Kawa) implemented this equation:
$(10+10i)^{10}$
Kawa give this output:
$+320000000000i$
My implementation (same as few others) return:
$9.79717439317883e-5+3.200000000000001e11i$
I was checking wolfram Alpha and it gives the same output. How to calculate this value to not get floating pointer number? Is there a special case that need to be handled? How to calculate the value to get such even number?
This is the equation I'm using for calculating of exponents taken from Wikipedia (de Moivre's formula):
$ z^{n}=(r(\cos \varphi + i\sin \varphi ))^n = r^n (\cos n\varphi + i \sin n \varphi) $
The problem is that $\varphi$ and $ r $ are real numbers the same as a result of $cos$ and $sin$. There has to be a different equation to evaluate the complex number to the power of an integer.
I was searching the Kawa source code but was not able to find anything. So hoping someone here will know the answer.
What is the equation that will give me an integer value like this? And when it should be used (what rules are required)?
EDIT: I think that this happens when both imaginary and real parts are the same integer.