import numpy as np import matplotlib.pyplot as plt X = np.arange(0, 10, 0.01) K = 100 alpha = 0.15 real_Y = K*np.exp(-alpha * X) def approx_function_generator(delta, alpha, K): def f(x): if(x <= 0): return K return (1 - delta*alpha)*f(x - delta) return f plt.plot(X, real_Y) plt.plot(X, [approx_function_generator(2, alpha, K)(x) for x in X]) plt.plot(X, [approx_function_generator(1, alpha, K)(x) for x in X]) plt.plot(X, [approx_function_generator(0.1, alpha, K)(x) for x in X]) plt.show()