Ask Your Question

Automatic expression.maxima_methods().rootscontract() ?

asked 2016-03-03 11:39:50 -0500

this post is marked as community wiki

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


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 flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2016-03-04 11:54:22 -0500

metabeta gravatar image

I think the answer to my actual question should be:


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


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

edit flag offensive delete link more


Thanks, that solve my issue.

louisgag gravatar imagelouisgag ( 2016-09-26 10:45:40 -0500 )edit

answered 2016-03-03 11:49:30 -0500

tmonteil gravatar image

updated 2016-03-03 11:51:20 -0500

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))

Note however that the assumption system is pretty weak.

edit flag offensive delete link 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))

Or am I missing again smth?

metabeta gravatar imagemetabeta ( 2016-03-04 11:09:46 -0500 )edit

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))
sage: bool(e.canonicalize_radical())
tmonteil gravatar imagetmonteil ( 2016-03-04 12:00:28 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2016-03-03 11:39:50 -0500

Seen: 77 times

Last updated: Mar 04 '16