- #1

- 42

- 0

Out[48]= False

Why? Seems basic enough, it should find it.

In[49]:= Simplify[2 Log[3]]

Out[49]= Log[9]

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

Thank you in advance.

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter Nile3
- Start date

- #1

- 42

- 0

Out[48]= False

Why? Seems basic enough, it should find it.

In[49]:= Simplify[2 Log[3]]

Out[49]= Log[9]

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

Thank you in advance.

- #2

- 1,069

- 29

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[3] == 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[3]] === Simplify[Log[3^2]] and Simplify[2 Log[3]] == 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.

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[3] == 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[3]] === Simplify[Log[3^2]] and Simplify[2 Log[3]] == 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:

- #3

- 42

- 0

They should make a manual just for these strange cases.

- #4

- 1,069

- 29

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.

Share:

- Replies
- 1

- Views
- 1K