approx_equal

approx_equal(x, y, tol=1e-15)[source]

Return True if two numbers are equal within the given tolerance.

This utility function returns True if two numbers are equal within the given tolerance.

Examples: >>> approx_equal(1.0e-2, 1.2e-2, 1e-2) True >>> approx_equal(1.0e-2, 1.2e-2, 1e-3) False

Parameters:
  • x (float)

  • y (float)

  • tol (float)

Return type:

bool