Question: How to do a nested collect

Second Try:

f:= c/(c - 1) - c*(Pi^2 - 12*ln(c))*(1 + c)/(12*(c - 1)^3*n) + (((144*c^3 + 1584*c^2 + 1584*c + 144)*ln(c)^2 - 24*Pi^2*(1 + c)*(c^2 + 10*c + 1)*ln(c) + (-96*c^3 - 288*c^2 + 288*c + 96)*Zeta(3) + Pi^2*((Pi^2 + 24)*c^3 + (11*Pi^2 + 72)*c^2 + (11*Pi^2 - 72)*c + Pi^2 - 24))*c)/(288*(c - 1)^5*n^2)

This expression is already arranged with respect to n. However, the nominator of each term is not collected with respect to c. So naturally I thought

collect(f,[n,c]) or collect(f,[n,c],simplify)

would work. But now he messes up the nominator i.e. he can not factor and simplify. Note that the single variable case collect(f,n,simplify) works in not messing up, but this is not what I want, since the nominator of each n-term is not in c-collected form.

collect(f,[n],u->collect(u,[c],...))

also does not work, since he messes up again.

By c-collected form I mean the following:

The n^0 and n^{-1} term are actually fine. The factorization in the second term is ok. But for the third term

f2:=(144*c^3 + 1584*c^2 + 1584*c + 144)*ln(c)^2 - 24*Pi^2*(1 + c)*(c^2 + 10*c + 1)*ln(c) + (-96*c^3 - 288*c^2 + 288*c + 96)*Zeta(3) + Pi^2*((Pi^2 + 24)*c^3 + (11*Pi^2 + 72)*c^2 + (11*Pi^2 - 72)*c + Pi^2 - 24)

what I mean by c-collected is

collect(f2,c,simplify)

This is the nominator of the n^{-2} term.

I sort of managed by the following to procedings:

of:=[op(f)];
add(`~`[`/`](collect~(numer~(of), c, factor), ` $`, denom(of)));
add(collect~(of, c, simplify));

but the first one seems cumbersome for such a trivial thing that should be handled by collect. It also does not factor out the e.g. 12*ln(c)-Pi^2. This seems to be a general behaviour

g:=a*x*(x+1);
collect(g,x) does not factor out the a as in a*(x^2+x).

With the second method I'm more or less happy, but I didn't manage to completely collect the c terms i.e. the n^{-1} term is still c*(c+1) and not c^2+c.

Please Wait...