18 if (!function_exists(__NAMESPACE__ .
'\\divideinto')) {
19 function divideinto(...$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 throw new \InvalidArgumentException(
'Division by zero');
39 $delta1 = ($complex->getReal() *
$result->getReal()) +
40 ($complex->getImaginary() *
$result->getImaginary());
41 $delta2 = ($complex->getImaginary() *
$result->getReal()) -
42 ($complex->getReal() *
$result->getImaginary());
46 $real = $delta1 / $delta3;
47 $imaginary = $delta2 / $delta3;
52 ($imaginary == 0.0) ? null : max(
$result->getSuffix(), $complex->getSuffix())