# Automatic expression.maxima_methods().rootscontract() ? This post is a wiki. Anyone with karma >750 is welcome to improve it.

I have to compare quite a lot expressions and I like to do it with Sage. Sadly something like

sqrt(x^3)/sqrt(x^2) == sqrt(x)


gives false in default mode sage. Here

expression.maxima_methods().rootscontract()


does help, but is there a automatic way doing that, at least for one notebook? (Btw, why is it not the default?) Shouldn't at least simplify_full be enough to trigger that?

Maybe worth another question: Are there other pitfalls like this, I should be aware of?

edit retag close merge delete

Sort by » oldest newest most voted

I think the answer to my actual question should be:

sage.calculus.calculus.maxima('radexpand:all');
sage.calculus.calculus.maxima('rootsconmode:all');


Seems that with these setting one can avoid also other pitfalls when comparing expressions involving sqrts, e.g.

assume(x>0)
bool(sqrt(x^3)/x==sqrt(x))


should give True, which it does with the settings, but not without.

more

You should provide some assumptions about x so that the equality becomes true, for example:

sage: assume(x>0)
sage: bool(sqrt(x^3)/sqrt(x^2) == sqrt(x))
True


Note however that the assumption system is pretty weak.

more

Does your comment mean that assumptions are not propagated to a complete expression like here:

sage: %var a,b
sage: assume(a>0)
sage: assume(b>0)
sage: bool(sqrt((a*b)^2)/sqrt(a*b)==sqrt(a*b))
False


Or am I missing again smth?

Yes, this is the kind of issue with assumptions (and symbolic expression in general). Note that in this case, you can use the canonicalize radical (which makes itself some assumptions, see the doc):

sage: e =  (sqrt((a*b)^2)/sqrt(a*b) == sqrt(a*b))
True