On Aug. 6, I wrote
-------------------
On Aug. 6, 2009, Mario Maio wrote:
---------------------------
I hope this is not too much a trivial question, I'm a newbie to Maxima. I'd
like to rearrange expressions like this
(3*cos(d1)^3-3*cos(d2)^3)*x
or this
(3*a*b1-3*a*b2)*x
into a simpler form with collected terms;
3*(cos(d1)^3-cos(d2)^3)*x
3*a*(b1-b2)*x
Is there a solution that works in BOTH cases ?
----------------------
use fac * ev( expr/fac, ratsimp )
(%i1) display2d:false$
(%i2) e1 : x*(A*cos(d1)^3 - A*cos(d2)^3);
(%o2) x*(cos(d1)^3*A-cos(d2)^3*A)
(%i3) A*ev (e1/A,ratsimp);
(%o3) (cos(d1)^3-cos(d2)^3)*x*A
(%i4) e2 : x*(A*a*b1 - A*a*b2);
(%o4) x*(a*b1*A-a*b2*A)
(%i5) A*a*ev(e2/(A*a),ratsimp );
(%o5) a*(b1-b2)*x*A
-----------
or maybe simpler:
(%i6) A*ratsimp(e1/A);
(%o6) (cos(d1)^3-cos(d2)^3)*x*A
(%i7) A*a*ratsimp(e2/(A*a));
(%o7) a*(b1-b2)*x*A
Ted