%i and (complex 0 1)



>>> Is numberp(%i) true?
>> Does anyone know the reason for this?
> My totally uninformed guess would be that numberp was written 
> when maxima only supported real numbers.  Complex numbers 
> were added later, and numberp wasn't changed.

I'm not sure about the history, but I suspect that %i has been there for
a long time.  I don't think you should try too hard to find a completely
cogent and consistent explanation for things like this.

But one relevant fact is that the general simplifier does not put
expressions involving %i into canonical form -- e.g. 1/(1+%i) does not
automatically simplify to 1/2-%i/2.  A consequence of using CL
arithmetic to represent %i is that it *would* automatically become
1/2-%i/2.  I am not sure whether this is a good thing.  When
manipulating complex numbers, do you always want them canonicalized?
That said, numberp's are not closed under ^, and expressions in ^ are
not canonicalized -- sqrt(11+6*sqrt(2)) does not simplify to 3+sqrt(2).

Note, by the way, that %e, %pi, and sqrt(2)=2^(1/2) aren't numberp
either.  All of these are constantp, on the other hand.  

Does someone want to propose (and defend) a better definition for
numberp?

       -s