Re: Checking conditions in MuPAD



swagat wrote:

Hi all!

I am new to this group and also new to "MuPAD". First of all, i would
like to thank MuPAD group for making this software freely available.


Please help me with this simple problem. I want to evaluate conditions something like

if (a>0) and (b>0), is (a+b)>0 end_if

But MuPAD gives me following error.

Error: Can't evaluate to boolean [bool]


Hi,

  I get rather 'then expected' for quite understandable reasons! :-)
  (is() is a function and requires parenthesis too around (a+b) > 0)

  if (a>0) and (b>0) then is(a+b > 0) end_if
  returns ~ your error :'Can't evaluate to boolean [_less]'

This error usually means that at least one of your variables can't be evaluated when needed. Here 'a' and 'b' are undefined.

  Let's do a function of a and b :
  f:= (a,b) -> if (a>0) and (b>0) then is(a+b > 0) end_if

  then you'll get :
  > f(1,1)
             TRUE
  > f(1,0)
             NIL
  ( since the 'else' case is not handled )

The question is how can i check whether a given expression is true or
false.

when i try bool((a+b)>0), i get following error message:

Error: Can't evaluate to boolean [_less]

  The test is fine but a context is needed :
  g:= (a,b) -> bool(a+b>0) for example works

  Wishing you a fine continuation!
                          Raymond

Regards, Swagat


I had to repost this (bad character) sorry... .