Previous Up Next

2.27.3  Build a polynomial from it’s evaluation : genpoly

genpoly takes three arguments : a polynomial P with n−1 variables, an integer b and the name of a variable var.
genpoly returns the polynomial Q with n variables (the P variables and the variable var given as second argument), such that :

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). Input :

genpoly(61,6,x)

Output :

2*x^2-2*x+1

Indeed 61 divided by 6 is 10, remains 1, then 10 divided by 6 is 2 remains -2 (instead of the usual quotient 1 and remainder 4 out of bounds),

61=2*62−2*6+1 

Input :

genpoly(5,6,x)

Output :

x-1

Indeed : 5=6−1
Input :

genpoly(7,6,x)

Output :

x+1

Indeed : 7=6+1
Input :

genpoly(7*y+5,6,x)

Output :

x*y+x+y-1

Indeed : x*y+x+y−1=y(x+1)+(x−1)
Input :

genpoly(7*y+5*z^2,6,x)

Output :

x*y+x*z+y-z

Indeed : x*y+x*z+yz=y*(x+1)+z*(x−1)


Previous Up Next