Search code examples
symbolic-mathsage

How to canonicalize radicals in a way that's consistent with assumptions


In the Sage docs they say that the function canonicalize_radical() chooses a branch based on its behavior at infinity. In their own words this means that

Assumptions are not taken into account during the transformation. This may result in a branch choice inconsistent with your assumptions.

Which, simply put, is a bad thing. A simple example of an answer that would be

assume(x<0) sqrt(x^2).canonicalize_radical() which returns x, and has the behavior with assume(x>0). At least we would expect the behavior to be different for the different assumptions.

Using Sage, is there a way of consistently doing this in a way that's always consistent with the assumptions? My main goal here is simplification, so maybe there's another function to do that that I'm not aware of.


Solution

  • There is a long correspondence regarding this on the Sage Trac server and on the Sage developer list and the Maxima developer list. That is why it is now called canonicalize_radical; the Maxima documentation is very clear that this is canonical in some class of expressions but not of functions (multivalued or not). That probably isn't the answer you are looking for, but the Maxima folks make it sound like that is the best one can hope for because of branch cuts.

    There are many other simplification routines, also in Sympy and other parts of Sage ...