sqrt(x)*sqrt(x)



A lot of interesting things were written in the last two days. It's all a question of the definition, isn't it.
As Richard Fateman suggested it, I did a few trials with a "positive sqrt" function. I'd like to understand what Maxima does.

But first of all "my" definition of the sqrt. It only considers REAL numbers!
The square root of a non-negative real number  a  (sqrt(a)) is the non-negative real number whose square (the result of multiplying the number by itself) is  a.

Now I'd like to "force Maxima to think only in real numbers". Look at this, please (I know a few forgets and assumes are not necessary):

pos_sqrt(z):=
  block(if is(z>=0)=true then return(sqrt(z))
    else throw(error()))$

assume(x<=0);
ex(x):=pos_sqrt(x)*pos_sqrt(x);
errcatch(ex(x));

forget(x<=0)$
assume(x<=0);
ex(x):=pos_sqrt(x^2);
errcatch(ex(x));

forget(x<=0)$
assume(x<=0,y<0);
ex(x,y):=pos_sqrt(x*y)*pos_sqrt(x*y);
errcatch(ex(x,y));

forget(x<=0,y<0)$
assume(x<=0,y<=0);
ex(x,y):=pos_sqrt(x*y)*pos_sqrt(x*y);
errcatch(ex(x,y));

(%o2) [x<=0]
(%o3) ex(x):=pos_sqrt(x)*pos_sqrt(x)
(%o4) []

(%o6) [x<=0]
(%o7) ex(x):=pos_sqrt(x^2)
(%o8) [-x]

(%o10) [x<=0,y<0]
(%o11) ex(x,y):=pos_sqrt(x*y)*pos_sqrt(x*y)
(%o12) [x*y]

(%o14) [x<=0,y<=0]
(%o15) ex(x,y):=pos_sqrt(x*y)*pos_sqrt(x*y)
(%o16) []


%o4 is true. The square root isn't defined (according to "my" definition). The solution set is empty.
%o8 is true since in this case (x<=0)  -x is equal to abs(x) and so non-negative.
%o12 is true. In this case (x<=0 and y<0) the square root of x*y does exist.
%o16 is false. This case should be treated as %o12. It is x*y>=0 and so the square root of x*y exists.


Compare %o12 and %o14 and look at this, please:

assume(x<=0,y<0);
sign(x*y);

forget(x<=0,y<0)$
assume(x<=0,y<=0);
sign(x*y);

(%o1) [x<=0,y<0]
(%o2) pz
(%o4) [x<=0,y<=0]
(%o5) nz

Can you explain this to me please?