Ask Your Question

Sage says equation isn't true while Mathematica says it is

asked 2017-09-12 15:22:24 +0200

muxamilian gravatar image

I have the following equation, of which I know that it is true when sigma > 0 and mu > 0.

eq = mu + 0.5*log(2*pi*sigma^2*e) == log(sqrt(2)*sqrt(pi)*sigma*e^(mu + 0.5))

So I set the constraints assume(sigma > 0) and assume(mu > 0). When evaluating it with bool(eq), Sage says False while Mathematica says that the equation holds. What am I doing wrong?

edit retag flag offensive close merge delete


Note that Sage only says True if it can prove it is true, otherwise returning False.

kcrisman gravatar imagekcrisman ( 2017-09-12 15:25:01 +0200 )edit

Yes, you know it, but sage needs some help:

We really need a subpage to refer for this kind of bool-evaluation of symbolic equalities, it will be the hit.

So let us provide the help!

sage: var( 'mu,sigma' )
(mu, sigma)
sage: var( 'mu,sigma' );
sage: assume(sigma > 0)
sage: assume(mu > 0)
sage: eq = mu + 0.5*log(2*pi*sigma^2*e) == log(sqrt(2)*sqrt(pi)*sigma*e^(mu + 0.5))
sage: bool(eq)
sage: bool(eq.canonicalize_radical())
sage: eq.canonicalize_radical()
1.0*mu + 0.5*log(2) + 0.5*log(pi) + 1.0*log(sigma) + 0.5 == 1.0*mu + 0.5*log(2) + 0.5*log(pi) + 1.0*log(sigma) + 0.5

EDIT: Sorry, i'm afraid i was editing a comment of muxamilian...

dan_fulea gravatar imagedan_fulea ( 2017-09-12 17:11:05 +0200 )edit

@dan_fulea - do you have a Trac account? Then you could put something to add this to the doc.

kcrisman gravatar imagekcrisman ( 2017-09-13 01:25:49 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-09-12 17:03:58 +0200

FrédéricC gravatar image


sage: (eq.lhs()-eq.rhs()).log_expand()
edit flag offensive delete link more


Nice. It would be great if this could happen automagically but computability ...

kcrisman gravatar imagekcrisman ( 2017-09-12 17:09:00 +0200 )edit

Just provide the help in the evaluation, if you know it:

sage: bool(eq)
sage: bool( eq.log_expand() )

( more complicated cases he same applies.) (For me there is no need to test if a to-be-equality is an equality indeed, but even if, just evaluate the eq, if still False, than just evaluate it at random values... or plot... or apply relevant simplifications...)

dan_fulea gravatar imagedan_fulea ( 2017-09-12 17:32:11 +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


Asked: 2017-09-12 15:22:24 +0200

Seen: 267 times

Last updated: Sep 12 '17