src/Malenki/Math/Number/Complex.php
public function divide($z)
    {
        if (is_numeric($z)) {
            $z = new self($z, 0);
        }

        if ($z->is_zero) {
            throw new \InvalidArgumentException('Cannot divide by zero!');
        }

        $divisor = pow($z->re, 2) + pow($z->im, 2);

        $r = ($this->float_r * $z->re) + ($this->float_i * $z->im);
        $i = ($this->float_i * $z->re) - ($this->float_r * $z->im);
        $r = $r / $divisor;
        $i = $i / $divisor;

        return new self( $r, $i);
    }
public function divide($z)
    {
        if (is_numeric($z)) {
            $z = new self($z, 0);
        }

        if ($z->is_zero) {
            throw new \InvalidArgumentException('Cannot divide by zero!');
        }

        $divisor = pow($z->re, 2) + pow($z->im, 2);

        $r = ($this->float_r * $z->re) + ($this->float_i * $z->im);
        $i = ($this->float_i * $z->re) - ($this->float_r * $z->im);
        $r = $r / $divisor;
        $i = $i / $divisor;

        return new self( $r, $i);
    }
Divides current complex number with another.

@throw \InvalidArgumentException If argument is zero
@param  mixed   $z Complex or real number
@access public
@return Complex