Ask Your Question
1

Coerce an algebraic into a number field that contains it

asked 2017-12-08 20:51:20 +0200

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2017-12-08 22:02:47 +0200

vdelecroix gravatar image

updated 2017-12-08 22:03:28 +0200

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
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: 2017-12-08 20:51:20 +0200

Seen: 264 times

Last updated: Dec 08 '17