Factoring polynomials




On Sat, 10 Oct 2009, Troy S wrote:

< New to Maxima.  I have a polynomial in a,b,c,x and I want it written as
< f(a,b,c)+f2(a,b,c) x + f3(a,b,c) x^2.
< 
< How do I accomplish this?
 
I think 'collectterms' is what you want.

(%i73) f : sum( product(l[random(3)+1],j,1,random(5)) *
x^random(4),i,0,20);

(%o73)
a*b*c*x^3+a*b*x^3+x^3+b^2*c*x^2+b*c*x^2+b*x^2+3*x^2+a^2*b*c*x+a*b*c*x
                +a^2*x+x+c^3+a^2*b*c+2*b*c+c+a*b+2
(%i74) collectterms(f,x);

(%o74) (a*b*c+a*b+1)*x^3+(b^2*c+b*c+b+3)*x^2+(a^2*b*c+a*b*c+a^2+1)*x+c^3
                        +a^2*b*c+2*b*c+c+a*b+2

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.