question on factorization



On 11/04/12 04:56, Raymond Toy wrote:
>>>>>> "lo" == lo  <james.smith1 at freenet.de> writes:
>      lo> hello Maxima users,
>      lo> a question from a newby:
>      lo> I define a function and take the derivative of it
>      lo> wrt some variables. The result is horribly long
>      lo> but it is the sum of many terms. If I examine those terms,
>      lo> for each, some factorization could be done, but are not.
>      lo> To simplify the problem, consider for instance:
>      lo> f: y1*exp(x1)+y1*cos(x1)+(x1-x2)^2;
>      lo> How come that Maxima do not put y1 as a common factor for exp(x1) and
>      lo> cos(x1) ?
>
> Because sometimes that's not what you want.  Maxima can't read your
> mind. :-)
>
>      lo> How to tell Maxima to factorize as much as possible (assuming I do not
>      lo> know myself that
>      lo> y1 is a common factor for the first two terms)  ?
>
> collectterms(f, y1) will do what you want in this case.
>
>      lo> If I use radcan, I get the result I want, but (x1-x2)^2 gets expanded,
>      lo> something I would like to avoid.
>
> Be careful with radcan.  It can change expressions in unexpected ways
> that you might not want.  Use ratsimp instead.
>
> Ray
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
thanks for the info;

collectterms would do the work, except that my expression is often of 
the type:

f: a*b*c*x1+a*b*c^2*x2;
collectterms(f,a,b,c) does not return a*b*c*(x1+c*x2);
how to force it ?

moreover, as said, I do know what terms to collect
only by visual inspection; is there a way to force Maxima
to do this kind of simplification without specification ?

thanks in advance;

Laurent