public function complexPow(ComplexType $a, NI $exp)
    {
        if ($exp instanceof ComplexType) {
            $comp = new Comparator();
            $zero = new IntType(0);
            $real = 0;
            $imaginary = 0;
            if (!($comp->eq($a->r(), $zero) && $comp->eq($a->i(), $zero))) {
                list($real, $imaginary) = $this->getPowExponentPartsFromPolar($a, $exp);
            }

            return new ComplexType(
                RationalTypeFactory::fromFloat($real),
                RationalTypeFactory::fromFloat($imaginary)
            );
        }
        //non complex
        //de moivres theorum
        //z^n = r^n(cos(n.theta) + sin(n.theta)i)
        //where z is a complex number, r is the radius
        $n = $exp();
        $nTheta = $n * $a->theta()->get();
        $pow = pow($a->modulus()->get(), $n);
        $real = cos($nTheta) * $pow;
        $imaginary = sin($nTheta) * $pow;

        return new ComplexType(
            RationalTypeFactory::fromFloat($real),
            RationalTypeFactory::fromFloat($imaginary)
        );
    }