0

I want to take some polynomial f and remove all of it's cyclotomic factors, and then look at the resulting polynomial (say g). I'm aware of polcyclofactors and the current code I have tried is:

c(f)=polcyclofactors(f)
p(f)=prod(i=1,#c(f),c(f)[i])
g(f)=f/p(f)

The issue I have is that polcyclofactors doesn't take into account multiplicity of the cyclotomic factors. For example:

f=3*x^4 + 8*x^3 + 6*x^2 - 1
g(f)
= 3*x^3 + 5*x^2 + x - 1

But

factor(f)
= 
[  x + 1 3]

[3*x - 1 1]

Is there any way to be able to nicely include multiple cyclotomic factors of f to divide by? Or will I have to look at factorising f and try and removing cyclotomic factors that way?

Mystery_Jay
  • 161
  • 5

1 Answers1

1

The following two suggestions are based on repeating the divisions until no more can be done (they are both very similar).

Suggestion 1:

r(f)={my(c); while(c=polcyclofactors(f); #c, f=f/vecprod(c)); f}

Suggestion 2:

r(f)={my(g=vecprod(polcyclofactors(f))); while(poldegree(g), f=f/g; g=gcd(f,g)); f}

Another suggestion without a loop:

r(f)={my(g=vecprod(polcyclofactors(f))); numerator(f/g^(poldegree(f)))}

Now a version that is probably superior: For each factor valuation can be used to get the required power.

r(f)={f/vecprod([t^valuation(f,t) | t<-polcyclofactors(f)])}
Andrew
  • 873
  • 4
  • 10
  • The final version is faster but incorrect: there is no guarantee that t is irreducible. Suggestion 2 (aka coprime factorization) is the way to go. – K.B. Aug 15 '21 at 13:26