1 | initial version |
Let $c_k$ be the coefficient of $x^k$ in sum( z^n/(1 - 2*z + z^(n+1))^2 for n in range(N))
, then for $0 < k < N$ we have
$$c_k = [x^k] \sum_{n\geq 1} z^{n} (1-2z+z^{n+1})^{-2} = [x^k] \sum_{n\geq1} \sum_{m\geq0} z^{n+m} \binom{-2}{m} (-2+z^n)^m$$
$$=\sum_{n=1}^k \sum_{m=0\atop m\equiv k\pmod{n}}^{k-n} \binom{-2}{m} \binom{m}{\frac{k-n-m}n}(-2)^{m-\frac{k-n-m}n}.$$
Here is a corresponding code:
def c(k):
return sum(binomial(-2,m) * binomial(m,(t:=(k-m-n)//n)) * (-2)^(m-t) for n in range(1,k+1) for m in range(k%n,k-n+1,n))
Then, the coefficient of $x^k$ in (1-z)^2 * sum( z^n/(1 - 2*z + z^(n+1))^2 for n in range(N))
can be obtained simply as c(k) - 2*c(k-1) + c(k-2)
.
2 | No.2 Revision |
Let $c_k$ be the coefficient of $x^k$ in sum( z^n/(1 - 2*z + z^(n+1))^2 for n in range(N))
, then for $0 < k < N$ we have
$$c_k = [x^k] \sum_{n\geq 1} z^{n} (1-2z+z^{n+1})^{-2} = [x^k] \sum_{n\geq1} \sum_{m\geq0} z^{n+m} \binom{-2}{m} (-2+z^n)^m$$
$$=\sum_{n=1}^k \sum_{m=0\atop m\equiv k\pmod{n}}^{k-n} \binom{-2}{m} \binom{m}{\frac{k-n-m}n}(-2)^{m-\frac{k-n-m}n}.$$
Here is a corresponding code:
def c(k):
return 1 if k==0 else sum(binomial(-2,m) * binomial(m,(t:=(k-m-n)//n)) * (-2)^(m-t) for n in range(1,k+1) for m in range(k%n,k-n+1,n))
Then, the coefficient of $x^k$ in (1-z)^2 * sum( z^n/(1 - 2*z + z^(n+1))^2 for n in range(N))
can be obtained simply as c(k) - 2*c(k-1) + c(k-2)
.
3 | No.3 Revision |
Let $c_k$ be the coefficient of $x^k$ in sum( z^n/(1 - 2*z + z^(n+1))^2 for n in range(N))
, then for $0 < k < N$ we have
$$c_k = [x^k] [z^k] \sum_{n\geq 1} z^{n} (1-2z+z^{n+1})^{-2} = [x^k] [z^k] \sum_{n\geq1} \sum_{m\geq0} z^{n+m} \binom{-2}{m} (-2+z^n)^m$$
$$=\sum_{n=1}^k \sum_{m=0\atop m\equiv k\pmod{n}}^{k-n} \binom{-2}{m} \binom{m}{\frac{k-n-m}n}(-2)^{m-\frac{k-n-m}n}.$$
Here is a corresponding code:
def c(k):
return 1 if k==0 else sum(binomial(-2,m) * binomial(m,(t:=(k-m-n)//n)) * (-2)^(m-t) for n in range(1,k+1) for m in range(k%n,k-n+1,n))
Then, the coefficient of $x^k$ in (1-z)^2 * sum( z^n/(1 - 2*z + z^(n+1))^2 for n in range(N))
can be obtained simply as c(k) - 2*c(k-1) + c(k-2)
.
4 | No.4 Revision |
Let $c_k$ be the coefficient of $x^k$ $z^k$ in sum( z^n/(1 - 2*z + z^(n+1))^2 for n in range(N))
, then for $0 < k < N$ we have
$$c_k = [z^k] \sum_{n\geq 1} z^{n} (1-2z+z^{n+1})^{-2} = [z^k] \sum_{n\geq1} \sum_{m\geq0} z^{n+m} \binom{-2}{m} (-2+z^n)^m$$
$$=\sum_{n=1}^k \sum_{m=0\atop m\equiv k\pmod{n}}^{k-n} \binom{-2}{m} \binom{m}{\frac{k-n-m}n}(-2)^{m-\frac{k-n-m}n}.$$
Here is a corresponding code:
def c(k):
return 1 if k==0 else sum(binomial(-2,m) * binomial(m,(t:=(k-m-n)//n)) * (-2)^(m-t) for n in range(1,k+1) for m in range(k%n,k-n+1,n))
Then, the coefficient of $x^k$ $z^k$ in (1-z)^2 * sum( z^n/(1 - 2*z + z^(n+1))^2 for n in range(N))
can be obtained simply as c(k) - 2*c(k-1) + c(k-2)
.