Comparison operators

There are six comparison operators in Maple:

  1. x = y is true the left-hand side equals the right-hand side, and false otherwise.
  2. x <> y is false the left-hand side equals the right-hand side, and true otherwise.
  3. x < y is true the left-hand side is less than the right-hand side, and false otherwise.
  4. x <= y is true if either x < y or x = y, and false otherwise.
  5. x > y is true the left-hand side is greater than the right-hand side, and false otherwise.
  6. x >= y is true if either x > y or x = y, and false otherwise.

Always remember to write the operator just like you say it: x <= y is read as $x$ is less than or equal to $y$. Less-than is said first, and so < appears first.

Comparison operators are not evaluated until there is a need to evaluate them. This may occur as part of a condition in a while condition of a while-loop, or an until condition of a do-until-loop, or a condition of a conditional statement.

If it is necessary to evaluate a conditional statement, one can explicitly call evalb(...) on the statement.

[> 3 < 4;

$3 < 4$

[> evalb( 3 < 4 );

$true$

[> evalb( x > 4 );

$4 < x$

In addition to returning true or false, Maple will also return FAIL if a comparison is nonsensical:

[> interface( 'imaginaryunit' = 'j' );
[> evalb( 3 < j );

$\textit{FAIL}$

Later, we will see how a conditional statement can appear as the condition of a conditional statement or a while loop.