public static function sqrt($z)
    {
        if (!($z instanceof Complex)) $z = static::parse($z);

        $r = sqrt($z->abs());
        $theta = $z->arg()/2;

        return new Complex($r*cos($theta), $r*sin($theta));
    }
public static function sqrt($z)
    {
        if (!($z instanceof Complex)) $z = static::parse($z);

        $r = sqrt($z->abs());
        $theta = $z->arg()/2;

        return new Complex($r*cos($theta), $r*sin($theta));
    }
public static function sqrt ( $ z ) { if ( ! ( $ z instanceof Complex ) ) $ z = static :: parse ( $ z ) ; $ r = sqrt ( $ z -> abs ( ) ) ; $ theta = $ z -> arg ( ) / 2 ; return new Complex ( $ r * cos ( $ theta ) , $ r * sin ( $ theta ) ) ; }
complex square root function

Complex::sqrt($z) computes and returns the principal branch of sqrt($z)


@param mixed $z (Complex, or parsable to Complex)
@retval Complex
complex square root function