This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
Wolfram Research, Inc.

EquationsSolving Equations

1.5.6 Relational and Logical Operators

Relational operators.

This tests whether 10 is less than 7. The result is False.

In[1]:= 10 < 7


Not all of these numbers are unequal, so this gives False.

In[2]:= 3 != 2 != 3


You can mix < and <=.

In[3]:= 3 < 5 <= 6


Since both of the quantities involved are numeric, Mathematica can determine that this is true.

In[4]:= Pi^E < E^Pi


Mathematica does not know whether this is true or false.

In[5]:= x > y


Logical operations.

Both tests give True, so the result is True.

In[6]:= 7 > 4 && 2 != 3


You should remember that the logical operations ==, && and || are all double characters in Mathematica. If you have used the C programming language, you will recognize this notation as being the same as in C.

Mathematica does not know whether this is true or false.

In[7]:= p && q


Mathematica leaves this expression unchanged.

In[8]:= (p || q) && !(r || s)


You can use LogicalExpand to expand out the terms.

In[9]:= LogicalExpand[ % ]


EquationsSolving Equations