You are doing inexact computations, and imaginary errors creep in. Indeed, let's first run without assume()'s:
sage: s=solve(f(x) == 0,x) sage: [t.rhs().n() for t in s] [0.464973569257452 - 1.11022302462516e-16*I, 0.0267727617252126 + 1.11022302462516e-16*I, 2.00825366901734] so you see a tiny imaginary part in two of the three solutions. And they get dropped: sage: assume(x,"real") ....: assume(x>=0) ....: sage: s=solve(f(x) == 0,x) sage: [t.rhs().n() for t in s] [2.00825366901734] HTH, Dima On Tuesday, November 29, 2016 at 11:32:27 PM UTC, Long Nguyen wrote: > > Hello, > > I'm encountering an issue in using solve: > > assume(x,"real") > assume(x>=0) > f(x)=(0.01+x^2)/(1+x^2)- 0.4*x > roots = solve(f(x) == 0,x) > num_roots = len(roots) > print "roots ", num_roots > roots > plot(f(x),(x,0,3)) > > I'm expecting 3 roots, but this only finds one. Is this intended? Can > some provide insight on why this occuring? > > Would the work-around be to do this numerically using find_root instead? > > Thank you. > > Cheers, > Long > > 'SageMath version 7.3, Release Date: 2016-08-04' > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
