src/Chippyash/Math/Type/Calculator/Native.php
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)
        );
    }
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)
        );
    }
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 ) ) ; }
Complex Pow - raise number to the exponent
Will return a ComplexType
Exponent must be non complex

@param ComplexType $a operand
@param NI $exp Exponent

@return ComplexType

@throws \InvalidArgumentException If exponent is complex
Complex Pow - raise number to the exponent Will return a ComplexType Exponent must be non complex