Subject: Substituting expressions in Maxima result
From: Barton Willis
Date: Wed, 24 Sep 2008 17:33:53 -0500
-----maxima-bounces at math.utexas.edu wrote: -----
>The?need?for?the?ev(%,?'my_power)?is?unfortunate.??Also,?if?it's
>important,?you?can?also?catch?b?=?1/2??case.
Non-ev version:
(%i7) powerize(e) := subst(lambda([a,b],if b = 2 then square(a) elseif b =
-2 then 1/square(a)
else pow(a,b)), "^",e)$
(%i8) powerize(x^2 + 1/x^2 + sqrt(x));
(%o8) pow(x,1/2)+square(x)+1/square(x)
Again, if the square root case is important, try:
(%i10) powerize(e) := subst(lambda([a,b],if b = 2 then square(a) elseif b =
-2 then 1/square(a)
elseif b = -1/2 then 1/sqrt(a) elseif b = 1/2 then sqrt(a) else pow
(a,b)), "^",e)$
(%i11) powerize(sqrt(1+x^2) - 1/sqrt(1-x^2));
(%o11) sqrt(square(x)+1)-1/sqrt(1-square(x))
Barton