I need to extract coefficients of $n$ from some powers, products and sums of descending products and their reciprocals. The first 5 terms (in $x$) of the descending product $(x)_y$ are $$ x^y \left (1 - \frac{y(y-1)}{2x} + \frac{y(y-1)(y-2)(3y-1)}{24x^2} - \frac{y^2(y - 1)^2(y - 2)(y - 3)}{48x^3} + \frac{y(y-1)(y-2)(y-3)(y-4)(15y^3-30y^2+5y+2)}{5760x^4}\right) $$ and the first 5 terms of its reciprocal are $$ x^{-y} \left(1 + \frac{y(y-1)}{2x} + \frac{y(y-1)(y+1)(3y-2)}{24x^2} + \frac{y^2(y-1)^2(y+1)(y+2)}{48x^3} + \frac{y(y-1)(y+1)(y+2)(y+3)(15y^3-15y^2-10y+8)}{5760x^4}\right) $$

I need to extract the coefficients of various powers of $n$ in expressions like

$$ \frac{(l(v-1)-1)(v-1)l(l)_t}{(n-1)_{t+1}} - \left(\frac{(l(v-1)-1)(v-1)l(l)_t}{(n-1)_{t+1}}\right)^2 + \frac{n(v-1)l(l)_{2t}(l(v-1)-1)^2(l(v-1)-2)}{(n)_{2t+3}} $$ where $l = n/v$. (I do not know why this previous expression does not show properly. \frac seems to be OK if it has a subscript in one of numerator or denominator but not both)

To encapsulate these descending products and their powers I wrote

```
def desc_prod(x,y):
t0 = 1
t1 = - y*(y-1)/(2*x)
t2 = (y*(y-1)*(y-2)*(3*y-1))/(24*x^2)
t3 = -(y^2*(y-1)^2*(y-2)*(y-3))/(48*x^3)
t4 = y*(y-1)*(y-2)*(y-3)*(y-4)*(15*y^3-30*y^2 + 5*y + 2)/(5760*x^4)
return (x^y)*(t0 + t1 + t2 + t3 + t4 )
def desc_prod_recip(x,y):
t0 = 1
t1 = y*(y-1)/(2*x)
t2 = (y*(y+1)*(y-1)*(3*y-2))/(24*x^2)
t3 = (y^2*(y-1)^2*(y+1)*(y+2))/(48*x^3)
t4 = y*(y-1)*(y+1)*(y+2)*(y+3)*(15*y^3-15*y^2-10*y+8)/(5760*x^4)
return (x^(-y))*(t0 + t1 + t2 + t3 + t4)
def desc_prod_power(x,y,e):
t0 = 1
t1 = - y*(y-1)/(2*x)
t2 = (y*(y-1)*(y-2)*(3*y-1))/(24*x^2)
t3 = -(y^2*(y-1)^2*(y-2)*(y-3))/(48*x^3)
t4 = y*(y-1)*(y-2)*(y-3)*(y-4)*(15*y^3-30*y^2 + 5*y + 2)/(5760*x^4)
return (x^(y*e))*(1 + multinomial(e-1,1)*t1 + multinomial(e-2,2)*t1^2 + multinomial(e-1,1)*t2 + multinomial(e-3,3)*t1^3 + multinomial(e-2,1,1)*t1*t2 + multinomial(e-4,4)*t1^4 + multinomial(e-2,2)*t2^2 + multinomial(e-3,2,1)*t1^2*t2 + multinomial(e-2,1,1)*t1*t3 + multinomial(e-1,1)*t4 )
def desc_prod_recip_power(x,y,e):
t0 = 1
t1 = y*(y-1)/(2*x)
t2 = (y*(y+1)*(y-1)*(3*y-2))/(24*x^2)
t3 = (y^2*(y-1)^2*(y+1)*(y+2))/(48*x^3)
t4 = y*(y-1)*(y+1)*(y+2)*(y+3)*(15*y^3-15*y^2-10*y+8)/(5760*x^4)
return (x^(-y*e))*(1 + multinomial(e-1,1)*t1 + multinomial(e-2,2)*t1^2 + multinomial(e-1,1)*t2 + multinomial(e-3,3)*t1^3 + multinomial(e-2,1,1)*t1*t2 + multinomial(e-4,4)*t1^4 + multinomial(e-2,2)*t2^2 + multinomial(e-3,2,1)*t1^2*t2 + multinomial(e-2,1,1)*t1*t3 + multinomial(e-1,1)*t4 )
```

but sagemath does not correctly compute the coefficients in $n$. In an attempt to figure this out I asked a question here about computing coefficients of $n$ correctly and you can see there a very simple instance of sagemath failing to compute the coefficient. In my question I tried to give the simplest situation, where I do not have powers, products nor sums of my descnding products and their reciprocals, but just enough to showcase the behaviour of sage that is getting me stuck. In his answer dan_fulea suggests that I need to approach my problem differently. Can anyone please give me some advice about the best way to compute the coefficients of any given power of $n$ in expressions like mine.