Matrix and _eval_diff

43 views
Skip to first unread message

Francesco Bonazzi

unread,
Jan 2, 2016, 10:41:12 AM1/2/16
to sympy
Is there a reason why matrices don't implement _eval_diff?

Elementwise derivatives are currently handled by the diff method.

Calling matrix.diff(x) calculates derivatives elementwisely, diff(matrix, x) returns an unevaluated derivative.

In [12]: var('x y z')
Out[12]: (x, y, z)

In [13]: m = Matrix([[x, y], [x*y, x*z]])

In [14]: m.diff(x)
Out[14]:
Matrix([
[1, 0],
[y, z]])

In [15]: diff(m, x)
Out[15]:
Derivative(Matrix([
[  x,   y],
[x*y, x*z]]), x)





Aaron Meurer

unread,
Jan 2, 2016, 5:19:13 PM1/2/16
to sy...@googlegroups.com
I guess because mutable matrices aren't subclasses of Expr, they need
to implement diff. I don't think there is a specific reason _eval_diff
is missing. It probably was never implemented.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/7227d34c-ab83-4325-9ff7-10b097a7b053%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Francesco Bonazzi

unread,
Jan 29, 2016, 9:49:54 AM1/29/16
to sympy

On Saturday, 2 January 2016 23:19:13 UTC+1, Aaron Meurer wrote:
I don't think there is a specific reason _eval_diff
is missing. It probably was never implemented.
Reply all
Reply to author
Forward
0 new messages