sympy/sympy — pull request #2014 by smichr (2013-04-15 06:54:40+00:00)
Title: apart and cancel handle nc; apart takes pseudo-multivariate

`cancel` and `apart` now handle non-commutative expressions, and `apart` will now defer judgement about the expression being multivariate until after the cancel step is taken.

Rather than raise an error, when the non-commutative error is detected, factors or terms of Mul and Add are stripped away and handled separately from the non-commutative portion.