18 if (!function_exists(__NAMESPACE__ .
'\\multiply')) {
19 function multiply(...$complexValues):
Complex 21 if (count($complexValues) < 2) {
22 throw new \Exception(
'This function requires at least 2 arguments');
25 $base = array_shift($complexValues);
28 foreach ($complexValues as $complex) {
29 $complex = Complex::validateComplexArgument($complex);
31 if (
$result->isComplex() && $complex->isComplex() &&
32 $result->getSuffix() !== $complex->getSuffix()) {
36 $real = (
$result->getReal() * $complex->getReal()) -
37 (
$result->getImaginary() * $complex->getImaginary());
38 $imaginary = (
$result->getReal() * $complex->getImaginary()) +
39 (
$result->getImaginary() * $complex->getReal());
44 ($imaginary == 0.0) ? null : max(
$result->getSuffix(), $complex->getSuffix())