Thanks Vincent! What version of Sage are you using? With sage-9.8 I get:
--- from sympy import sympify exp = sympify("CRootOf(x**5 + x + 1, 0)") sage_poly = QQ['x'](list(map(QQ, reversed(exp.poly.rep.rep)))) sage_approx = RIF(exp.n()) + RIF(-1e-30, 1e-30) QQbar.polynomial_root(sage_poly, sage_approx) Outputs: ValueError: Refining interval that does not bound unique root! ---- On Sat, Apr 1, 2023 at 12:02 PM vdelecroix <20100.delecr...@gmail.com> wrote: > > Dear Marcel, > > It is a pity that this does not work more directly. Here is a work around to > achieve what you want to do > > sage: exp = sympify("CRootOf(x**5 + x + 1, 0)") > sage: sage_poly = QQ['x'](list(map(QQ, reversed(exp.poly.rep.rep)))) > sage: sage_approx = RIF(exp.n()) + RIF(-1e-30, 1e-30) > sage: QQbar.polynomial_root(sage_poly, sage_approx) > -0.7548776662466928? > > This will be fixed in https://github.com/sagemath/sage/pull/35414 and > hopefully included in the next sage version. > > Vincent > Le vendredi 31 mars 2023 à 15:00:34 UTC+2, Marcel Moosbrugger a écrit : >> >> I am trying to convert "complex_root_of" expressions to algebraic numbers >> (elements in the field QQbar). However, I get a "ValueError" with the >> message "to many values to unpack". >> >> A minimal example would be: >> >> from sage.all import * >> from sympy import sympify >> >> exp1 = sympify("CRootOf(x**2 + 1, 0)")._sage_() >> exp2 = sympify("CRootOf(x**2 + 1, 1)")._sage_() >> print(exp1) >> print(exp2) >> exp1 = QQbar(exp1) >> exp2 = QQbar(exp2) >> print(exp1) >> print(exp2) >> >> The context I am working in is: I have a tool that is currently written in >> python and sympy. I am trying to use the output of that tool to do some >> further computation using sage, and the output of the first tool may contain >> CRootOf expressions. >> >> > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-support+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sage-support/c4602f36-3cec-44e2-81a5-67dc38a50230n%40googlegroups.com. -- William (http://wstein.org) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CACLE5GC1HFN_H6%3DoWeOSVa1c6UHzHh5k8GtiUvQB9h2mS8%2BeuQ%40mail.gmail.com.