# How Simplify and Assume can be combined on matrix products?

What I am trying to do is to simplify some expressions involving matrices! The problem is that Simplify[] considers the simplifications based on alphabetical order and everything is Commutative. For instance, let

f[e_] := df*(e^1 + Subscript[C, 2]*e^2 + Subscript[C, 3]*e^3 +
Subscript[C, 4]*e^4 + Subscript[C, 5]*e^5 + Subscript[C, 6]*e^6);


and

fe = f[e]; f1e = f'[e];
u = Simplify[e - (2/3) Series[fe/f1e, {e, 0, 4}]];
f1u = f'[u]; J = (3 f1u + f1e)/(6 f1u - 2 f1e);
v = Simplify[e - J*(f[e]/f'[e])]


In fact, when I call Simplify[] in the above piece of code, Subscript[C, 2], ..., Subscript[C, 6] must be considered as matrices. I mean, Simplify[], assume that all muliplications are Commutative, while there is no such thing for matrices. To tackle this, I also added

NonCommutativeMultiply[Subscript[C, 2], Subscript[C, 3], Subscript[C, 4], Subscript[C, 5], Subscript[C, 6]]

at the beggining of my code, but once again I could not obtain reliable outputs! For example, we must have $C_2C_3\neq C_3C_2$, or the code must not simplify $C_2C_3C_2$ to $C_2^2C_3$. I also used the way described by Mr.Wizard in https://mathematica.stackexchange.com/questions/17926/why-does-simplify-ignore-an-assumption?newsletter=1&nlcode=83941%7cfd18, but once again the matrix products are commutative? So, is there any way to use Simplify or FullSimplify on matrix expressions involving matrix products to have reliable output simplified expression? Any tips or help will be fully appreciated.

• I don't see anything in your code that stipulates the $C_i$ "must be considered as matrices," so I doubt Mathematica can tell, either. Except for mind readers, that makes your question just as difficult for people to interpret as it is for MMA. Perhaps, to make this question interpretable and answerable, you could state--in mathematical or at least English terms, rather than non-working code--what it is you're trying to do and what you need to accomplish. Feb 21, 2013 at 16:04
• I think in version 9, you can tell MMA that Ci are matrix by doing this: $Assumptions = Element[C1, Matrices[{n, n}]]. Feb 21, 2013 at 17:02 ## 1 Answer From xslittlegrass's comment: I think in version 9, you can tell Mathematica that $$C_i$$ are matrices by doing this: $Assumptions = Element[C1, Matrices[{n, n}]]

• So, how this works in practice. I mean can you revise my above code so as to keep the commutativity while simplifying the Taylor expansion?
– Faz
Feb 2, 2016 at 21:13