Ask Your Question
0

Variables in a polynomial

asked 2016-02-08 13:48:10 +0100

nd gravatar image

updated 2016-02-11 16:24:07 +0100

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!

B=PolynomialRing(E,3,'b');

v=B.gens()

E.<r>=B.extension(x^3-2)

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".

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-02-08 14:54:56 +0100

vdelecroix gravatar image

Here is a possibility to convert your polynomial P to the desired output

sage: R2 = QQ['x','y','z','t']['r']
sage: s = R2.zero()
sage: for c,m in zip(P.coefficients(),P.monomials()):
....:         s += R2(c.polynomial('r')) * R2(m)
sage: print s
(y + 2*t)*r + x + 2*z
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-02-08 13:48:10 +0100

Seen: 443 times

Last updated: Feb 11 '16