sympy/sympy — pull request #1383 by Krastanov (2012-06-23 20:33:10+00:00)
Title: Fix the way that Derivatives are produced when using abuse of notation.

Pull Request #460 introduced support for a handy abuse of notation, however it
disregarded the convention for constructing `Subs(Derivative(...))` objects
causing serious inconsistencies:

- this does not work anymore:

```
In [1]: f(g(x)).diff(x).subs(g, Lambda(x, 2*x))
Error
```

- these results are inconsistent:

```
In [6]: Derivative(f(x), x).subs(x, 2*x)
Out[6]: Subs(Derivative(f(_x), _x), (_x,), (2*x,))

In [7]: Derivative(f(x), x).subs(x, sin(x))
Out[7]: Derivative(f(sin(x)), sin(x))
```

These are fixed in the present commit.

There was also a conflicting definition of "derivation wrt function" in the
docstring that was partially removed. The main source of the inconsistency was
the confusion in calling `f(x)` a function when only `f` is a function. This
does not permit a real distinction between `f(x)` and `2*x` which was claimed
in the docstring.