Comment #44 on issue 1816 by hazelnu...@gmail.com: Adding partial derivatives and taking derivatives with respect to functions
http://code.google.com/p/sympy/issues/detail?id=1816

Aaron:

expr.subs(function, Dummy('x')).diff(Dummy('x')).subs(Dummy('x'), function)

Makes perfect sense to me and I think is very useful. In contrast to Ronan's stance in Comment 43, I *don't* want to have to explicitly substitute-transform-backsubstitute every time, and I think many people who are doing variational calculus would feel the same.

The reason is that if you consider an expression to be a function of some Function
in the expression, say F(f(x)), then F(u) means exactly the same thing as
expr.subs(f(x), u) in SymPy.

begs the question of whether a Functional class should be created. This is bound to be a huge can of worms and I don't think it should block Brian's request, but is probably worth thinking about.

I am fine with Brian's implementation as long as there is a statement in the docstring that explicitly states that we are simply substituting non-Symbol instances with dummy Symbols, differentiating wrt to those symbols, and back-substituting non-Symbol instances. From what I can tell, Brian has stated this in the docstrings for Derivative, Expr, and his comments throughout the code clearly state what he is doing.

Ronan: Am I correct in understanding that you don't find the following functionality to be something that should be automatically handled by diff():
t = Symbol('t')
xfunc = Function('x')
x = xfunc(t)
diff(2 * x + 4, x)
2

Instead, would you prefer *users* to enter:
_x = Dummy('x')
(2 * x + 4).subs(x, _x).diff(_x).subs(_x, x)

Also, you mention "I'm quite sure that it has many puzzling and mathematically inconsistent consequences." Could you give us some examples?

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to