evalb - Maple Programming Help

evalb

evaluate as a Boolean expression

 Calling Sequence evalb(x)

Parameters

 x - expression

Description

 • The evalb command forces the evaluation of expressions involving relational operators, using a three-valued logic system.  The return values are true, false, and FAIL. If evaluation is not possible, an unevaluated expression is returned.
 • Normally expressions containing the relational operators =, <>, <, <=, >, and >= are treated as algebraic equations or inequalities by Maple.  However, when passed as arguments to the evalb command (or when appearing in a Boolean context in an if or while statement), they are evaluated to true or false if possible.
 • Note that expressions involving > and >= are converted into equivalent expressions involving < and <=, respectively.
 • An evalb call using <, <=, >, or >= returns evaluated only with arguments of type extended_numeric, complex, or string. For more on string comparisons, see the section Operations on Entire Strings in Using Strings in Maple.
 Important: The evalb command does not simplify expressions. It may return false for a relation that is true. In such a case, apply a simplification to the relation before using evalb.
 Important: The evalb command does not perform arithmetic for inequalities involving <, <=, >, or >=. It may return unevaluated when a relation is true. In such a case, perform the arithmetic operations before using evalb.

 • The evalb command is thread-safe as of Maple 15.

Examples

 > $x=x$
 ${x}{=}{x}$ (1)
 > $\mathrm{evalb}\left(x=x\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{evalb}\left(x=y\right)$
 ${\mathrm{false}}$ (3)
 > $a≔2:$
 > $b≔2:$
 > $\mathrm{evalb}\left(a=b\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{evalb}\left(\mathrm{Float}\left(\mathrm{∞}\right)<\mathrm{∞}\right)$
 ${\mathrm{false}}$ (5)
 > $\mathrm{evalb}\left(\mathrm{Float}\left(\mathrm{undefined}\right)<\mathrm{undefined}\right)$
 ${\mathrm{false}}$ (6)
 > $\mathrm{evalb}\left(\mathrm{ℜ}\left(x\right)\ne \mathrm{ℜ}\left(x+1\right)\right)$
 ${\mathrm{true}}$ (7)

The evalb command cannot be used in some cases.

 > $\mathrm{evalb}\left(y
 ${y}{<}{x}$ (8)
 > $\mathrm{evalb}\left(2+3I<3+4I\right)$
 ${\mathrm{FAIL}}$ (9)

In some cases, you must subtract the right-hand side from the left-hand side before evaluating inequalities that use <, <=, >, or >=.

 > $\mathrm{evalb}\left(\mathrm{ℜ}\left(x\right)<\mathrm{ℜ}\left(x+1\right)\right)$
 ${\mathrm{\Re }}{}\left({x}\right){<}{1}{+}{\mathrm{\Re }}{}\left({x}\right)$ (10)
 > $\mathrm{evalb}\left(\mathrm{ℜ}\left(x\right)-\mathrm{ℜ}\left(x+1\right)<0\right)$
 ${\mathrm{true}}$ (11)

The evalb command uses address tests to determine equality.

 > $\mathrm{evalb}\left(\mathrm{ℜ}\left(x\right)\le \mathrm{ℜ}\left(x\right)\right)$
 ${\mathrm{true}}$ (12)

You must convert symbolic arguments to floating-point values when using the evalb command for inequalities that use <, <=, >, or >=.

 > $\mathrm{evalb}\left(2<\sqrt{5}\right)$
 ${2}{<}\sqrt{{5}}$ (13)
 > $\mathrm{evalb}\left(2<\mathrm{evalf}\left(\sqrt{5}\right)\right)$
 ${\mathrm{true}}$ (14)

Alternately, in this case you could use the is command to evaluate the boolean expression, without using evalf.

 > $\mathrm{is}\left(2<\sqrt{5}\right)$
 ${\mathrm{true}}$ (15)

The evalb command can be used in combination with any number of packages.

 > $\mathrm{evalb}\left({\mathrm{StringTools}}_{\mathrm{Search}}\left("2","This sentence does not contain any numbers."\right)=0\right)$
 ${\mathrm{true}}$ (16)

The evalb command can be used to check if an equation has an x-term.

 > $\mathrm{evalb}\left(\mathrm{coeff}\left({x}^{3}+2{x}^{2}-5,x\right)\ne 0\right)$
 ${\mathrm{false}}$ (17)
 > $\mathrm{evalb}\left(\mathrm{coeff}\left({x}^{3}+2{x}^{2}-5,{x}^{2}\right)\ne 0\right)$
 ${\mathrm{true}}$ (18)