{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/symengine/issues/569","labels_url":"https://api.github.com/repos/sympy/symengine/issues/569/labels{/name}","comments_url":"https://api.github.com/repos/sympy/symengine/issues/569/comments","events_url":"https://api.github.com/repos/sympy/symengine/issues/569/events","html_url":"https://github.com/sympy/symengine/pull/569","id":97842426,"number":569,"title":"Make derivatives of abstract functions less tautological","user":{"login":"cbehan","id":13301871,"avatar_url":"https://avatars.githubusercontent.com/u/13301871?v=3","gravatar_id":"","url":"https://api.github.com/users/cbehan","html_url":"https://github.com/cbehan","followers_url":"https://api.github.com/users/cbehan/followers","following_url":"https://api.github.com/users/cbehan/following{/other_user}","gists_url":"https://api.github.com/users/cbehan/gists{/gist_id}","starred_url":"https://api.github.com/users/cbehan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbehan/subscriptions","organizations_url":"https://api.github.com/users/cbehan/orgs","repos_url":"https://api.github.com/users/cbehan/repos","events_url":"https://api.github.com/users/cbehan/events{/privacy}","received_events_url":"https://api.github.com/users/cbehan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-07-29T02:20:50Z","updated_at":"2015-08-15T22:29:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sympy/symengine/pulls/569","html_url":"https://github.com/sympy/symengine/pull/569","diff_url":"https://github.com/sympy/symengine/pull/569.diff","patch_url":"https://github.com/sympy/symengine/pull/569.patch"},"body":"Repeatedly differentiating composed function_symbol types should build up the Faa di Bruno formula (chain rule). However, the simplest implementation of Derivative::diff gives up too quickly by just adding symbols to differentiate by even when they are not directly present in the function. This modification gets the right answer when differentiating by symbols and falls back to the old method when it detects that non-symbols are present as well."},"comment":{"url":"https://api.github.com/repos/sympy/symengine/issues/comments/131456840","html_url":"https://github.com/sympy/symengine/pull/569#issuecomment-131456840","issue_url":"https://api.github.com/repos/sympy/symengine/issues/569","id":131456840,"user":{"login":"cbehan","id":13301871,"avatar_url":"https://avatars.githubusercontent.com/u/13301871?v=3","gravatar_id":"","url":"https://api.github.com/users/cbehan","html_url":"https://github.com/cbehan","followers_url":"https://api.github.com/users/cbehan/followers","following_url":"https://api.github.com/users/cbehan/following{/other_user}","gists_url":"https://api.github.com/users/cbehan/gists{/gist_id}","starred_url":"https://api.github.com/users/cbehan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbehan/subscriptions","organizations_url":"https://api.github.com/users/cbehan/orgs","repos_url":"https://api.github.com/users/cbehan/repos","events_url":"https://api.github.com/users/cbehan/events{/privacy}","received_events_url":"https://api.github.com/users/cbehan/received_events","type":"User","site_admin":false},"created_at":"2015-08-15T22:29:20Z","updated_at":"2015-08-15T22:29:20Z","body":"If the code I added called `->subs` on a `Subs`, then my substitution denesting patch would not be needed. I would just have to make my original code clever enough to modify the dict in place. However, the line I add at the end of `Derivative::diff` will differentiate many things including the `Subs` type. Over in `Subs::diff`, a line at the beginning reads `diff = arg_->diff(x)->subs(dict_);`. After the `diff` step, the result can easily have the form `Derivative(foo)*Subs(bar)`. To avoid calling `->subs` on this which leads to nesting, we would effectively have to reimplement `Mul::subs`. This is why I think the patch in pull 572 is our only reasonable way of getting the multi-variable chain rule to work."}}