Problematic SR interpretation of radicals (and non-integer rational exponents) in Sage.

38 views
Skip to first unread message

Emmanuel Charpentier

unread,
May 6, 2023, 5:25:07 AM5/6/23
to sage-devel

TLDR : Sage easily gets the roots of the polynomial system |x2^2-x1, x3^4-x1, x2+x3+2] but interprets \sqrt[3]{x}+\sqrt{x}+2 inconsistently : this expression is not zero for the above roots.

Details : see the enclosed Jupyter Lab sheet.

This seems to be little discussed in Sage documentation. Is it worth to discuss it ?

A problematic radical expression in Sage.ipynb

Emmanuel Charpentier

unread,
May 6, 2023, 5:28:29 AM5/6/23
to sage-devel

Typo in the preceding message : The polynomial system is of course |x2^2-x1, x3^3-x1, x2+x3+2]

Sorry for the noise !

Oscar Benjamin

unread,
May 6, 2023, 8:13:16 AM5/6/23
to sage-...@googlegroups.com
In the notebook you note that the results returned by sympy "do not check". I suspect this is because sympy's solve function is being called with check=False under the hood:

In [43]: x = symbols('x')

In [44]: eq = sqrt(x) + cbrt(x) + 2

In [45]: print(solve([eq], [x]))
[]

In [46]: print(solve([eq], [x], check=False))
[((1 + (3*sqrt(87) + 28)**(1/3) + (3*sqrt(87) + 28)**(2/3))**6/(729*(3*sqrt(87) + 28)**2),), ((-4 + (1 - sqrt(3)*I)*(2 - (1 - sqrt(3)*I)*(3*sqrt(87) + 28)**(1/3))*(3*sqrt(87) + 28)**(1/3))**6/(46656*(1 - sqrt(3)*I)**6*(3*sqrt(87) + 28)**2),), ((-4 + (1 + sqrt(3)*I)*(2 - (1 + sqrt(3)*I)*(3*sqrt(87) + 28)**(1/3))*(3*sqrt(87) + 28)**(1/3))**6/(46656*(1 + sqrt(3)*I)**6*(3*sqrt(87) + 28)**2),)]

With radical equations like this sympy's solve will transform them to polynomial equations and compute all solutions to the polynomial equations. Transforming to polynomials introduces spurious solutions so solve then checks to see which of the solutions satisfy the original radical equations. Passing check=False means that the checking is disabled and so you get all solutions to the polynomial equation which may or may not be solutions to the radical equation.

--
Oscar


--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/dc5d995c-e76c-4e5b-89f9-beb640a1b9e8n%40googlegroups.com.

Emmanuel Charpentier

unread,
May 6, 2023, 5:59:00 PM5/6/23
to sage-devel

Py point was that sqrt (or, more generally \displaystyle{x^{\frac{k}{p}}},\ k,p\in\mathbb{N}^+) is/are multivalued functions, and that neither Sage's solver nor the various solvers in Maxoma, Giac,Fricas and Mathematica account for this. In my example; `x:->sqrt(x)+x^(1/3)+2`  is a 6-valued function of `x`, and the solvers solve only for one *unspecified (!)* of them.

A convention exists that privilegies the positive square root of positive real numbers and sometimes the real root of of real numbers of the same sign as the argument, but this convention has no mathematical foundation defensible outside of high school (and not even then when high-schoolers discover complexes and the so-called Cardan solution to the quadrinomial…).

I was thinking that a discussion of this problem might be in order in the Sage reference manual, and wonder what is the advice of Sage users and developers, which are much more mathematically educated than I am.

BTW, the same thing could be said of log, whose extension to \mathbb{C} is done by analytic continuation, and therefore makes it multivalued. But in this case, there is no obvious conflict with polynomials… and the users of log of complexes are usually already aware of it.

Reply all
Reply to author
Forward
0 new messages