Karim Belabas on Fri, 16 Feb 2024 18:01:52 +0100


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

Re: conversion of t_FFELT to t_POL


* Max Alekseyev [2024-02-16 17:11]:
> 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 the operation Pol(r) didn't do what you expected: you omitted
the variable in the call to Pol(), but this is equivalent to Pol(r, 'x)
['x by default ] and it produces the constant polynomial r * 'x^0 (if
the default 'simplify' is on, this simplifies to r in %1, but it's
apparently off in your session).

Note that even though r apparently involves many "x" when printed, it
doesn't actually contain a free variable. And that printed "x" has nothing to
do with the 'x variable, it's only used for printing your t_FFELT, and
can (should) be specified as an optional argument to ffgen() [again
"x" by default]

This allows to use t_FFELT without worrying about variable priorities.
You can actually have a polynomial in 'x whose coefficients are t_FFELT
elements written in terms of "x" and this will work; this will certainly
be confusing though, so don't do that !

What you probably intended is r.pol. Beware that now, the result becomes a true
polynomial in variable 'x.

Cheers,

    K.B.
-- 
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/