mathnumber-theorypari

PARI/GP code that uses nfroots to compute roots of polynomial in terms of power basis


I'm working on a PARI/GP script with the following setup. I have a quintic polynomial f(x) such that the number field K:=Q(rho) is cyclic. Here Q is the set of rational numbers and rho is a root of f. In particular, all the Galois conjugates of rho are in K. I want to extract these conjugates of rho, written in terms of {1, rho, rho^2, rho^3, rho^4}, the power basis of K.

I want the conjugates of f(x) in terms of the power basis and not as a floating point, as the nfeltembed function only takes in elements written algebraically. As my final goal is to compute the images of products of the conjugates under the 5 field embeddings. Please correct me if I am wrong in this part.

I tried using the nfroots function in PARI/GP. First, I tried the following.

lehmer_poly(n) = {
  return(x^5+n^2*x^4-(2*n^3+6*n^2+10*n+10)*x^3+(n^4+5*n^3+11*n^2+15*n+5)*x^2+(n^3+4*n^2+10*n+10)*x+1);
};
n = 5;
P = lehmer_poly(n);
K = nfinit(P);
roots = nfroots(K,P);

This gives

  ***   at top-level: roots=nfroots(K,P)
  ***                       ^------------
  *** nfroots: incorrect priority in nfroots: variable x >= x.

This same code but with the last line replaced with roots = nfroots(K) gives *** too few arguments: roots=nfroots(K). ***


Solution

  • For nfroots(K, T) to work, you must define the number field K using a lower priority variable than the one used in the polynomial T. Here's a correct (simplified) implementation:

    lehmer_poly(n, y = 'x) =
    {
      Pol([1, n^2, -(2*n^3+6*n^2+10*n+10), (n^4+5*n^3+11*n^2+15*n+5),
          (n^3+4*n^2+10*n+10), 1], y);
    }
    ? P = lehmer_poly(5, 'y)
    %1 = y^5 + 25*y^4 - 460*y^3 + 1605*y^2 + 285*y + 1
    
    ? lehmer_poly(5)
    %2 = x^5 + 25*x^4 - 460*x^3 + 1605*x^2 + 285*x + 1
    
    ? K = nfinit(P); roots = nfroots(K, lehmer_poly(5)); lift(roots)
    %3 = [y, -42/307*y^4 - 1044/307*y^3 + 19513/307*y^2 - 68838/307*y - 11960/307,
     -13/307*y^4 - 367/307*y^3 + 4629/307*y^2 - 11176/307*y - 91/307, 6/307*y^4 + 
    193/307*y^3 - 1428/307*y^2 - 2139/307*y + 1884/307, 49/307*y^4 + 1218/307*y^3 
    - 22714/307*y^2 + 81846/307*y + 2492/307]~            
    

    The variable y in these expressions stand for the algebraic number Mod(y, P) in the number field K = Q[y] / P(y) and we are factoring the polynomial P(x) in K. You could also use subst(T, 'x, 'y) to convert a polynomial from Q[x] to Q[y].

    N.B. For the specific problem of computing all Galois conjugates of a polynomial, it is simpler to use directlynfgaloisconj:

    ? nfgaloisconj(lehmer_poly(5))
    %4 = [x, -42/307*x^4 - 1044/307*x^3 + 19513/307*x^2 - 68838/307*x - 11960/307, 
    -13/307*x^4 - 367/307*x^3 + 4629/307*x^2 - 11176/307*x - 91/307, 6/307*x^4 + 
    193/307*x^3 - 1428/307*x^2 - 2139/307*x + 1884/307, 49/307*x^4 + 1218/307*x^3
    - 22714/307*x^2 + 81846/307*x + 2492/307]~