I have some computation that results in a rather complicated looking expression that could be much simplified by converting it into matrix or vector expressions. For example, instead of x0 y0 + x1 y1 + x2 y2
appearing, it would be simpler to have $x^T y$.
A simple example, after declaring xi={xi0,xi1,xi2}
, etc:
In[43]:= Dot[xi, xj]
Out[43]= xi0 xj0 + xi1 xj1 + xi2 xj2
How do I reduce that Out[43] back into a matrix expression? i.e. In[43]
itself is actually simpler than Out[43]
. The final expressions I'm working with are generated by taking derivatives of matrix/vector expressions and are multiple lines long and involve both matrix and vector operations.
This is more about computational considerations than pure simplicity, I'm OK with ugly auto-generated code; I want to convert these Mathematica results into C++ code, and the vector expressions can result in a lot more efficient code through SSE instructions, more efficient matrix multiplications, etc.