Ask Your Question

Revision history [back]

Sage's Symbolic Ring is probably not the best setting for your computations.

Would the following satisfy your needs?

First define number fields for a and B.

sage: k.<a> = NumberField(x^4-5*x^2-32)
sage: K.<B> = k.extension(x^2+2)
sage: a^4
5*a^2 + 32
sage: B^2
-2

Now define some expressions in a and B. Note how they self-simplify.

sage: xx = ((-12*a^3+92*a+24)*B-48*a^3-80*a+6)/(8*B-6); xx
(114/41*a^3 + 22/41*a - 48/41)*B + 24/41*a^3 + 488/41*a + 87/41
sage: yy = ((11*a^3+65*a-52)*B-605*a^3+13*a-12)/(8*B+70); yy
(935/838*a^3 + 741/838*a - 886/1257)*B - 7029/838*a^3 + 325/838*a - 418/1257

Now define a polynomial ring P over K, define some polynomial f, and substitute.

sage: P.<x,y> = K[]
sage: f = x^2 + y^2
sage: f.subs({x: xx, y: yy})
(19045574740/885354123*a^3 - 178146516864/295118041*a^2 - 23662616188/885354123*a - 2091104351128/2656062369)*B + 21451563214/885354123*a^3 + 924837417564/295118041*a^2 + 48925292450/885354123*a + 22206643558277/2656062369