Generating Functions · Generating Functions

Lesson 6

Nikolai Chukhin · Alexander S. Kulikov

Again, these eleven numbers can be found directly, but what is more important now is that they are the coefficients of the polynomial \(D^{2}(x)\), where \[D(x)=x+x^{2}+x^{3}+x^{4}+x^{5}+x^{6}.\]

from sympy import expand
from sympy.abc import x

print(expand(sum(x ** d for d in range(1, 7)) ** 2))

x**12 + 2*x**11 + 3*x**10 + 4*x**9 + 5*x**8 + 6*x**7 + 5*x**6 + 4*x**5 + 3*x**4 + 2*x**3 + x**2