(f)
return sorted([expand_2arg(i) for i in (r0, r1)], key=default_sort_key)
Returns a list of roots of a quadratic polynomial.
Returns a list of roots of a quadratic polynomial.
Returns a list of roots of a quadratic polynomial .
def roots_quadratic(f):
    """Returns a list of roots of a quadratic polynomial."""
    a, b, c = f.all_coeffs()
    dom = f.get_domain()

    def _simplify(expr):
        if dom.is_Composite:
            return factor(expr)
        else:
            return simplify(expr)

    if c is S.Zero:
        r0, r1 = S.Zero, -b/a

        if not dom.is_Numerical:
            r1 = _simplify(r1)
    elif b is S.Zero:
        r = -c/a

        if not dom.is_Numerical:
            R = sqrt(_simplify(r))
        else:
            R = sqrt(r)

        r0 = R
        r1 = -R
    else:
        d = b**2 - 4*a*c

        if dom.is_Numerical:
            D = sqrt(d)

            r0 = (-b + D) / (2*a)
            r1 = (-b - D) / (2*a)
        else:
            D = sqrt(_simplify(d))
            A = 2*a

            E = _simplify(-b/A)
            F = D/A

            r0 = E + F
            r1 = E - F

    return sorted([expand_2arg(i) for i in (r0, r1)], key=default_sort_key)
def roots_quadratic ( f ) : a , b , c = f . all_coeffs ( ) dom = f . get_domain ( ) def _simplify ( expr ) : if dom . is_Composite : return factor ( expr ) else : return simplify ( expr ) if c is S . Zero : r0 , r1 = S . Zero , - b / a if not dom . is_Numerical : r1 = _simplify ( r1 ) elif b is S . Zero : r = - c / a if not dom . is_Numerical : R = sqrt ( _simplify ( r ) ) else : R = sqrt ( r ) r0 = R r1 = - R else : d = b ** 2 - 4 * a * c if dom . is_Numerical : D = sqrt ( d ) r0 = ( - b + D ) / ( 2 * a ) r1 = ( - b - D ) / ( 2 * a ) else : D = sqrt ( _simplify ( d ) ) A = 2 * a E = _simplify ( - b / A ) F = D / A r0 = E + F r1 = E - F return sorted ( [ expand_2arg ( i ) for i in ( r0 , r1 ) ] , key = default_sort_key )