Repository: sympy/sympy
File: sympy/physics/control/routh_table.py (Python)

Code before:
from sympy import Symbol

__all__ = ['RouthHurwitz', 'negative_real_root_conditions']

def negative_real_root_conditions(
        polynomial,
        var = None, /,
        *, domain=None):
    """
    Returns a list of conditions for a polynomial to have all its roots with
    negative real parts.

    Parameters
    ==========

    polynomial : Expr, Number
        The polynomial whose roots are to be analyzed.
    var : Symbol, None, optional
        The symbol representing the variable in the polynomial.
    domain : None, Domain, optional
        The domain in which the polynomial is defined.

    Returns
    =======

    list[StrictGreaterThan | bool]
        A list of conditions that must be satisfied for the polynomial to
        have all its roots with negative real parts.

    Examples
    ========

    >>> from sympy.physics.control import negative_real_root_conditions
    >>> from sympy import symbols
    >>> s = symbols('s')
    >>> p1 = (s+1)*(s+2)*(s+2.5)
    >>> negative_real_root_conditions(p1, s)
    [True, True, True]
    >>> k = symbols('k')
    >>> p2 = (s+1)*(s+k)
    >>> negative_real_root_conditions(p2, s)
    [k + 1 > 0, k*(k + 1)**3 > 0]
    >>> a = symbols('a', negative = True)
    >>> p3 = (s+1)*(s+a)
    >>> negative_real_root_conditions(p3, s)
    [a + 1 > 0, a*(a + 1)**3 > 0]

    """
    p: Poly = Poly(polynomial, var, domain = domain)

    _, p = p.clear_denoms(convert=True)

Review comment (suggestion):
I think that it is better to consistently return `S.true` or `S.false` instead of mixing types of Python bool. For example, you should return `S.true` and `S.false` instead of `True` and `False` in `_run_checks`

Code after:
from sympy import Symbol
from sympy.logic.boolalg import true, false

__all__ = ['RouthHurwitz', 'negative_real_part_conditions']

def negative_real_part_conditions(polynomial, var, /, *, domain=None):
    """
    Returns a list of conditions for a polynomial to have all its roots with
    negative real parts.

    Note: This method assumes that the leading coefficient is non-zero.
    In the opposite case, additional verification is required.

    Parameters
    ==========

    polynomial : Expr, Number
        The polynomial whose roots are to be analyzed.
    var : Symbol, None, optional
        The symbol representing the variable in the polynomial.
    domain : None, Domain, optional
        The domain in which the polynomial is defined.

    Returns
    =======

    list[StrictGreaterThan | Boolean]
        A list of conditions that must be satisfied for the polynomial to
        have all its roots with negative real parts.

    Examples
    ========

    >>> from sympy.physics.control import negative_real_part_conditions
    >>> from sympy import symbols
    >>> s = symbols('s')
    >>> p1 = (s+1)*(s+2)*(s+2.5)
    >>> negative_real_part_conditions(p1, s)
    [True, True, True]
    >>> k = symbols('k')
    >>> p2 = (s+1)*(s+k)
    >>> negative_real_part_conditions(p2, s)
    [k + 1 > 0, k*(k + 1)**3 > 0]
    >>> a = symbols('a', negative = True)
    >>> p3 = (s+1)*(s+a)
    >>> negative_real_part_conditions(p3, s)
    [a + 1 > 0, a*(a + 1)**3 > 0]

    """
    p: Poly = Poly(polynomial, var, domain = domain)