I am trying to program the generalized binomial theorem, where n can be any rational number, using a vectorized approach. Formula attached as image below.
The numerator for each term is n, n×(n-1) , n×(n-1)×(n-2) and so on. I have assigned 0.5 to n to and am trying to generate 5 terms.
So far, I have an array of the products of the numerator: [ 0.5 -0.5 -1.5 -2.5 -3.5] using
def num_products(number_of_terms):
r = np.arange(1,number_of_terms+1)
num_prod = np.array(n-r+1)
return num_prod
But want to create an array of the numerators for each terms, like this (w each item in array shown separated by commas):
[ 0.5, 0.5×-0.5, 0.5×-0.5×-1.5, 0.5×-0.5×-1.5×-2.5, 0.5×-0.5×-1.5×-2.5×-3.5]
Does anyone know how to do this using arrays (vectorized approach)? I am trying to make it very quick to compute the terms so I can have a larger number of terms and increase accuracy of the result.