Inconsistent behavior when ^ operates on an equation



For simplifying functions there is a distribute_over feature; an example using plog:

Doesn't distribute over equality (note: plog is a simplifying function) 

 (%i1) plog(a=b);
 (%o1) plog(a=b)

Give %plog the distribute_over property

  (%i2) :lisp(defprop %plog (mequal) distribute_over)
 (MEQUAL)

 (%i2) plog(x=y);
 (%o2) plog(x)=plog(y)

But  :lisp(defprop mexpt (mequal) distribute_over) doesn't make "^" distribute over equality. This is due to the way that
simplifya (defined in simp.lisp)  special cases simplification of mexpt before it reaches the branch that checks for
the distribute_over property:

  ((and $distribute_over
              (get (caar x) 'distribute_over)
              ;; A function with the property 'distribute_over.

One possibility is to move the  $distribute_over clause before the (special case) check for mexpt simplification.  But
simplifya is a vitally important Maxima function, so there might not be a great deal of enthusiasm for changing  simplifya.
Also there might be a problem with this--I'm not sure the distribute-over function (defined in simp.lisp) handles functions
of several variables--I didn't check.

Another possibility is to insert a few lines of code into simpexpt (defined in simp.lisp) that watches for an "=" input.

--Barton

________________________________________
From: maxima-bounces at math.utexas.edu [maxima-bounces at math.utexas.edu] on behalf of Jorge Calvo [Jorge.Calvo at avemaria.edu]
Sent: Friday, August 09, 2013 10:33
To: maxima at math.utexas.edu
Subject: Inconsistent behavior when ^ operates on an equation

Hello there:

I brought up a related topic a few months ago and filed a bug report (#2522) but it seems to have disappeared.  I might have enough time now to do something about it but will need some pointers.

The issue came up as I was writing some notes for a class on the topic of using Maxima to do algebra.  (This would come right at the beginning of the course, so I want as simple and consistent a set of instructions as possible.)  As we know, there are some equations that solve() can't solve in their original form without some human assistance.  As a simple example:

(%i2) solve(x^log(x) = %e);
(%o2) [x^log(x) = %e]
(%i3) log(%);
(%o3) [log(x)^2 = 1]
(%i4) solve(%);
(%o4) [x = %e^-1,x = %e]

The point is that entering log(%) is a quick way to apply log() to each side of the equation; it's much better than having to enter log(lhs(%[1]) = log(rhs(%[1])).  I was experimenting with this idea and realized that many primitive operations work well this way:

(%i5) log(a = b);
(%o5) log(a) = log(b)
(%i6) sqrt(a = b);
(%o6) sqrt(a) = sqrt(b)
(%i7) (a = b)^2;
(%o7) a^2 = b^2
(%i8) (a = b) + 5;
(%o8) a+5 = b+5
(%i9) 5 + (a = b);
(%o9) a+5 = b+5

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.  If someone could point me in the right direction, I would surely appreciate it!

Sincerely,

Jorge

--
Dr. Jorge Alberto Calvo
Associate Professor of Mathematics
Department of Mathematics and Physics
Ave Maria University

Phone: (239) 280-1608
Email: jorge.calvo at avemaria.edu<mailto:jorge.calvo at avemaria.edu>
Web: http://sites.google.com/site/jorgealbertocalvo




_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima