symbrim.utilities.utilities.check_zero¶
- symbrim.utilities.utilities.check_zero(expr: Expr, n_evaluations: int = 10, atol: float = 1e-08) bool ¶
Check if an expression is zero based on random evaluations.
Explanation
This function evaluates the given expression with randomly generated values for the free symbols and checks if the result is zero. To minimize the chances of false positives, the evaluation is performed multiple times. However, it should be noted that false negatives can still occur. Examples are when values are close to zero or functions like the Dirac function are used, which is likely to evaluate to zero.
- Parameters:
- Returns:
Returns True if the expression evaluates to zero, and False otherwise.
- Return type: