1 | initial version |
To get the list of factors, you can simply do:
sage: L = list(factor(x^13-1))
sage: L
[(x + 2, 1),
(x^3 + 2*x + 2, 1),
(x^3 + x^2 + 2, 1),
(x^3 + x^2 + x + 2, 1),
(x^3 + 2*x^2 + 2*x + 2, 1)]
Here, each factor has multiplicity 1, so you can forget about the second information as follows:
sage: M = [l[0] for l in L]
sage: M
[x + 2, x^3 + 2*x + 2, x^3 + x^2 + 2, x^3 + x^2 + x + 2, x^3 + 2*x^2 + 2*x + 2]
Then you can make the iterated products as follows:
sage: [prod(M[:i]) for i in range(1,len(M)+1)]
[x + 2,
x^4 + 2*x^3 + 2*x^2 + 1,
x^7 + x^5 + x^4 + 2*x^3 + 2*x^2 + 2,
x^10 + x^9 + 2*x^8 + x^7 + x^6 + x^5 + 2*x^3 + 2*x + 1,
x^13 + 2]
Now, if you have some non-trivial multiplicities, and you want to take them into account, you can define M
as follows to repeat each factor the number of times you need:
sage: L = factor(x^8 + x^7 + x^6 + x^2 + x + 1)
sage: L
(x + 2)^2 * (x^2 + 1)^3
sage: M = []
sage: for f,m in L:
....: M += [f]*m
sage: M
[x + 2, x + 2, x^2 + 1, x^2 + 1, x^2 + 1]
Then as before:
sage: [prod(M[:i]) for i in range(1,len(M)+1)]
[x + 2,
x^2 + x + 1,
x^4 + x^3 + 2*x^2 + x + 1,
x^6 + x^5 + 2*x^3 + x + 1,
x^8 + x^7 + x^6 + x^2 + x + 1]