Error, cannot determine if this expression is true or false: ...
Error, (in ...) cannot determine if this expression is true or false: ...
Description
Examples
Maple cannot determine whether something is true or false in an if statement or while clause.
Example 1
A typical occurrence happens when a procedure that requires numeric arguments is called with symbolic arguments. Here are three examples with the same underlying problem:
f ≔ procx if x < 0 then x3 else x2 end if end proc
f≔procxifx<0thenx^3elsex^2end ifend proc
plotfx,x=−1..1
Error, (in f) cannot determine if this expression is true or false: x < 0
evalfIntfx,x=−1..1
fsolvefx=−1,x
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.
Solution 1
Here we use unevaluation quotes around f. For details, see Unevaluated Expressions.
plot⁡f⁡x,x=−1..1
Solution 2
Here, we supply the operator form to the plot function. (Note it is f not f⁡x in the first argument to plot.)
plotf,−1..1
Solutions for the fsolve and evalf/Int problems
fsolve⁡f⁡x=−1,x
−1.000000000
fsolve⁡f⁡x,x=−1..1
0.
evalf⁡Int⁡f,−1..1
0.08333333333
evalfInt'f'x,x=−1..1
Example 2
In this example, we want to use a loop to find primes less than 15. The error happens because i needs an initial value.
doiuntil15<i≔nextprime⁡i
i
Error, cannot determine if this expression is true or false: 15 < nextprime(i)
Before beginning the loop, assign i to a starting value.
i≔2
2
3
5
7
11
13
Alternatively, use the from clause to set a starting value.
restart
for i from 1 doiuntil15<i≔nextprime⁡i
1
6
8
12
14
For more information about loops, see The Repetition Statement.
See Also
fsolve
Numerical Integration
plot
The Repetition Statement
Unevaluated Expressions
Download Help Document