Given an irreducible polynomial P from Q[x] I want to find the primitive element A of the extension field defined by it.
Moreover I want to know how to write the roots of P in terms of A(per example, the coefficients of the polynomial of powers of A).
Finally I want to find the dimension of the vectors space of the extension field of the roots of P.
For example, if the roots are sqrt(2) and -sqrt(2) I can write one in terms of the other with rational coefficients(they are rational dependent). So they have dimension 1, in some sense.
One such way of starting this is by making the following:
P = some irreducible polynomial on variable x
K.<a> = NumberField(P)
f = (a).coordinates_in_terms_of_powers()
rts = P.roots(ring=QQbar)#need the QQbar as some without this some roots are not returned
for r in rts:
coeff = f(r[0])
#do something with it
So my idea was using this f to get the coefficients of the polynomial in A of the roots of P. But when I do the above I get the following error:
File "sage/rings/number_field/number_field_element.pyx", line 5341, in sage.rings.number_field.number_field_element.CoordinateFunction.__call__ (build/cythonized/sage/rings/number_field/number_field_element.cpp:43366)
raise TypeError("Cannot coerce element into this number field")
TypeError: Cannot coerce element into this number field
As I saw r[0]'s parent is a Algebraic Field. There is any way of casting or coercing this field into the number field in order to get the coefficients? Because when I write a "number" M in terms of a and call f(M) it works as expected. If not, is there any other way of getting this coefficients? Any work around from number field that gives me these coefficients in terms of the primitive element from the polynomial that generates it? Or is there another approach to this using vectors spaces or modules? Because in the end I'll also need the dimension as said before.