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
In:= Dot[xi, xj] Out= xi0 xj0 + xi1 xj1 + xi2 xj2
How do I reduce that Out back into a matrix expression? i.e.
In itself is actually simpler than
Out. 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.