First time here? Check out the FAQ!

Ask Your Question
1

Coerce an algebraic into a number field that contains it

asked 7 years ago

watson_ladd gravatar image

Consider the following code

r = QQbar.polynomial_root(x^5-x-1,CIF(RIF(0.1, 0.2), RIF(1.0, 1.1))
F,_,_ = number_field_elements_from_algebraics(r)
F(r)

Even though r can be coerced into an element of F, this coercion doesn't happen. What is the right thing for me to do? I'm interested in computing an algebraic number field that will contain a bunch of eigenvalues and want to express all the eigenvalues as elements of the number field. I've done the obvious workaround but the limitation expressed in the sample above isn't great.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
4

answered 7 years ago

vdelecroix gravatar image

updated 7 years ago

First of all, you missed a closing paranthesis on the first line. Secondly, it is better to include code that is working, that is to say include the line

sage: from sage.rings.qqbar import number_field_elements_from_algebraics

Now, if you want to convert a single element, just do

sage: K, elt, phi = r.as_number_field_element()

Then elt is the element of your number field K (that is the same thing as r). phi is the morphism from the number field K to QQbar and you can check

sage: phi(elt) == r
True
Preview: (hide)
link

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: 7 years ago

Seen: 383 times

Last updated: Dec 08 '17