1 | initial version |
Solution via factorization over $\mathbb{C}$:
def factor_in_t(f):
D = [0]*(f.degree()+1)
for r,m in f.roots(ring=CC):
d = 1 if r==1 else CC(r.argument()/(2*pi)).algdep(1)[1]
D[d] += m
ft = {}
d = f.degree()
while True:
while d>0 and D[d]==0:
d -= 1
if d==0:
return ft
ft[d] = D[d] // euler_phi(d)
for i in (1..d-1):
D[d//gcd(i,d)] -= ft[d]
For example, running
R.<t> = ZZ[]
factor_in_t( (t^2 - t + 1)*(t^2 + t + 1)*(t + 1)^2 )
returns a dict {6:1, 2:1}
, which is interpreted as $([6]_t)^1\cdot ([2]_t)^1$.
2 | No.2 Revision |
Solution via factorization over $\mathbb{C}$:
def factor_in_t(f):
D = [0]*(f.degree()+1)
{}
for r,m in f.roots(ring=CC):
a = CC(r.argument()/(2*pi)).algdep(1)
if a[0]==-1:
D[a[1]] = D.get(a[1],0) + m
ft = {}
K = sorted(D.keys())[::-1]
for k in K:
if D[k]>0:
ft[k] = D[k]
for d = 1 in divisors(k):
if r==1 else CC(r.argument()/(2*pi)).algdep(1)[1]
d>1:
D[d] += m
ft = {}
d = f.degree()
while True:
while d>0 and D[d]==0:
d -= 1
if d==0:
ft[k]
return ft
ft[d] = D[d] // euler_phi(d)
for i in (1..d-1):
D[d//gcd(i,d)] -= ft[d]
For example, running
R.<t> = ZZ[]
factor_in_t( (t^2 - t + 1)*(t^2 + t + 1)*(t + 1)^2 )
returns a dict {6:1, 2:1}
, which is interpreted as $([6]_t)^1\cdot ([2]_t)^1$.