Inconsistent behavior when ^ operates on an equation
Subject: Inconsistent behavior when ^ operates on an equation
From: Barton Willis
Date: Sat, 10 Aug 2013 11:00:53 +0000
First, ?mequalp is an internal function--using it at user-level is bad form. Second, my code did the mequalp check on the
wrong argument. Let's try:
(%i1) mequalp(x) := not mapatom(x) and op(x)="="$
(%i2) distribute_power(e) := subst("^" = lambda([a,b], if mequalp(b) then map(lambda([s], a^s), b) else funmake("^",[a,b])), e)$
(%i3) distribute_power([exp(a=b), 2^(a=b), x^2 + 1 = 42]);
(%o3) [%e^a=%e^b,2^a=2^b,x^2+1=42]
--Barton
________________________________________
Maybe a simple utility would be a workaround:
(%i33) distribute_power(e) := subst("^" = lambda([a,b], if ?mequalp(a) then map(lambda([s], s^b), a) else funmake("^",[a,b])), e)$