How to make results more compact



For ZINTER.

The following should do steps 1, 2,3 the rest by hand. 
  Look to the example at the end. No more time to explain the code.

1. counting which variable appears most often (Zo in my example)

2. factor out this variable; you would get a system like
   Zo*[...] + [...]

3. Repeat steps 1, 2 in each part [...] recursively as long as you are
   able to factor out further variables; you'll get something like Zo
   (a(b+c) + d(-b-c) + e( ... ) + ... ) + ( ... )



inflag:true;
mostoften(e):=block([c,el,maxi,lv,ae],
		if numberp(e) then return(false),
		lv:sort(listofvars(e)),
		ae:args(e),
		for x in lv do c[x]:0,
	        for x in ae do
	          if not(atom(x)) then  
	             for y in args(x) do
	          	    if not(numberp(y)) then c[y]:c[y]+1,
	        maxi:0,
	        for x in lv do
	         if c[x]>maxi then (maxi:c[x], el:x),
	        if maxi > 1 then return(el) else return(false));
	       
	       
rompe(e):=block([y],y:mostoften(e), if y=false then false else
[y,subst(1,y,e),subst(0,y,e)]);
	      
da(e):= block([l],l:rompe(e), if l=false then return(e) else
return(l[1]*da(l[2]-l[3])+da(l[3])));	   
----------------------------------------------------------------

Example:


(%i103) e1:expand((a+b+c)*(d+e+f)*(g+h+i));
(%o103) c*f*i+b*f*i+a*f*i+c*e*i+b*e*i+a*e*i+c*d*i+b*d*i+a*d*i+
c*f*h+b*f*h+a*f*h+
c*e*h+b*e*h+a*e*h+c*d*h+b*d*h+a*d*h+c*f*g+b*f*g+a*f*g+c*e*g+b*e*g+
a*e*g+c*d*g+
b*d*g+a*d*g
(%i104) da(e1);
(%o104) c*(f*(i+h+g)+e*(i+h+g)+d*(i+h+g))+b*(f*(i+h+g)+
e*(i+h+g)+d*(i+h+g))+a*(f*(i+h+g)+e*(i+h+g)+d*(i+h+g))
(%i105) subst(C,i+h+g,%);
(%o105) c*(f*C+e*C+d*C)+b*(f*C+e*C+d*C)+a*(f*C+e*C+d*C)
(%i106) da(expand(%));
(%o106) (c*(f+e+d)+b*(f+e+d)+a*(f+e+d))*C
(%i107) subst(B,f+e+d,%);
(%o107) (c*B+b*B+a*B)*C
(%i108) da(expand(%));
(%o108) (c+b+a)*B*C
(%i109) subst(A,c+b+a,%);
(%o109) A*B*C