Indeed, 1e-30 is too precise. Changing to 1e-10 makes it work. The solution at https://github.com/sagemath/sage/pull/35414 is more robust.
Le samedi 1 avril 2023 à 21:21:05 UTC+2, William Stein a écrit : > 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.d...@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...@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/67c830d6-11bf-4a4b-ad35-6bc3b7042f00n%40googlegroups.com.