sympy/sympy — pull request #1275 by mrocklin (2012-05-03 14:42:55+00:00)
Title: Added MatrixDerivative class for MatrixExpr

See this email discussion
https://groups.google.com/forum/?fromgroups#!topic/sympy/JEOLmDfXdK0
This issue
http://code.google.com/p/sympy/issues/detail?id=2759

As a disclaimer I don't fully understand what derivative means in this context or what exactly correct behavior entails.

Some examples

```
In [1]: X = MatrixSymbol('X', 3, 3)

In [2]: Y = MatrixSymbol('Y', 3, 3)

In [3]: (X*Y).diff(X)
Out[3]: ∂X⋅Y

In [4]: X.I.diff(X)
Out[4]: -X^-1⋅∂X⋅X^-1

In [5]: MatrixDerivative(X.T*X*Y)
Out[5]: ∂X'⋅X⋅∂Y + X'⋅∂X⋅∂Y

In [6]: MatrixDerivative(X.T.diff(X)*X*Y)
Out[6]: ∂X'⋅∂X⋅∂Y + ∂∂X'⋅X⋅∂Y
```