Ask Your Question
2

Automatic expression.maxima_methods().rootscontract() ?

asked 2016-03-03 18:39:50 +0200

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

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

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-03-04 18:54:22 +0200

metabeta gravatar image

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.

edit flag offensive delete link more

Comments

Thanks, that solve my issue.

louisgag gravatar imagelouisgag ( 2016-09-26 17:45:40 +0200 )edit
0

answered 2016-03-03 18:49:30 +0200

tmonteil gravatar image

updated 2016-03-03 18:51:20 +0200

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.

edit flag offensive delete link more

Comments

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?

metabeta gravatar imagemetabeta ( 2016-03-04 18:09:46 +0200 )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())
True
tmonteil gravatar imagetmonteil ( 2016-03-04 19:00:28 +0200 )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

Stats

Asked: 2016-03-03 18:39:50 +0200

Seen: 348 times

Last updated: Mar 04 '16