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

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

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

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)
False
True
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 - do you have a Trac account? Then you could put something to add this to the doc.

Sort by » oldest newest most voted But

sage: (eq.lhs()-eq.rhs()).log_expand()
0.0

more

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

1

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

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


(...in 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...)