yields True if the expression lhs is not identical to rhs, and yields False otherwise.


  • e1=!=e2=!=e3 gives True if no two of the ei are identical.

Background & Context

  • UnsameQ[expr1,expr2] returns True if expr1 is not identical expr2 and otherwise returns False. In particular, UnsameQ[expr1,expr2] returns False if and only if SameQ[expr1,expr2] returns True (i.e. if there is exact correspondence between the underlying FullForm representations of expressions expr1 and expr2, with the exception that real numbers are considered SameQ if they differ only in their last binary digit). UnsameQ[expr1,expr2] may be input as expr1=!=expr2. The multiple-argument form UnsameQ[expr1,expr2,], which may also be input as expr1=!=expr2=!=, returns True if no two of the expressions expri are identical.
  • Different input forms of expressions will not be UnsameQ if their underlying representations are identical; for example, n! =!=Factorial[n] returns False. On the other hand, UnsameQ differentiates between representations of numbers that are numerically equal but that do not have identical representations. For example, UnsameQ[1,1.] and UnsameQ[1.,1.+0.I] both return True. This behavior is expressly different from that exhibited by Unequal, which performs equality testing and remains unevaluated in cases that cannot be resolved.
  • UnsameQ is related to a number of other symbols. Unequal[expr1,expr2] (which may be input as expr1!=expr2 or expr1expr2) returns True if expr1 and expr2 are numerically unequal. SameQ (which may be input as expr1===expr2) is the converse of UnsameQ.
  • PossibleZeroQ can be used to indicate if a given expression has value in some cases where UnsameQ returns True. For example, UnsameQ[Erf[Log[4]+2Log[Sin[Pi/8]]]-Erf[Log[2-Sqrt[2]]],0] returns True, whereas calling PossibleZeroQ on its first argument indicates it is equal to zero by returning True (together with an informative message indicating that a zero value could not be rigorously established). Symbolic simplifiers like Simplify, FullSimplify and RootReduce can sometimes also be used to rigorously establish equality (including in the example just given) when UnsameQ and Unequal (or SameQ and Equal) cannot.


open allclose all

Basic Examples  (2)

Test whether two expressions are not identically the same:

Click for copyable input
Click for copyable input

!= remains symbolic unless literal values are given:

Click for copyable input

Full form:

Click for copyable input

Scope  (3)

Applications  (1)

See Also

Equal  Order  SameQ


Introduced in 1991