Bill Allombert on Fri, 16 Feb 2024 17:56:50 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: conversion of t_FFELT to t_POL


On Fri, Feb 16, 2024 at 11:11:03AM -0500, Max Alekseyev wrote:
> Please take a look at this example:
> 
> ? r = ffprimroot(ffgen([3,5]))
> %1 = 2*x^4 + 2*x^3 + x^2 + x + 2
> ? type(r)
> %2 = "t_FFELT"
> ? f = Pol(r)
> %3 = 2*x^4 + 2*x^3 + x^2 + x + 2
> ? type(f)
> %4 = "t_POL"
> ? print(f)
> (2*x^4 + 2*x^3 + x^2 + x + 2)
> 
> Why are there parentheses around the polynomial f when it's printed?

Because f is a constant polynomial in x whose value is r.

? poldegree(f)
%8 = 0

But really, the question you should ask is why %3 is printed without
parenthesis. This is due to 'simplify' being on.

? \y
   simplify = 0 (off)
? f = Pol(r)
%10 = (2*x^4+2*x^3+x^2+x+2)

But really, always set a name in ffgen to avoid confusion.

? \y
   simplify = 0 (off)
? r = ffprimroot(ffgen([3,5],'a))
%4 = a^4+2*a^3+2*a^2+2*a+2
? f = Pol(r,'x)
%5 = (a^4+2*a^3+2*a^2+2*a+2)

Is it clearer now ?

(I think we should set simplify to off by default. This is more confusing than
helpful).

If you want the underlying polynomial of r, just do
r.pol

? r.pol
%6 = 2*a^4+2*a^3+a^2+a+2
subst     substpol  substvec
? subst(r.pol,a,x)
%7 = 2*x^4+2*x^3+x^2+x+2

Cheers,
Bill