Question: What is the correct way to check if one number is greater than another?

What is the correct idiom in Maple to check that one number is greater than another or not?

For example if n=sqrt(3) and m=3 ?

Maple does not like to compare sqrt(3) with other number. It says 

   Error, cannot determine if this expression is true or false: 3 <= 3^(1/2)

I am doing this in code, so solution has to be such that it works for all cases of n and m, without the ability to look at screen and decide.

I found that using is works without the need to convert to float.  Should one then use is(n>=m) instead of evalb(n>=m) always?  

I can also always apply evalf() on each side before. But this seems like an overkill to me.

restart;

n:=sqrt(3);
m:=3;

3^(1/2)

3

if evalb(n>=m) then
   "yes";
else
   "no";
fi;

Error, cannot determine if this expression is true or false: 3 <= 3^(1/2)

if n>=m then
   "yes";
else
   "no";
fi;

Error, cannot determine if this expression is true or false: 3 <= 3^(1/2)

if evalb(evalf(n)>=m) then
   "yes";
else
   "no";
fi;

"no"

if is(n>=m) then
   "yes";
else
   "no";
fi;

"no"

 

 

Download checking_one_number_larger_than_another.mw

For reference, another software does compare these two numbers as is without the need to convert them to floating point;

But it looks the design of Maple in this aspect is different. Since the principal root of sqrt(3) is always the positive one, I did not think it will cause a problem.

Please Wait...