def inverse_function(original_function, x_upper_bound, x_lower_bound, values): import numpy as np x_array = np.arange(x_lower_bound, x_upper_bound, 0.001) y_array = original_function(x_array) output=[] for val in values: ind=0 for i in range(len(y_array)-1): if (val <= y_array[i] and val > y_array[i+1]) ind=i break output.append(y_array[ind]) return np.array(output)