On Fri, Apr 25, 2014 at 5:23 AM, Clifford Wolf <[email protected]> wrote:
> On Friday, April 25, 2014 1:16:19 AM UTC+2, Aaron Meurer wrote:
>>
>> If we override _eval_derivative on MatrixElement can we make it do the
>> right thing?
>
>
> No. Because in the case that fails, MatrixElement._eval_derivative is never
> called. That's the whole point of the existing _diff_wrt interface:
> Derivative.__new__ will try to replace the instances of the MatrixElement we
> differentiate wrt in the expression so we can differentiate wrt an ordinary
> symbol.
>
> I've now written a patch and created a pull request that adds a
> _eval_derivative_wrt interface that can be used to address that issue.
>
> https://github.com/sympy/sympy/pull/7437
>
> I preserved the current behavior of the other classes with _diff_wrt=True,
> but I think the is room for improvement there as well. For example should
> the following code really return "x"?

Yes it should. See the docstring of Derivative.

Aaron Meurer

>
> from sympy import *
> x = Symbol('x')
> f = Function('f')
> diff(x*f(x), f(x))
>
> With the new interface Function._eval_derivative_wrt could detect that even
> after substituting f(x) in x*f(x), the resulting term x*xi_1 still contains
> members of f(x).free_symbols and thus make diff() return "Derivative(x*f(x),
> f(x))" instead.
>
> Please comment on the pull request if you disagree with the approach I
> chose.
>
> --
> 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 http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/177e7ddd-655e-46bf-a64d-a2aae98d5aae%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 http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6LBs5DOvE1NmWUO0gCi_0eorTpRVSBMgnYPXAmEKeua5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to