Evalb - Maple Help

MathematicalFunctions[Evalf]

 Evalb
 works as 'evalb' but handles boolean expressions involving the functions as And, Or, Not and extending the integer types 'integer', 'posint', etc. to handle floating-point numbers

 Calling Sequence Evalb(boolean_expression)

Parameters

 boolean_expression - any valid maple construction, typically an algebraic boolean_expression built with the operators and, or, or the boolean functions And, Or, Not, etc. and the type operator ::

Description

 • The Evalb command works the same way as the standard evalb command in that it 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.
 • Unlike evalb, however, Evalb also handles the boolean functions And, Or, Not, etc. and extends the integer types integer, negint, nonnegint, posint, nonposint, even and odd to handle floating-point numbers in equal footing as exact numbers. So, within the context of Evalb, both 4 and 4.0 are of type integer and even. This is particularly useful when writing numerical evaluation routines using these integer types. For example: for most functions, special cases happen when some of the parameters are integers, or non-negative integers.
 • Likewise, the ability to handle constructions using And, Or, Not, etc. permits writing these procedures with a rather simple syntax since these boolean functions are not automatically executed and the constructions using these boolean functions can be nested with no restrictions.

Examples

 > $\mathrm{with}\left(\mathrm{MathematicalFunctions}:-\mathrm{Evalf}\right)$
 $\left\{{\mathrm{Add}}{,}{\mathrm{Evalb}}{,}{\mathrm{Zoom}}{,}{\mathrm{QuadrantNumbers}}{,}{\mathrm{Singularities}}{,}{\mathrm{GenerateRecurrence}}{,}{\mathrm{PairwiseSummation}}\right\}$ (1)

When writing numerical procedures, the expressions or mathematical functions to be numerically evaluated have special cases for integer values of their parameters. For example, consider the 2F1 hypergeometric series - its sum form can be seen using the FunctionAdvisor:

 > $\mathrm{FunctionAdvisor}\left(\mathrm{sum},\mathrm{hypergeom}\right)$
 * Partial match of "sum" against topic "sum_form".
 $\left[{}_{{2}}{F}_{{1}}\left({a}{,}{b}{;}{c}{;}{z}\right){=}{\sum }_{{\mathrm{_k1}}{=}{0}}^{{\mathrm{\infty }}}\frac{{\left({a}\right)}_{{\mathrm{_k1}}}{}{\left({b}\right)}_{{\mathrm{_k1}}}{}{{z}}^{{\mathrm{_k1}}}}{{\mathrm{_k1}}{!}{}{\left({c}\right)}_{{\mathrm{_k1}}}}{,}\left({a}{::}{\mathrm{nonposint}}{\wedge }{c}{\ne }{a}{+}{1}\right){\vee }\left|{z}\right|{<}{1}{\vee }\left(\left|{z}\right|{=}{1}{\wedge }{0}{<}{-}{\mathrm{\Re }}\left({-}{c}{+}{a}{+}{b}\right)\right){\vee }\left(\left|{z}\right|{=}{1}{\wedge }{z}{\ne }{1}{\wedge }{-}{\mathrm{\Re }}\left({-}{c}{+}{a}{+}{b}\right){\in }\left({-1}{,}{0}\right]\right)\right]$ (2)

In this definition we see a pochhammer function in the denominator, so when the parameter $c$ is a nonnegative integer, the sum will diverge when the summation index, $\mathrm{k1}$, is bigger than the absolute value of $c$, because in those cases pochhammer(c, _k1) will be equal to 0 in the denominator. In turn, when either of $a$ or $b$ are nonnegative integers, the pochhammer functions in the numerator will be zero at some point, truncating the series so that the 2F1 function is a polynomial. And when both things happen at the same time, the function will be a polynomial if the absolute value of $a$ or $b$ is smaller or equal to the absolute value of $c$, and will be divergent (as in division by zero) otherwise.

The condition for divergence can thus be written using And, Or and Not as follows:

 >
 ${c}{::}{\mathrm{nonposint}}{\wedge }\left({a}{::}\left({¬}{\mathrm{nonposint}}\right){\vee }\left|{c}\right|{<}\left|{a}\right|\right){\wedge }\left({b}{::}\left({¬}{\mathrm{nonposint}}\right){\vee }\left|{c}\right|{<}\left|{b}\right|\right)$ (3)

Thus, using Evalb, you can construct a numerical procedure that first checks for this divergent case, and only forwards the problem to hypergeom for numerical evaluation directly using the condition for divergence above:

 > $F≔\left(a,b,c,z\right)→\mathbf{if}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{Evalb}\left(\mathrm{And}\left(c::\mathrm{nonposint},\mathrm{Or}\left(a::\left(\mathrm{Not}\left(\mathrm{nonposint}\right)\right),\left|c\right|<\left|a\right|\right),\mathrm{Or}\left(b::\left(\mathrm{Not}\left(\mathrm{nonposint}\right)\right),\left|c\right|<\left|b\right|\right)\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{then}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{error}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}"division by zero"\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{else}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{evalf}\left('\mathrm{hypergeom}'\left(\left[a,b\right],\left[c\right],z\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{fi}$
 ${F}{≔}\left({a}{,}{b}{,}{c}{,}{z}\right){↦}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathrm{Evalb}}\left({c}{::}{\mathrm{nonposint}}{\wedge }\left({a}{::}\left({¬}{\mathrm{nonposint}}\right){\vee }\left|{c}\right|{<}\left|{a}\right|\right){\wedge }\left({b}{::}\left({¬}{\mathrm{nonposint}}\right){\vee }\left|{c}\right|{<}\left|{b}\right|\right)\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{error}}{"division by zero"}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{else}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathrm{evalf}}\left('{\mathrm{hypergeom}}'\left(\left[{a}{,}{b}\right]{,}\left[{c}\right]{,}{z}\right)\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{end}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{if}}$ (4)

Note the simplicity in which the condition got expressed and, due to using Evalb, this condition also works as expected with floating-point numbers. For example, the following input, where c = -3.0, interrupts with division by zero

 > $F\left(-4.0,3,-3.0,0.5,0.3\right)$

while the following input, where $c=-4.0$ forwards the problem to hypergeom where the computation is performed

 > $F\left(-4.0,3,-4.0,0.5,0.3\right)$
 ${6.18750000}$ (5)

Compatibility

 • The MathematicalFunctions[Evalf][Evalb] command was introduced in Maple 2017.