Updates:
Status: NeedsDecision
Comment #6 on issue 1525 by asmeurer: No integration by substitution
http://code.google.com/p/sympy/issues/detail?id=1525
After the revert, we get
In [2]: f(g(x)).diff(x)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/Users/aaronmeurer/Documents/Python/sympy/sympy/<ipython console> in
<module>()
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/expr.py in
diff(self, *symbols, **assumptions)
1497 new_symbols = map(sympify, symbols) # e.g. x, 2, y, z
1498 assumptions.setdefault("evaluate", True)
-> 1499 return Derivative(self, *new_symbols, **assumptions)
1500
1501
###########################################################################
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/function.py in
__new__(cls, expr, *symbols, **assumptions)
600 unevaluated_symbols = []
601 for s in symbolgen:
--> 602 obj = expr._eval_derivative(s)
603 if obj is None:
604 unevaluated_symbols.append(s)
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/function.py in
_eval_derivative(self, s)
274 continue
275 if isinstance(self.func, FunctionClass):
--> 276 df = self.fdiff(i)
277 l.append(df * da)
278 return Add(*l)
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/function.py in
fdiff(self, argindex)
472 if not (1<=argindex<=nargs):
473 raise ArgumentIndexError(self, argindex)
--> 474 return Derivative(self,self.args[argindex-1],evaluate=False)
475
476 def _eval_as_leading_term(self, x):
/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/function.py in
__new__(cls, expr, *symbols, **assumptions)
563
564 if i == iwas: # didn't get an update because of bad
input
--> 565 raise ValueError('Derivative expects Symbol [,
Integer] args but got %s, %s' % (s, count))
566
567 symbol_count.append((s, count))
ValueError: Derivative expects Symbol [, Integer] args but got g(x), 1
And it turns out that it has been doing this for a while (or would be doing
it, were it not for the fdiff dummy commit), ever since
commit 2361dd86df3757939dfd9fcb5e39888465e2dfc3
Author: smichr <[email protected]>
Date: Thu Mar 31 21:46:31 2011 +0545
Expr has default eval_derivative action
Rather than have a default _eval_derivative method for Expr, the
logic of __new__ has been upgraded so if an Expr does not contain
a symbol of differentiation then zero is returned. This allows
even objects that don't define an _eval_derivative method to work
for such situations. (Not having this default action can make
sympy objects grow quite large after differentiation because
many unevaluated derivatives need to be processed.)
The only case that an object's _eval_derivative method should have
to worry about is the non-trivial case where all the variables of
differentiation are in the object's free_symbols.
While working on this, some problems were noticed with the
_symbolgen function: it allowed errors in input to pass silently
and also didn't properly process symbol/count input. That code
has been refactored into the __new__ function and corrected. Tests
were also added.
Before this commit it gave:
In [1]: f(g(x)).diff(x)
Out[1]:
d d
─────(f(g(x)))⋅──(g(x))
dg(x) dx
So I'm guessing the _symbolgen fix mentioned prevents it now from creating
the dubious Derivative(f(x), g(x)).
The question is, is this OK? This might break a lot of stuff. Of course,
the best fix would be to just fix issue 1620 already, but Derivative(f(x),
g(x)) has been a "workaround" for it for some time.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.