Error, (in f1) cannot determine if this expression is true or false: 0 <= x - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Error, (in f1) cannot determine if this expression is true or false: 0 <= x

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

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

 

Description

Examples

Description

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

Examples

 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

fprocxifx<0thenx&Hat;3elsex&Hat;2end ifend proc

(2.1)

plotfx&comma;x&equals;1..1

Error, (in f) cannot determine if this expression is true or false: x < 0

evalfIntfx&comma;x&equals;1..1

Error, (in f) cannot determine if this expression is true or false: x < 0

fsolvefx&equals;1&comma;x

Error, (in f) cannot determine if this expression is true or false: x < 0


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.

plotfx&comma;x=1..1

Solution 2

Here, we supply the operator form to the plot function.  (Note it is f not fx in the first argument to plot.)

plotf&comma;1..1

Solutions for the fsolve and evalf/Int problems

fsolvefx=1&comma;x

1.000000000

(2.2)

fsolvefx&comma;x=1..1

0.

(2.3)

evalfIntf&comma;1..1

0.08333333333

(2.4)

evalfInt&apos;f&apos;x&comma;x&equals;1..1

0.08333333333

(2.5)

 

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<inextprimei

i

Error, cannot determine if this expression is true or false: 15 < nextprime(i)

Solution 1

Before beginning the loop, assign i to a starting value.

i2

i2

(2.6)

doiuntil15<inextprimei

2

3

5

7

11

13

(2.7)

Solution 2

Alternatively, use the from clause to set a starting value.

restart

for i from 1 doiuntil15<inextprimei

1

3

6

8

12

14

(2.8)

For more information about loops, see The Repetition Statement.

See Also

fsolve

Numerical Integration

plot

The Repetition Statement

Unevaluated Expressions