# Difficulty understanding difference between == and ===

After doing this:

Clear[f, h]
f[z_] = .66 I Cos[z];
h[c_] := {Re[c], Im[c], Nest[f, c, 200]};
complexpts =
Flatten[Table[a + b I, {a, 0., 8, 8/249}, {b, -4., 4, 8/249}], 1];
t1 = Map[h, complexpts] // Chop


This works:

Select[t1, Not[#[[3]] === Indeterminate] &]


But why doesn't this work:

Select[t1, Not[#[[3]] == Indeterminate] &]


And why doesn't this work:

Select[t1, (#[[3]] != Indeterminate) &]

• Equal (==) tests for numerical equality, SameQ(===) and its negation UnsameQ(=!=) test for symbolic equality. Since Indeterminate is not a number, == and != fail. Nov 7, 2015 at 21:10
• Thanks everyone. Nice explanations. Nov 7, 2015 at 22:25
• A related question. Oct 27, 2017 at 12:40

=== (SameQ) is structural equality. a === b is True if a and b are exactly the same data structure (expressions), and False otherwise. For === it doesn't matter what a and b represent. Also, like nearly all Mathematica functions ending in Q, === always evaluates to either True or False (but nothing else).
== is mathematical equality. a == b represents the equality of two mathematical expressions. It may or may not evaluate to True or False. Equations are represented in terms of ==
Indeterminate == someNumber never evaluates in Mathematica. You end up with something that is neither False nor True in Select. Select treats that as if it were false. Compare Select[{1,2,3}, foo] where foo is an arbitrary symbol (not True or False). Also consider that Not[foo] doesn't evaluate (because foo is here treated as a yet-unknown logical variable).
• Why would 12 == "a" evaluate ?
• "a == b represents the equality of two mathematical expressions. It may or may not evaluate to True or False." Maybe it's worth noting that Mma may fail to perform the numerically "obvious" comparison and return an unevaluated, non-Boolean result in surprising situations. For instance, Sqrt[(2 - Sqrt[3])^2 + (-3 + 2 Sqrt[3])^2] == 4 - 2 Sqrt[3] doesn't evaluate straight to True, but does so when "pushed" with Simplify. Nov 10, 2015 at 18:12