sage: L[1].n()
fails because L1 is an equation, i. e a symbolic expression whose operator is the built-in “eq”, which has no n() method. However, sage: PP=-625/1000*t^4 + 2355/100*t^3 - 264051/1000*t^2 + 10269/10*t - 8538/10 sage: PP.parent() Symbolic Ring sage: L=solve(PP,t) sage: L[1].rhs().n() 6.66465694043241 + 1.07289603917368e-15*I That’s still a numerical (“inexact”) answer. But you can get an “exact” answer without explicitly going to the relevant polynomial ring : 6.66465694043241 + 1.07289603917368e-15*I sage: PP.roots(ring=QQbar, multiplicities=False) [1.125379936402974?, 6.664656940432404?, 8.52508591940022?, 21.36487720376441?] In this case, this exact answer tells you that this second root is real, which was not evident from the numerical output… HTH, Le mardi 15 septembre 2020 à 20:38:02 UTC+2, fqgo...@colby.edu a écrit : > Thanks! I've already learned more. > > What I first did was this: > > sage: PP > -0.625000000000000*t^4 + 23.5500000000000*t^3 - 264.051000000000*t^2 + > 1026.90000000000*t - 853.800000000000 > sage: L=solve(PP==0,t) > sage: L[1] > t == -1/1250*sqrt((390625*(4/1953125*I*sqrt(37468876945450884598)*sqrt(5) > - 3986170531587/244140625)^(2/3) + > 28629375*(4/1953125*I*sqrt(37468876945450884598)*sqrt(5) - > 3986170531587/244140625)^(1/3) + > 397327289)/(4/1953125*I*sqrt(37468876945450884598)*sqrt(5) - > 3986170531587/244140625)^(1/3)) + > 1/2*sqrt(-(4/1953125*I*sqrt(37468876945450884598)*sqrt(5) - > 3986170531587/244140625)^(1/3) - > 397327289/390625/(4/1953125*I*sqrt(37468876945450884598)*sqrt(5) - > 3986170531587/244140625)^(1/3) - > 2316636/5/sqrt((390625*(4/1953125*I*sqrt(37468876945450884598)*sqrt(5) - > 3986170531587/244140625)^(2/3) + > 28629375*(4/1953125*I*sqrt(37468876945450884598)*sqrt(5) - > 3986170531587/244140625)^(1/3) + > 397327289)/(4/1953125*I*sqrt(37468876945450884598)*sqrt(5) - > 3986170531587/244140625)^(1/3)) + 91614/625) + 471/50 > sage: L[1].n() > (errors) > > > TypeError: cannot evaluate symbolic expression numerically > > > I then tried to use the gp version of "solve": > > sage: gp.solve(t=10,30,PP) > File "<ipython-input-20-236b1d016f63>", line 1 > gp.solve(t=Integer(10),Integer(30),PP) > ^ > SyntaxError: positional argument follows keyword argument > > So Sage doesn't like the gp syntax. > > I now know that I could have done this by creating a polynomial ring over > R and asking for roots, or with PP.find_root(0,30), which only finds one of > the roots (there are four in that interval). > > Fernando > On 9/15/2020 1:53 PM, kcrisman wrote: > > > I still don't know my way around the Sage documentation... Sorry for the >> elementary question. >> > Yeah, we are sorry that it never has gotten more organized (though it is > actually quite thorough!). You may want to try the French (now in > English) Sage book, or Greg Bard's AMS (but free online) Sage book. > >> I just tried to use the *solve* command to find the roots of a >> polynomial of degree 4 with real coefficients. The result is a list of >> solutions expressed in (complicated) symbolic form. When I attempted to >> find the numerical value of the solutions, I got an error: >> >> TypeError: cannot evaluate symbolic expression numerically >> > There should be, and if you give us the precise commands you used, we > should be able to either log it as a bug report or something else. For > many equations we get something back like x^5-x+1==0 which we know there > isn't a formula for, but if it is using the quartic formula or something > similar it should, in principle, be able to be approximated. We'd have to > see your exact output to determine why that isn't happening. > > -- > 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/292f795f-80af-488f-835c-344fa08782d8n%40googlegroups.com > > <https://groups.google.com/d/msgid/sage-support/292f795f-80af-488f-835c-344fa08782d8n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- > ============================================================= > Fernando Q. Gouvea http://www.colby.edu/~fqgouvea > > > Carter Professor of Mathematics > Dept. of Mathematics and Statistics > Colby College > 5836 Mayflower Hill > Waterville, ME 04901 > > The first prerequisite for leading any satisfactory kind of personal > life in a technological society is the ability to resist distraction. > -- W. H. Auden > > > -- 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/26452314-5838-46dc-8caf-819ded444834n%40googlegroups.com.