# Extension field over p-adics: how to write an element in the standard basis?

Suppose we have an extension field $\mathbb{Q}_2(w)$, where $w$ is a root of $f(x) = x^3 + 4x^2 + 2$. By default, Sage represents $w^3$ as $w^3 + O(w^d)$, where $d$ is the precision. How do I get Sage to print $w^3$ out as a linear combination of the standard basis, i.e., as $-4w^2 - 2$ (with -4 and -2 written as they would be in $\mathbb{Q}_2$)?

edit retag close merge delete

Please provide code to reproduce the observed behaviour.

Sort by » oldest newest most voted

Here are some ways to do it:

sage: K.<a> = Qp(2).extension(x^3 +4*x^2 + 2, print_mode="terse")
sage: a^3
2097150 + 2097148*a^2 + O(a^63)
sage: K.<a> = Qp(2, print_mode='digits').extension(x^3 +4*x^2 + 2)
sage: (a^3).polynomial()
...111111111111111111100*x^2 + ...000000000000000000000*x + ...111111111111111111110
sage: V, from_V, to_V = K.vector_space()
sage: to_V(a^3)
(...111111111111111111110, ...000000000000000000000, ...111111111111111111100)


The print modes available are "series" (default), "val-unit", "terse", "digits" and "bars". When p > 2 you can also use the print_pos keyword to print using the range -(p-1)/2 .. (p-1)/2 instead of 0 .. p-1.

more

It seems you are looking for the terse printing mode:

sage: K = Qp(2, print_mode='terse')
sage: R.<x> = K[]
sage: L.<w> = K.extension(x^3 + 4*x^2 + 2)
sage: w^3
2097150 + 2097148*w^2 + O(w^63)


There's a section PRINTING in the reference manual which has more details.

more