Relational and Logical Operators

x==yequal (also input as )
x!=yunequal (also input as )
x>ygreater than
x>=ygreater than or equal to (also input as )
x<yless than
x<=yless than or equal to (also input as )
x==y==zall equal
x!=y!=zall unequal (distinct)
x>y>z, etc.strictly decreasing, etc.

Relational operators.

This tests whether is less than . The result is False.
In[1]:=
Click for copyable input
Out[1]=
Not all of these numbers are unequal, so this gives False.
In[2]:=
Click for copyable input
Out[2]=
You can mix and .
In[3]:=
Click for copyable input
Out[3]=
Since both of the quantities involved are numeric, Mathematica can determine that this is true.
In[4]:=
Click for copyable input
Out[4]=
Mathematica does not know whether this is true or false.
In[5]:=
Click for copyable input
Out[5]=
!pnot (also input as p)
p&&q&&... and (also input as )
p||q||... or (also input as )
Xor[p,q,...]exclusive or (also input as )
Nand[p,q,...] and Nor[p,q,...]nand and nor (also input as and )
If[p,then,else]give then if p is True, and else if p is False
LogicalExpand[expr]expand out logical expressions

Logical operations.

Both tests give True, so the result is True.
In[6]:=
Click for copyable input
Out[6]=

You should remember that the logical operations , , and are all double characters in Mathematica. If you have used a programming language such as C, you will be familiar with this notation.

Mathematica does not know whether this is true or false.
In[7]:=
Click for copyable input
Out[7]=
Mathematica leaves this expression unchanged.
In[8]:=
Click for copyable input
Out[8]=
You can use LogicalExpand to expand out the terms.
In[9]:=
Click for copyable input
Out[9]=
New to Mathematica? Find your learning path »
Have a question? Ask support »