def sympy_str_eq()

in src/math_verify/grader.py [0:0]


def sympy_str_eq(a: Basic | MatrixBase, b: Basic | MatrixBase) -> bool:
    """Compare two sympy expressions by string representation.

    Args:
        a: First sympy expression
        b: Second sympy expression

    Returns:
        True if string representations are equal, False otherwise
    """
    # We can't evaluate nan or zoo
    if a == nan or a == zoo:
        raise ValueError("Can't evaluate nan or zoo")
    try:
        return a == b
    except Exception:
        pass
    return False