Inspiration : see Sagemath's ticket 6862
rectform treats variables as real, not as indicated by the domain default :
(%i1) display2d:false;
(%o1) false
(%i2) domain:complex;
(%o2) complex
(%i3) c:a+%i*b;
(%o3) %i*b+a
(%i4) realpart(c);
(%o4) a
However, rectform does its job correctly provided that the variables are explicitly declared complex :
(%i5) declare(a, complex, b, complex);
(%o5) done
(%i6) realpart(c);
(%o6) 'realpart(a)-'imagpart(b)
I didn't (yet) check for other cases.
domain only affects the simplification of powers, and is not intended to have any effect on realpart
This should be clarified in the documentation, which is skimpy and hard to interpret. I will reclassified this as a documentation issue.
The Sagemath thread actually mentions this. It would be fairly straightforward to add a global variable which says "treat all variables as complex by default". However, much of Maxima will break with that set. For example, if variables are considered complex by default, then is(x>0) will always return unknown even after assume(x>0) (unless x is bound to a number). Users who expect rectform(x^2) to return x^2 will be shocked to find it returning realpart(x)^2 - imagpart(x)^2 + 2*%i*imagpart(x)*realpart(x). etc.
Last edit: Stavros Macrakis 2021-03-17