The beta function

from math import factorial, gamma import matplotlib.pyplot as plt def beta_via_factorial(x, y): return (factorial(x-1) * factorial(y-1)) / factorial(x + y - 1) def beta_via_gamma(x, y): return (gamma(x) * gamma(y)) / gamma(x+y) start, end = 10, 20 xs = [i for i in range(start, end)] ys = [i for i in range(start, end)] res = [beta_via_gamma(x, y) for x in xs for y in ys] fig, ax = plt.subplots() plt.plot(range(len(res)), res, 'k-') plt.title(r'Beta function B(x, y) = $\frac{\Gamma(x) * \Gamma(y)}{\Gamma(x+y)}$ for $x \in {[10, 20]}, y \in {[10, 20]}$') ax.xaxis.set_visible(False) plt.tight_layout() plt.show() print(beta_via_gamma(5, 10) == beta_via_factorial(5, 10)) # True The beta function, varying the parameters in the range between 10 and 20