solve limitations

62 views
Skip to first unread message

Damiano Pasetto

unread,
Feb 21, 2026, 4:21:59 AMFeb 21
to sage-support
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 COMPLICATEDSIMPLIFICATIONS
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])

Aram Dermenjian

unread,
Feb 22, 2026, 9:13:27 AMFeb 22
to sage-s...@googlegroups.com
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

--
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 visit https://groups.google.com/d/msgid/sage-support/16dc4c1c-c8f0-4b4d-9dbb-55f896cf738an%40googlegroups.com.

الليل المعتم

unread,
Feb 26, 2026, 11:15:44 PMFeb 26
to sage-s...@googlegroups.com
Dear Professor,

I would like to briefly explain the problem I am currently working on.
Consider a polynomial curve parametrized by
x(t), y(t),
where x(t), y(t) belong to K[t] and K is an algebraically closed field of characteristic 0.
This concerns a classical question in the theory of singularities of polynomial curves.
If f(x,y) is the implicit equation of the curve, two invariants are associated with it:
Milnor number: mu = dim_K ( K[x,y] / (f_x, f_y) )
Tjurina number: nu = dim_K ( K[x,y] / (f, f_x, f_y) )
Clearly, mu >= nu.
Many years ago, together with A. Sathaye, my supervisor proved that
mu = nu if and only if the curve can be reduced to the form x = t^a, y = t^b.
This is a global version of a local result due to Zariski.
Later, he proved that
mu/2 <= nu <= mu,
and classified polynomial curves satisfying nu = mu/2.
We then attempted to classify curves for which
d = mu − nu >= 1.
The case d = 1 was solved, but the problem becomes extremely difficult for d >= 2.
After theoretical work, we obtained an algorithm that, for each parametrization, produces a system of polynomial equations in the parameters.
By computing the radical prime decomposition of this system, it simplifies significantly, allowing us to determine relations between the parameters that force
mu − nu = 1, 2, 3, etc.
I have already completed the classification for curves of degree <= 4.
The next objective is to treat degrees 5 and 6 (and possibly higher).
If the algorithm can be implemented efficiently in Sage, the classification should become computationally feasible.
If you are interested, I would be happy to send the detailed mathematics or any additional information you may need.
Best regards,
Mousa

Reply all
Reply to author
Forward
0 new messages