# Expanding Matrix Expressions

I want Mathematica to recognize that

A.(-B.C)+A.B.C = 0


Yet FullSimplify and the like leaves the expression as it is. How do I get around this?

-
C is not a good name for a variable. As you can see, C is in black, indicating that it means something specific to Mathematica. Look up C in the docs if you want. –  Jacob Akkerboom May 15 '13 at 21:34
you could argue that capital anything is not a good name for either variables or functions in Mathematica! –  SEngstrom May 15 '13 at 22:11

You can teach Mathematica to factor out any number from inside a dot.

Unprotect[Dot];
x__.(c_?NumberQ y__) := c x.y
(c_?NumberQ x__).y__ := c x.y
Protect[Dot];

-
Keeping in mind that it's very easy to break things or introduce a significant performance penalty by modifying builtins ... –  Szabolcs May 15 '13 at 23:43
People often don't realize this until they get burnt. –  Szabolcs May 15 '13 at 23:44
a.(-b.c) + a.b.c // TensorExpand