Inconsistent behavior when ^ operates on an equation



On 2013-08-09, Jorge Calvo <Jorge.Calvo at avemaria.edu> wrote:

> However, exponentials do not:
>
> (%i10) exp(a = b);
> (%o10) %e^(a = b)
> (%i11) 2^(a=b);
> (%o11) 2^(a = b)
>
> My guess is that the problem lies with the way that ^ handles
> equations.  As seen in (%i7), we have the correct behavior if the
> equation is on the lhs, but not on the rhs.  I imagine that
> fixing ^ would automatically fix exp() as well.
>
> Presumably the code for + can be modified for ^.  I might be able to
> fix this if I knew where to look.  However, although I know some LISP,
> I don't know which files need to be fixed.

My advice is to try it via user-defined simplificaton rules (tellsimp,
tellsimpafter, defrule, defmatch functions). The Lisp code for 
simplfication is almost entirely incomprehensible except to initiates
who have submitted to the years of penance necessary for enlightenment.

Here is a first attempt (I suspect more work is needed).

(%i2) equationp (x) := not atom(x) and (op(x) = "=" or op(x) = "#") $
(%i3) matchdeclare (ee, equationp) $
(%i4) matchdeclare (xx, lambda ([e], not equationp (e))) $
(%i5) tellsimp (xx^ee, map (lambda ([e], xx^e), ee)) $

So far, so good:

(%i9) exp (x = y);
(%o9) %e^x = %e^y
(%i10) 2^(x = y);
(%o10) 2^x = 2^y
(%i11) (foo + bar)^(x = y);
(%o11) (foo+bar)^x = (foo+bar)^y

As pointed out elsewhere, an equation raised to an equation causes
trouble. Maxima has a built-in simplication (a = b)^c => a^c = b^c,
which leads to interesting behavior when combined with the rule above.

(%i12) (foo = bar)^(x = y);
(%o12) foo^x = foo^y = (bar^x = bar^y)

Hmm. Not sure where to go from here.

best

Robert Dodier