Question: (a and b) is different from `and`(a, b)?

a::real and b::real;
Error, type `real` does not exist

`and`(a::real, b::real);
                       a::real and b::real

Since a::real by itself is fine, why does the conjunction give an error?

These two are evaluated differently as well:

Im(a) > 0 and a <> 0;
                           0 < Im(a)
`and`(Im(a) > 0, a <> 0);
                      0 < Im(a) and a <> 0

The consequence is that these two will work differently:

is(a <> 0) assuming Im(a) > 0 and a <> 0;
                             FAIL

is(a <> 0) assuming `and`(Im(a) > 0, a <> 0);
                             true

is(a <> 0) assuming Im(a) > 0; # sadly, just Im(a) > 0 is not enough
                             FAIL

It looks like (a and b) and `and`(a, b) just do completely different things:

x := proc() local r; r := rand(); print(r); r end proc;

a > x() and a > x() and a = a;
                          395718860534
                        395718860534 < a

`and`(a > x(), a > x(), a = a);
                          193139816415
                          22424170465
         193139816415 < a and 22424170465 < a and a = a

That is, (a and b) first simplifed the expression and then evaluated a>x() once, but `and`(a, b) evaluated the arguments without doing any simplifications.

Also, should this work (it works with `real`, which supposedly doesn't exist):

Re(a+b) assuming a::realcons, b::realcons;
                           Re(a + b)

 

Please Wait...