I want to study an algebraic curve defined by equations of the form

$$ a_1 \sqrt{f_1(x)} + ... + a_n \sqrt{f_n(x)} = 0, $$

where $x$ is a real variable and $f_i$ are polynomials. $ a_1,... a_n $ could be functions of $x$, and there could be more than one equation (that is a system), and it has also constant parameters (not just numbers) and other variables ($y$ for two dimensions), though all this may be not important for this question.

I wanted to use SageMath, but it seems it can't even solve an equation

$$ \sqrt{x} + \sqrt{1-x} = 1 $$

with obvious solutions 0 and 1.

x = var('x')
rad_pol = sqrt(x) + sqrt(1-x) - 1
solve(rad_pol, x)
# Out: [sqrt(x) == -sqrt(-x + 1) + 1]

I checked Mathematica online, and it solves such an equation.

However, I can't be sure that I will be able to solve my systems of equations online (because of proprietary software restrictions or online limitations), and maybe there exists an even more powerful instrument to solve such equations. In fact, I'm more interested in a good instrument to solve a system of equations, because I could do radical simplifications manually, but in this respect I see little difference between systems, because the Gröbner basis is almost universally implemented. However, a decent computer algebra system may have more advanced methods to solve radical equations than I could do manually (like this method with resultants).

I checked that online Sage can neither solve the simple equation, so the problem is likely not my installation. Do you know good free software to do that? If not, what could be considered the most powerful software for these kinds of problems, even non-free?

UPD: thanks to Samuel Lelièvre's answer, we can solve the equation above in Sage. Unfortunately, it still can't solve an equation for two points in two dimensions. Suppose we want to find a solution for

$$|\mathbf{n}_1 + \mathbf{n}_2| = 1,$$


$$\mathbf{n}_i = \frac{(x_i - x_0; y_i - y_0)}{\sqrt{(x_i - x_0)^2 + (y_i - y_0)^2}},$$

or, by squaring the first equation, $1 + 2 \mathbf n_1 \mathbf n_2 = 0$,

$$ \sqrt{(x_1-x_0)^2 + (y_1-y_0)^2} \sqrt{(x_2-x_0)^2 + (y_2-y_0)^2} + 2 \left((x_1-x_0)(x_2-x_0) + (y_1-y_0)(y_2-y_0)\right) = 0$$

This is a curve on which the sum of unit vectors to two given points is equal to one. The answer is known to be a part of a circle, and it can be solved by Mathematica (both with numeric point coordinates and with symbolic ones). Again, it can't be solved by sagemath, unfortunately. So the question about a powerful enough system remains.

# variables
x0, y0 = var('x0 y0')
# parameters
x1, x2, y1, y2 = 0, 1, 0, 0 # var('x1, x2, y1, y2')
r1, r2 = var('r1, r2')
# can't solve
eq2 = 2 * ((x1-x0)*(x2-x0) + (y1-y0)*(y2-y0)) == - r1 * r2
solve([eq2, r1**2 - ((x1-x0)**2 + (y1-y0)**2), r2**2 - ((x2-x0)**2 + (y2-y0)**2)], x0, y0, to_poly_solve=True)
# Mathematica succeeds:
# solve 2 * ((x1-x0)*(x2-x0) + (y1-y0)*(y2-y0)) == - sqrt((x1-x0)**2 + (y1-y0)**2) * sqrt((x2-x0)**2 + (y2-y0)**2), x1=0, y1=0, x2=1, y2=0 for x0, y0
# maybe try without new variables for radicals?
eq3 = 2 * ((x1-x0)*(x2-x0) + (y1-y0)*(y2-y0)) + sqrt((x1-x0)**2 + (y1-y0)**2) * sqrt((x2-x0)**2 + (y2-y0)**2) == 0
solve(eq3, x0, y0, to_poly_solve=True)
# doesn't work again, empty set.
  • 2
    $\begingroup$ Arthur Cayley (1821-1895) made a very thorough study of these curves in On polyzomal curves, otherwise the curves $\sqrt{U} + \sqrt{V} + \&\text{c.} = 0$, Transactions of the Royal Society of Edinburgh 25 (1869), pp. 1-110. archive.org copy Incidentally, Cayley uses the radical symbol with an extra horizontal bar for nonnegative square roots (see article 5, which begins at the bottom of p. 5). $\endgroup$ Aug 12, 2022 at 14:25
  • $\begingroup$ @DaveL.Renfro this article is of great importance for my study. Tremendous thanks for the reference and the link! $\endgroup$ Aug 12, 2022 at 16:11

2 Answers 2


Sage's solve has an optional parameter to_poly_solve.

It helps in this case:

sage: x = var('x')
sage: rad_pol = sqrt(x) + sqrt(1 - x) - 1
sage: solve(rad_pol, x)
[sqrt(x) == -sqrt(-x + 1) + 1]
sage: solve(rad_pol, x, to_poly_solve=True)
[x == 0, x == 1]

The documentation of solve can be accessed

  • from Sage
    • in text mode:
      sage: solve?
    • rendered in html:
      sage: browse_sage_doc(solve)
  • in the built documentation
    • online: https://doc.sagemath.org/
      in particular: solve
    • offline: file:///path_to_sage_doc/index.html
      in particular file:///path_to_sage_doc/sage/html/en/reference/calculus/sage/symbolic/expression.html?#sage.symbolic.expression.Expression.solve

Depending on how you installed Sage, typing sage.env.SAGE_DOC in a Sage session might give you a path. If so, you can replace /path_to_sage_doc with that path in the "offline" urls above.

  • $\begingroup$ Thank you very much! This really works, I upvote. My sage installation is very poor and I killed my system while struggling with OS package manager vs pip packages. However, sage works as a part of a Jupyter notebook, and I'm fine with that. Thanks for great links to docs! Unfortunately, your method doesn't work for more advanced equations (see my update). Should directly using Maxima provide more options, or is it the same functionality? $\endgroup$ Aug 13, 2022 at 13:58

The original equation is equivalent to a system with $n+1$ unknowns:

$$ \eqalign{ \sum a_i r_i & = 0, \cr r_1^2 - f_1(x) & = 0, \cr &... \cr r_n^2 - f_n(x) & = 0, } $$

with additional requirements all $r_i \geq 0$.

I was able to solve such system with sagemath (UPD: only for the simplest case, not for the updated question). Please add answers/comments, if there is some more powerful method than this or if I missed something!

  • $\begingroup$ Now I understand that this system is not completely equivalent: one has to require that $r_i >= 0$ (this is not a big problem, because all original solutions will be a subset of the new ones). I also have to think about how this affects the Gröbner basis. $\endgroup$ Aug 12, 2022 at 15:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .