def tolerant_equals(a, b, atol=10e-7, rtol=10e-7): return math.fabs(a - b) <= (atol + rtol * math.fabs(b))