Hi Damiano, For number 1 and 3, you can get the correct answer by using "to_poly_solve=True". sage: solve(abs(x-4)==x,x, to_poly_solve=True) [x == 2] sage: solve(x^2+abs(x+1)==4,x, to_poly_solve=True) [x == -1/2*sqrt(21) + 1/2, x == 1/2*sqrt(13) - 1/2]
For number 2, the answer is correct, all values of R are present (x = 0, x < 0 and x > 0 gives you all real numbers). Alternatively, you can use the sympy algorithm, which in your case seems to give "nicer" solutions (note that you might need to force the domain to be real numbers as solve assumes the domain to be complex numbers usually): sage: solve(abs(x-4)==x,x, algorithm='sympy', domain='real') [x == 2] sage: solve(abs(x+1)>=x,x, algorithm='sympy') [x < +Infinity] sage: solve(x^2+abs(x+1)==4,x, algorithm='sympy', domain='real') [x == 1/2*sqrt(13) - 1/2, x == -1/2*sqrt(21) + 1/2] sage: solve(abs(5*x-1)>=x,x, algorithm='sympy') [[x <= (1/6)], [x >= (1/4)]] Note that you can get more information on any function using a question mark after the function: "solve?" which will show the documentation for that function allowing you to see optional parameters and examples on how to use the function. -Aram On Sat, 21 Feb 2026 at 10:21, Damiano Pasetto <[email protected]> wrote: > Hi, > I am quite new to SageMath. I wanted to use Sage to solve some easy > equations and inequalities, but frequently the solve command doesn't > provide any answer, sometimes the answers should be simplified, and > sometimes it even gives wrong answers. > > Am I doing something wrong? > > If sage cannot solve those simple problems, how can it be a valuable > alternative to mathematica? > > I am copying here some examples: > > *1) NOT SOLVIG* > in: solve(abs(x-4)==x,x) > out: [x == abs(x - 4)] NOT SOLVIG > (correct: x=2) > > *2) WRONG ANSWER* > in: solve(abs(x+1)>=x,x) > out: [[x == 0], [0 < x], [x < 0]] WRONG > (correct: all values of R) > > *3) NOT SOLVING* > in: solve(x^2+abs(x+1)==4,x) > out: [x == -sqrt(-abs(x + 1) + 4), x == sqrt(-abs(x + 1) + 4)] NOT > SOLVIG > (correct: [(-1+sqrt(13))/2, (1-sqrt(21))/2]) > > *4) CORRECT ANSWER BUT COMPLICATED*SIMPLIFICATIONS > in: solve(abs(5*x-1)>=x,x) > out: [[x == (1/4)], [x == (1/6)], [x == 0], [0 < x, x < (1/6)], [(1/4) < > x], [x < 0]] TOO COMLICATED > (correct: [x<=(1/6)], [x>=1/4]) > > -- > 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 view this discussion visit > https://groups.google.com/d/msgid/sage-support/16dc4c1c-c8f0-4b4d-9dbb-55f896cf738an%40googlegroups.com > <https://groups.google.com/d/msgid/sage-support/16dc4c1c-c8f0-4b4d-9dbb-55f896cf738an%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 view this discussion visit https://groups.google.com/d/msgid/sage-support/CAKQMtiq7w0BwToNboXgU5NPZD9q3LzxHZe%2BVK%3Ds%3D2hYce44Vbg%40mail.gmail.com.
