is equal with realpart



On April 6, 2012, I wrote:
------------------------------
(%i1) display2d:false$

(%i2) bex : 1/sqrt(sin(x));
(%o2) 1/sqrt(sin(x))

(%i3) realpart(bex);
(%o3) cos(atan2(0,sin(x))/2)/sqrt(abs(sin(x)))

(%i4) imagpart(bex);
(%o4) -sin(atan2(0,sin(x))/2)/sqrt(abs(sin(x)))

(%i5) is (equal (bex, realpart(bex)));
(%o5) true            <==  wrong!

(%i6) is (equal (bex, imagpart(bex)));
(%o6) false          <== correct
---------------------------------
Here we also show that if a calling program (test) 
gets the wrong "true" answer from is(equal(...)), 
and then calls a subprogram (test1), an incorrect
evaluation of realpart(expr) is found in test1.

This occurs in both 5.26.0gcl and 5.25.1gcl.

First with 5.26.0gcl: (see code file at end)
--------------------------------------------
 (%i1) load(test);
(%o1) "c:/work2/test.mac"

(%i2) test(1/sqrt(sin(x)));

  test   
 aex =  1/sqrt(sin(x)) 
 aexr =  cos(atan2(0,sin(x))/2)/sqrt(abs(sin(x))) 
 isr =  t 
 
 test1  
 bex =  1/sqrt(sin(x)) 
 bexr =  1/sqrt(sin(x)) 
(%o2) 1/sqrt(sin(x))

(%i3) realpart(1/sqrt(sin(x)));
(%o3) cos(atan2(0,sin(x))/2)/sqrt(abs(sin(x)))

(%i4) is(equal(1/sqrt(sin(x)), realpart(1/sqrt(sin(x)))));
(%o4) true

(%i5) build_info();
Maxima version: 5.26.0
Maxima build date: 22:48 1/15/2012
Host type: i686-pc-mingw32
Lisp implementation type: GNU Common Lisp (GCL)
Lisp implementation version: GCL 2.6.8
--------------------------------------------
Next with 5.25.1gcl:

--------------------------------
(%i1) load(test);

(%o1) "c:/work2/test.mac"
(%i2) test(1/sqrt(sin(x)));

  test
 aex =  1/sqrt(sin(x))
 aexr =  cos(atan2(0,sin(x))/2)/sqrt(abs(sin(x)))
 isr =  true
 test1
 bex =  1/sqrt(sin(x))
 bexr =  1/sqrt(sin(x))
(%o2) 1/sqrt(sin(x))
--------------------------
Here is the code file test.mac:

--------------------------------------
/* test.mac */

test1(bex) :=
block([bexr],
   print (" test1 "),   
   print(" bex = ",bex),
   bexr : realpart(bex),   
   print(" bexr = ",bexr),
   bexr)$
   
   
   
test(aex) :=
 block([aexr,ans1,isr],
     print("  test  "),
     print(" aex = ",aex),
     
     aexr : realpart(aex),
     print(" aexr = ",aexr),     
     
     isr : is(equal(aex,realpart(aex))),
     print(" isr = ",isr),

     ans1 : test1(aex),          
     ans1)$
     
 display2d:false$
-------------------------------
Ted Woollett