src/Chippyash/Math/Type/Calculator/Native.php
private function complexExponent($base, ComplexType $exp)
    {
        if ($exp->isReal()) {
            return $this->rationalPow(
                RationalTypeFactory::fromFloat($base),
                $exp->r()
            );
        }

        //do the imaginary part
        //n^bi = cos(b.lg(n)) + i.sin(b.lg(n))
        $b = $exp->i()->get();
        $n = log($base);
        $r = cos($b * $n);
        $i = sin($b * $n);

        //no real part
        if ($exp->r()->get() == 0) {
            return new ComplexType(
                RationalTypeFactory::fromFloat($r),
                RationalTypeFactory::fromFloat($i)
            );
        }
        //real and imaginary part
        //n^a+bi = n^a(cos(b.lg(n)) + i.sin(b.lg(n)))
        $na = pow($base, $exp->r()->get());
        $rr = $na * $r;
        $ii = $na * $i;
        return new ComplexType(
            RationalTypeFactory::fromFloat($rr),
            RationalTypeFactory::fromFloat($ii)
        );
    }
private function complexExponent($base, ComplexType $exp)
    {
        if ($exp->isReal()) {
            return $this->rationalPow(
                RationalTypeFactory::fromFloat($base),
                $exp->r()
            );
        }

        //do the imaginary part
        //n^bi = cos(b.lg(n)) + i.sin(b.lg(n))
        $b = $exp->i()->get();
        $n = log($base);
        $r = cos($b * $n);
        $i = sin($b * $n);

        //no real part
        if ($exp->r()->get() == 0) {
            return new ComplexType(
                RationalTypeFactory::fromFloat($r),
                RationalTypeFactory::fromFloat($i)
            );
        }
        //real and imaginary part
        //n^a+bi = n^a(cos(b.lg(n)) + i.sin(b.lg(n)))
        $na = pow($base, $exp->r()->get());
        $rr = $na * $r;
        $ii = $na * $i;
        return new ComplexType(
            RationalTypeFactory::fromFloat($rr),
            RationalTypeFactory::fromFloat($ii)
        );
    }
private function complexExponent ( $ base , ComplexType $ exp ) { if ( $ exp -> isReal ( ) ) { return $ this -> rationalPow ( RationalTypeFactory :: fromFloat ( $ base ) , $ exp -> r ( ) ) ; } //do the imaginary part //n^bi = cos(b.lg(n)) + i.sin(b.lg(n)) $ b = $ exp -> i ( ) -> get ( ) ; $ n = log ( $ base ) ; $ r = cos ( $ b * $ n ) ; $ i = sin ( $ b * $ n ) ; //no real part if ( $ exp -> r ( ) -> get ( ) == 0 ) { return new ComplexType ( RationalTypeFactory :: fromFloat ( $ r ) , RationalTypeFactory :: fromFloat ( $ i ) ) ; } //real and imaginary part //n^a+bi = n^a(cos(b.lg(n)) + i.sin(b.lg(n))) $ na = pow ( $ base , $ exp -> r ( ) -> get ( ) ) ; $ rr = $ na * $ r ; $ ii = $ na * $ i ; return new ComplexType ( RationalTypeFactory :: fromFloat ( $ rr ) , RationalTypeFactory :: fromFloat ( $ ii ) ) ; }
Create complex power from natural base and complex exponent

@param int|float $base base
@param ComplexType $exp exponent

@return NI|ComplexType
Create complex power from natural base and complex exponent