6.31.4 Building a polynomial from its evaluation: genpoly
The genpoly command finds a polynomial which evaluates to a
given polynomial.
-
genpoly takes three arguments:
-
P, a polynomial with n−1 variables.
- b, an integer.
- x, the name of a variable.
- genpoly(P,b,x)
returns the polynomial Q with n variables (the n−1 variables in
P and the variable x) such that the
coefficients of Q are in the interval (−b/2,b/2] and Q|x=b =
P.
In other words, P is written in base b but using the
convention that the Euclidean remainder belongs to (−b/2,b/2]
(this convention is also known as s-mod representation).
Examples.
-
Input:
genpoly(61,6,x)
Output:
Indeed 61 divided by 6 is 10 with remainder 1, then 10 divided by 6 is 2
with remainder -2 (instead of the usual quotient 1 and remainder 4 out of bounds),
- Input:
genpoly(5,6,x)
Output:
Indeed: 5=6−1.
- Input:
genpoly(7,6,x)
Output:
Indeed: 7=6+1
- Input:
genpoly(7*y+5,6,x)
Output:
Indeed: x*y+x+y−1=y(x+1)+(x−1).
- Input:
genpoly(7*y+5*z^2,6,x)
Output:
Indeed: x*y+x*z+y−z=y*(x+1)+z*(x−1).