Variables in a polynomial
I edited my question and put the answer I found, so this solves my problem!
My problem was: take a field " E " generated by " r " (here, "r" is a root of X^3 - 2 ) and 3 variables " b0 , b1 , b2 ".
I want to produce the element " A = b0 + r * b1 + r^2 * b2 " and it's square:
A^2 = b0^2 + (2r) * b0 * b1 + (r^2) * b1^2 + (2r^2) * b0 * b2 + 4 * b1 * b2 + (2*r) * b2^2
and express A and A^2 in terms of the basis "( 1 , r , r^2 )" so that the result becomes:
A^2 = r^2 ( b1^2 + 2 b0 * b2 ) + r ( 2 b0 * b1 + 2 b2^2 ) + ( b0^2 + b2^2 + b1 * b2 )
The solution was simply to define the number field as an extension of the ring of coefficients and the other way round! Good!
A^2=sum( [v[i] * r^i for i in range(3) ] )
gives me the solution:
(b1^2 + 2b0b2)r^2 + (2b0b1 + 2b2^2)r + b0^2 + 4b1*b2
result expressed in terms of powers of "r".