⩵
)
Equal
[x, y]x == y
True
if x and y are known to be equal, orFalse
if x and y are known to be unequal, in which caseNot[x == y]
will be True
.
Commutative properties apply, so if x == y then y == x.
For any expression x and y, Equal[x, y] == Not[Unequal[x, y]].
For any expression SameQ[x, y]
implies Equal[x, y].
x == y == z == ...
Numerical Equalities:
1 == 1.
5/3 == 3/2
Comparisons are done using the lower precision:
N[E, 100] == N[E, 150]
Compare an exact numeric expression and its corresponding approximate number:
Pi == N[Pi, 20]
Symbolic constants are compared numerically:
Pi == 3.14
Compare two exact numeric expressions; a numeric test may suffice to disprove equality:
Pi ^ E == E ^ Pi
Compare an exact expression against an approximate real number:
Pi == 3.1415``4
Real values are considered equal if they only differ in their last digits:
0.739085133215160642 == 0.739085133215160641
0.73908513321516064200000000 == 0.73908513321516064100000000
Numeric evaluation using Equal:
{Mod[6, 2] == 0, Mod[6, 4] == 0}
String equalities:
Equal["11", "11"]
Equal["121", "11"]
When we have symbols without values, the values are equal
only if the symbols are equal:
Clear[a, b]; a == b
a == a
a = b; a == b
Comparison to mismatched types is False:
Equal[11, "11"]
Lists are compared based on their elements:
{{1}, {2}} == {{1}, {2}}
{1, 2} == {1, 2, 3}
For chains of equalities, the comparison is done amongst all the pairs. The evaluation is successful only if the equality is satisfied over all the pairs:
g[1] == g[1] == g[1]
g[1] == g[1] == g[r]
Equality can also be combined with other inequality expressions, like:
g[1] == g[2] != g[3]
g[1] == g[2] <= g[3]
Equal
with no parameter or an empty list is True
:
Equal[] == True
Equal
on one parameter or list element is also True
{Equal[x], Equal[1], Equal["a"]}
This degenerate behavior is the same for Unequal
;
empty or single-element lists are both Equal
and Unequal
.