[Python] Why does SymPy incorrectly evaluate inequalities for infinite symbols?

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using SymPy to handle symbolic mathematics involving possibly infinite values. I need to define a symbol y>=0 and y<=sympy.inf and tried the following but the behaviour is not as I would expect it:

    import sympy

    y = sympy.symbols("y", finite=False, extended_nonnegative=True)

    print(y >= 0) # True (as expected)
    print(y < sympy.oo) # False (should be uncertain)
    print(y > 19) # True (should be uncertain)


    How to ensure the last two comparisons ain't evaluated?

    Continue reading...

Compartilhe esta Página