The combine method






 
From: shinabe.munehiro at hotmail.co.jp
To: maxima at math.utexas.edu
Subject: The combine method
Date: Sat, 4 May 2013 14:02:36 +0900




I want to get Maxima to transform f(z)+a*f(y)+f(x) into f(z+a*y+x). >>The function inverse_additive could follow the same pattern--just substitute a lambda form for "+".  If you try this method and get stuck, let us know. I try it !  kill(all)$inverse_outative(e,f) :=  subst("*" = lambda([[l]],
  block([listarith : true, farg : false, q : 1, lx],
   for  lx in l  do (    if farg=false and not mapatom(lx) and op(lx)=f  then (farg : true,lx : args(lx)),
    q : q * lx
   ),         
   if farg then funmake(f, inverse_outative(q,f)) else q)
  ),
 e)$ inverse_additive(e,f) :=
 subst("+" = lambda([[l]],
  block([listarith : true, q : 0, lx, r:0],
   for  lx in l  do (
    if not mapatom(lx) and op(lx)=f then (lx : args(lx),q : q +lx) else r:r+lx
   ),
   funmake(f, inverse_outative(q,f))+r)
  ), e)$ s1:5*f(x) + 7*f(y) +42$
s2:inverse_outative(s1,f)$
inverse_additive(s2,f)$ f(7*y+5*x)+42 But I can not do this. s1:5*f(x) + 7*f(y) +3*f(z)+42$
s2:inverse_outative(s1,f)$ 3*y(z)+f(7*y)+f(5*x)+42