# Log doesn't work properly in MMA

In:= 2 Log === Log[3^2]

Out= False

Why? Seems basic enough, it should find it.

In:= Simplify[2 Log]

Out= Log

He gets it with simplify... What am I missing this time?

If you look at the documentation you see that SameQ yields true if the lhs is "identical" to the rhs and that word "identical" means much more in that statement than many might think.

SameQ, or ===, is a very narrow definition of equality.

Two expressions that might "obviously be the same" to someone with mathematical skill will sometimes be SameQ and sometimes not. SameQ is sometimes exactly what is needed to solve a challenging programming problem.

If I remember correctly, long long ago, back in the dark ages of the old plain LISP programming language, the equivalent of SameQ in LISP would just look at the memory address of the left hand side and right hand side and if those were the same then they were SameQ. That saved all the processor cycles needed to climb up and down the tree that made up each expression and compare each pair of words in memory to determine whether these two expressions were the same or not.

That is the reason there is an == and an === in LISP and in Mathematica and those are completely different things.

With Mathematica and the automatic mandatory simplifications of some parts of some expressions I think it is a little more difficult to describe PRECISELY EXACTLY what SameQ will do in every case. But I don't believe that SameQ will invoke Simplify against each expression and spend the cycles doing that and then see if the result turns out to be SameQ or not. I vaguely remember, but can't give you examples at the moment, of some what seem to be really simple examples that you might think are "the same", but that are not SameQ.

It isn't quite true, but there is some truth in the statement that Mathematica does not have "mathematical maturity." That means that Mathematica sometimes cannot see what is obviously, or relatively obviously, true to a person trained and experienced in mathematics. But, to be fair, there are probably tens of thousands of rules inside Mathematica and some or many of those might be missed by a person who is even relatively skilled in mathematics.

Even 2 Log == Log[3^2] fails in Mathematica because it drops the ball and starts playing around with approximate mathematics rather than taking the result from Simplify and seeing that both sides are SameQ. Fortunately Simplify[2 Log] === Simplify[Log[3^2]] and Simplify[2 Log] == Simplify[Log[3^2]] both get it right.

Buried somewhere in the Wolfram website there should be a detailed explanation that explains all this, but I can't put my finger on it at the moment.

Last edited:
Hey thank you for the lengthy but thorough reply. I do find mathematica behavior strange sometimes when it seems obvious it should be designed to do maths first and foremost. I guess I'll use simplify for now.

They should make a manual just for these strange cases.

Mathematica has an attitude and a learning curve that have been known since before it was ever released. This almost certainly is in part because of the history of where this came from.

The support people are also notoriously resistant for even improving the documentation in small ways. I don't think the SameQ help has changed in twenty five years.

But your example has provoked me to make one more try at getting them to add a few sentences of explanation for "identical" in SameQ and for a couple of my favorite misleading help pages. Who knows, maybe a miracle will happen and in a year they might release an improved explanation.

I was very surprised to find in the second edition of "Mathematica Navigator" a claim that SameQ would yield True if Mathematica could determine that the two expressions were identical and False otherwise, but no further explanation about what identical meant, AND a claim that for numerical expressions that SameQ would yield True if the two values if the difference were less than the uncertainty of either one of them. I did not realize that last case was there.