Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

factoring out a term - not only a variable - in a symbolic expression

I know that I can use collect to "factor out" a variable or arrange a symbolic expressions in powers of that variable.

But if there's a term, e.g. x+1, as common factor, I don't know how to factor it out. collect doesn't work for this, e.g.:

sage: var('c0 c1 c2 x0 x1 x') sage: (c0 * (x+1) + c1(x+1) + c2c1x - c0c1(x+1)).collect(x+1) output: -c0c1(x + 1) + c1c2x + c0(x + 1) + c1*(x + 1)

What I would like to have here is: (-c0c1 + c0 + c1)(x + 1) + c1c2x

factoring out a term - not only a variable - in a symbolic expression

I know that I can use collect to "factor out" a variable or arrange a symbolic expressions in powers of that variable.

But if there's a term, e.g. x+1, as common factor, I don't know how to factor it out. collect doesn't work for this, e.g.:

sage: var('c0 c1 c2 x0 x1 x')
sage: (c0 * (x+1) + c1(x+1) c1*(x+1) + c2c1x c2*c1*x - c0c1(x+1)).collect(x+1)
c0*c1*(x+1)).collect(x+1)
output: -c0c1(x -c0*c1*(x + 1) + c1c2x c1*c2*x + c0(x c0*(x + 1) + c1*(x + 1)

1)

What I would like to have here is:

(-c0c1
(-c0*c1 + c0 + c1)(x c1)*(x + 1) + c1c2x

c1*c2*x