0

When using factor, Pari prints the factors of a polynomial and their multiplicities. When using, say, polcyclofactors, however, the cyclotomic factors of the polynomial are listed as a vector, without multiplicity.

Is there are way to mimic polcyclofactors when just simply factoring polynomials? So, to just display the factors of the polynomial as a vector, without worrying about multiplicities?

Mystery_Jay
  • 161
  • 5

2 Answers2

1

Yes. The function factor returns a two column matrix. If you are only interested in the primes, not the multiplicities you can select just the first column:

For example:

factor(120)[,1]

If you were only interested in the multiplicities you would do [,2]. If you need the result as a vector rather than a column vector (the two types are mostly interchangeable), then you also need to add a conversion:

Vec(factor(120)[,1])

Although, I have done my examples with an integer, it also works with polynomials.

Vec(factor((1+x)^7*(1+x^2)^3)[,1])
Andrew
  • 873
  • 4
  • 10
0

A variant on Andrew's answer: you can convert a matrix into the vector of its columns using Vec, then (multi-)assign individual columns to new variables, so that

[P] = Vec(factor(120));

sets P to the vector of irreducible factors and

[P, E] = Vec(factor(120));

sets P and E to irreducible factors and multiplicities respectively. But the more messy factor()[,1] construct will be a little faster (because calling Vec causes extra copies).

K.B.
  • 861
  • 5
  • 14