Error, (in ...) cannot determine if this expression is true or false: ... - Maple Programming Help

Home : Support : Online Help : System : Error Message Guide : cannotdetermineifthisexpression

Error, (in ...) cannot determine if this expression is true or false: ...

 Description Maple cannot determine whether something is true or false in an if statement or while clause.

Examples

A typical occurrence happens when a procedure that requires numeric arguments is called with symbolic arguments:

 > $f\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}:=\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{proc}(x)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{if}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}x\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}<\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}0\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{then}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}x^3\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{else}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}x^2\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{if}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{proc}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}$
 ${f}{:=}{\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{<}{0}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{^}{3}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{else}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{^}{2}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (2.1)
 >
 > $\mathrm{evalf}\left(\mathrm{Int}(f\left(x\right),x=-1..1\right));$
 > $\mathrm{fsolve}\left(f\left(x\right)=-1,x\right);$

Solution:

Maple evaluates the inputs to a procedure such as plot before it calls the procedure, resulting in $f$ being called with the symbolic argument $x$. Since $x$ has not yet been assigned a value, Maple cannot determine if $x$ is less than $0$. You can either delay the evaluation of the input using unevaluation quotes, or you can supply the arguments with operator form. For details, see uneval.

 > > $\mathrm{plot}\left(f,-1..1\right)$ > $\mathrm{fsolve}\left('f'\left(x\right)=-1,x\right)$
 ${-}{1.000000000}$ (2.2)
 > $\mathrm{fsolve}\left('f'\left(x\right),x=-1..1\right)$
 ${0.}$ (2.3)
 > $\mathrm{evalf}\left(\mathrm{Int}\left(f,-1..1\right)\right);$
 ${0.08333333333}$ (2.4)
 > $\mathrm{evalf}\left(\mathrm{Int}\left('f'\left(x\right),x=-1..1\right)\right);$
 ${0.08333333333}$ (2.5)