If this is a generalization (same meaning) as the new matrix derivative stuff, then I think it's good. I think it would be better to explicitly require a Matrix object, although lists could potentially be useful for easier input. Assumedly the output would be a Matrix (a list output would be less useful for further SymPy operations).
Also, please consider the proposed syntax at https://github.com/sympy/sympy/issues/5575 (diff(f(x), (x, n)) to mean d^n/dx^n f(x), for n symbolic) when looking at any new APIs for diff(). Aaron Meurer On Mon, Nov 27, 2017 at 10:24 AM, Francesco Bonazzi <[email protected]> wrote: > Hi, I think we could support a simple notation for array derivatives. > > For example, if would be nice if the Gradient and Hessian could be easily > calculated as: > > In [5]: f(x, y, z).diff([[x, y, z]]) > Out[5]: > ⎡∂ ∂ ∂ ⎤ > ⎢──(f(x, y, z)) ──(f(x, y, z)) ──(f(x, y, z))⎥ > ⎣∂x ∂y ∂z ⎦ > > In [6]: f(x, y, z).diff([[x, y, z], 2]) > Out[6]: > ⎡ 2 2 2 ⎤ > ⎢ ∂ ∂ ∂ ⎥ > ⎢ ───(f(x, y, z)) ─────(f(x, y, z)) ─────(f(x, y, z))⎥ > ⎢ 2 ∂y ∂x ∂z ∂x ⎥ > ⎢ ∂x ⎥ > ⎢ ⎥ > ⎢ 2 2 2 ⎥ > ⎢ ∂ ∂ ∂ ⎥ > ⎢─────(f(x, y, z)) ───(f(x, y, z)) ─────(f(x, y, z))⎥ > ⎢∂y ∂x 2 ∂z ∂y ⎥ > ⎢ ∂y ⎥ > ⎢ ⎥ > ⎢ 2 2 2 ⎥ > ⎢ ∂ ∂ ∂ ⎥ > ⎢─────(f(x, y, z)) ─────(f(x, y, z)) ───(f(x, y, z)) ⎥ > ⎢∂z ∂x ∂z ∂y 2 ⎥ > ⎣ ∂z ⎦ > > That is, if the argument being derived wrt is a nested list, interpret the > derivative as an array derivative. > > This behaviour would then be similar to Wolfram Mathematica's one: > http://reference.wolfram.com/language/ref/D.html > > Currently, it's possible to calculate the array derivative provided that the > deriving factor is an Array object. > > Anyone objecting to introducing this API addition? > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > 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/0fd53e7c-7ff1-4abc-8c5b-5ec101bca7d1%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CAKgW%3D6%2B%2BQs-qh7KJvrYuUDyX4QMcABm-zv1ojo2KhTr2WNmtpw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
