I want to find the maximum value for a that doesn't change the output from another function. (_find_mean simply finds the location of the maximum element in a matrix)This is how I am currently doing it and was wondering if there was a better way.def _find_max_a(matrix1, matrix2):    a = np.arange(0,10, 0.01)[::-1]    for val in a:        mat = matrix1 +  val * matrix2        if _find_mean(matrix1) == _find_mean(mat):            return val        else:            pass
Maximum value that satisfies a specific function
python;performance