Helpers for randomized testing
Return a bool indicating whether the error between z1 and z2 is <= tol.
If z2 is non-zero and |z1| > 1 the error is normalized by |z1|, so if you want the absolute error, call this as comp(z1 - z2, 0, tol).
Return a random complex number.
To reduce chance of hitting branch cuts or anything, we guarantee b <= Im z <= d, a <= Re z <= c
Test numerically that the symbolically computed derivative of f with respect to z is correct.
This routine does not test whether there are Floats present with precision higher than 15 digits so if there are, your results may not be what you expect due to round-off errors.
Examples
>>> from sympy import sin
>>> from sympy.abc import x
>>> from sympy.utilities.randtest import test_derivative_numerically as td
>>> td(sin(x), x)
True
Test numerically that f and g agree when evaluated in the argument z.
If z is None, all symbols will be tested. This routine does not test whether there are Floats present with precision higher than 15 digits so if there are, your results may not be what you expect due to round- off errors.
Examples
>>> from sympy import sin, cos
>>> from sympy.abc import x
>>> from sympy.utilities.randtest import test_numerically as tn
>>> tn(sin(x)**2 + cos(x)**2, 1, x)
True