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);
    }