First time here? Check out the FAQ!

Ask Your Question
2

Automatic expression.maxima_methods().rootscontract() ?

asked 9 years ago

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?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
0

answered 9 years ago

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.

Preview: (hide)
link

Comments

Thanks, that solve my issue.

louisgag gravatar imagelouisgag ( 8 years ago )
0

answered 9 years ago

tmonteil gravatar image

updated 9 years ago

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.

Preview: (hide)
link

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 ( 9 years ago )

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 ( 9 years ago )

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: 9 years ago

Seen: 539 times

Last updated: Mar 04 '16