# How to calculate integer exponent of complex number with integer parts to not get real values

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.

• you can use the exponentiation trick used in the powermod algorithm; here, with $z = a+bi$ and $n>0$ an integer, find $z^n$ with successive steps, at current $w$ either take $w^2$ or take $zw.$ Involves writing $n$ in binary and reversing the digits... en.wikipedia.org/wiki/Modular_exponentiation Commented Feb 11 at 22:40
• Matlab computes $(10+10i)^{10}=3.2\cdot10^{11}i$. So does WolframAlpha. Commented Feb 13 at 16:46
• @CyeWaldman and? This is the same as $+320000000000i$ Commented Feb 13 at 17:58
• @jcubic I thought that you were looking for verification of that, that's all. Commented Feb 14 at 1:07
• @CyeWaldman now I was looking, how to get this result. Commented Feb 14 at 14:53