I thought that === is shorthand for SameQ? Then why do these two expressions yield True for one and False for the other?

SameQ[((k^2 (k + 1)^2)/4 + (k + 1)^3) == (((k + 1)^2 (k + 2)^2)/4)]
((k^2 (k + 1)^2)/4 + (k + 1)^3) === (((k + 1)^2 (k + 2)^2)/4)

closed as off-topic by Szabolcs, Quantum_Oli, m_goldberg, Mr.Wizard May 13 '17 at 1:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Szabolcs, Quantum_Oli, m_goldberg, Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ The useless, but correct answer is, because SameQ[blub] gives True and you don't do what you think you do. $\endgroup$ – halirutan May 12 '17 at 17:18
  • 3
    $\begingroup$ Replace the == in the first line with a comma; SameQ[a, b] is equivalent to a === b, but SameQ[a == b] should evaluate as either SameQ[True] or SameQ[False]. $\endgroup$ – user16054 May 12 '17 at 17:21
  • $\begingroup$ Perhaps for the first line you thought you were doing something like SameQ @@ (((k^2 (k + 1)^2)/4 + (k + 1)^3) == (((k + 1)^2 (k + 2)^2)/4))? $\endgroup$ – Michael E2 May 12 '17 at 17:41
  • $\begingroup$ @user16054 Can you elaborate on the difference between SameQ[False] and SameQ[True]? $\endgroup$ – halirutan May 12 '17 at 18:37
  • 1
    $\begingroup$ @user16054 Look, this is exactly why I asked :) 1. No! SameQ[a == b] will always evaluate to True. Try SameQ[1 == 1] and SameQ[1 == 2]. 2. Yes, a==b usually evaluates to True or False. In the case of the question above, it is not. This is, why the result of the first line is SameQ[a==b] with unevaluated equation :) $\endgroup$ – halirutan May 13 '17 at 0:26

The syntax for SameQ is SameQ[x,y], with two (or more) arguments and yields True if all the arguments are the same. Your first line is merely SameQ[.] with a single argument, which of course yields True.


The documentation is admittedly lacking in detail, but basically

SameQ[a, b, c,...]

"returns True if all the" a, b, c,... "are identical." In SameQ[a], all the arguments are identical.


UnsameQ[a, b, c,...]

"gives True if no two of"" a, b, c,... "are identical." In UnsameQ[a], no two of the arguments are identical.

Hence both SameQ[a] and UnsameQ[a] return True, which might seem a paradox if you forget how the quantifiers work.


Not the answer you're looking for? Browse other questions tagged or ask your own question.