/** * @param ComplexType $a first operand * @param ComplexType $exp second operand * * @return array [real, imaginary] */ protected function getPowExponentPartsFromPolar(ComplexType $a, ComplexType $exp) { $eReal = $exp->r()->get(); $eImaginary = $exp->i()->get(); $logr = log($a->modulus()->get()); $theta = $a->theta()->get(); $rho = exp($logr * $eReal - $eImaginary * $theta); $beta = $theta * $eReal + $eImaginary * $logr; return [$rho * cos($beta), $rho * sin($beta)]; }
/** * @dataProvider polars */ public function testThetaReturnsCorrectValue(ComplexType $c, $r, $t) { $this->assertEquals($t, (string) $c->theta()); }