ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 25 Apr 2022 12:46:26 +0200factoring out a term - not only a variable - in a symbolic expressionhttps://ask.sagemath.org/question/62150/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) + c2*c1*x - c0*c1*(x+1)).collect(x+1)
output: -c0*c1*(x + 1) + c1*c2*x + c0*(x + 1) + c1*(x + 1)
What I would like to have here is:
(-c0*c1 + c0 + c1)*(x + 1) + c1*c2*xAlbert_ZweisteinMon, 25 Apr 2022 12:46:26 +0200https://ask.sagemath.org/question/62150/