Substituting expressions in Maxima result



-----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