# Randomised Testing¶

Helpers for randomized testing

sympy.testing.randtest.random_complex_number(a=2, b=- 1, c=3, d=1, rational=False, tolerance=None)[source]

Return a random complex number.

To reduce chance of hitting branch cuts or anything, we guarantee b <= Im z <= d, a <= Re z <= c

When rational is True, a rational approximation to a random number is obtained within specified tolerance, if any.

sympy.testing.randtest.test_derivative_numerically(f, z, tol=1e-06, a=2, b=- 1, c=3, d=1)[source]

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.testing.randtest import test_derivative_numerically as td
>>> td(sin(x), x)
True

sympy.testing.randtest.verify_numerically(f, g, z=None, tol=1e-06, a=2, b=- 1, c=3, d=1)[source]

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.testing.randtest import verify_numerically as tn
>>> tn(sin(x)**2 + cos(x)**2, 1, x)
True