{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/13143","repository_url":"https://api.github.com/repos/sympy/sympy","labels_url":"https://api.github.com/repos/sympy/sympy/issues/13143/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/13143/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/13143/events","html_url":"https://github.com/sympy/sympy/issues/13143","id":251075346,"number":13143,"title":"collect giving wrong results for derivatives","user":{"login":"asmeurer","id":71486,"avatar_url":"https://avatars3.githubusercontent.com/u/71486?v=4","gravatar_id":"","url":"https://api.github.com/users/asmeurer","html_url":"https://github.com/asmeurer","followers_url":"https://api.github.com/users/asmeurer/followers","following_url":"https://api.github.com/users/asmeurer/following{/other_user}","gists_url":"https://api.github.com/users/asmeurer/gists{/gist_id}","starred_url":"https://api.github.com/users/asmeurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmeurer/subscriptions","organizations_url":"https://api.github.com/users/asmeurer/orgs","repos_url":"https://api.github.com/users/asmeurer/repos","events_url":"https://api.github.com/users/asmeurer/events{/privacy}","received_events_url":"https://api.github.com/users/asmeurer/received_events","type":"User","site_admin":false},"labels":[{"id":84627358,"url":"https://api.github.com/repos/sympy/sympy/labels/simplify","name":"simplify","color":"0000FF","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-08-17T21:18:23Z","updated_at":"2017-08-18T18:58:22Z","closed_at":null,"body":"```py\r\n>>> collect(x*diff(f(x), x, x) - 6*x + f(x).diff(x)*diff(f(x), x, x) + f(x).diff(x), f(x).diff(x, x))\r\nx*Derivative(f(x), x, x) - 6*x + (Derivative(f(x), x, x) + 1)*Derivative(f(x), x)\r\n```\r\n\r\nI asked it to collect the second derivative, but it collected the first. I believe this is because it is trying to be smart with derivatives, but it relies on the args order\r\n\r\n```py\r\n>>> (diff(f(x), x, x)*diff(f(x), x)).args\r\n(Derivative(f(x), x), Derivative(f(x), x, x))\r\n```\r\n\r\nThis is a modified example from https://github.com/sympy/sympy/pull/13059#issuecomment-323195614 (in that PR, the args order of `f(x)*diff(f(x), x)` is reversed from master. \r\n\r\nI'm unclear what exactly collect is trying to do with derivatives, but it should respect the symbols given to it and their order (the original example had `collect(x*Derivative(f(x), x) - 6*x + f(x)*Derivative(f(x), x) + f(x), [f(x).diff(x), f(x)])`). Beyond that, I'd say should prefer to collect higher order derivatives. "},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/323434826","html_url":"https://github.com/sympy/sympy/issues/13143#issuecomment-323434826","issue_url":"https://api.github.com/repos/sympy/sympy/issues/13143","id":323434826,"user":{"login":"asmeurer","id":71486,"avatar_url":"https://avatars3.githubusercontent.com/u/71486?v=4","gravatar_id":"","url":"https://api.github.com/users/asmeurer","html_url":"https://github.com/asmeurer","followers_url":"https://api.github.com/users/asmeurer/followers","following_url":"https://api.github.com/users/asmeurer/following{/other_user}","gists_url":"https://api.github.com/users/asmeurer/gists{/gist_id}","starred_url":"https://api.github.com/users/asmeurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmeurer/subscriptions","organizations_url":"https://api.github.com/users/asmeurer/orgs","repos_url":"https://api.github.com/users/asmeurer/repos","events_url":"https://api.github.com/users/asmeurer/events{/privacy}","received_events_url":"https://api.github.com/users/asmeurer/received_events","type":"User","site_admin":false},"created_at":"2017-08-18T18:58:22Z","updated_at":"2017-08-18T18:58:22Z","body":"I believe the automatic collection of derivatives was a feature that was added at some point to make collecting differential equations easier. \r\n\r\nThe problem is how collect resolves ambiguities (`x*y` when both `x` and `y` are variables to be collected). When the ambiguity is in variables, it seems to do the right thing, but when they are a function and derivative, the automatic logic somehow confuses it, causing it to ignore the ordering given by the user. "}}
{"actor":{"display_login":"asmeurer"}}