{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/11284","repository_url":"https://api.github.com/repos/sympy/sympy","labels_url":"https://api.github.com/repos/sympy/sympy/issues/11284/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/11284/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/11284/events","html_url":"https://github.com/sympy/sympy/issues/11284","id":162209280,"number":11284,"title":"Improving integrate() for holonomic functions","user":{"login":"certik","id":20568,"avatar_url":"https://avatars.githubusercontent.com/u/20568?v=3","gravatar_id":"","url":"https://api.github.com/users/certik","html_url":"https://github.com/certik","followers_url":"https://api.github.com/users/certik/followers","following_url":"https://api.github.com/users/certik/following{/other_user}","gists_url":"https://api.github.com/users/certik/gists{/gist_id}","starred_url":"https://api.github.com/users/certik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/certik/subscriptions","organizations_url":"https://api.github.com/users/certik/orgs","repos_url":"https://api.github.com/users/certik/repos","events_url":"https://api.github.com/users/certik/events{/privacy}","received_events_url":"https://api.github.com/users/certik/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sympy/sympy/labels/Holonomic%20Functions","name":"Holonomic Functions","color":"1d76db"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-06-24T18:57:29Z","updated_at":"2016-06-25T13:21:45Z","closed_at":null,"body":"Currently it does:\r\n```\r\nIn [17]: sympy.holonomic.from_sympy(sin(x)**2/x).integrate((x, 0, 1))\r\nOut[17]: HolonomicFunction((4)Dx + (4*x)Dx**2 + (3)Dx**3 + (x)Dx**4, x)\r\n```\r\nBut should probably raise an exception, since it can't do it --- the returned answer is just a general holonomic function, which is wrong. Let's try just the indefinite integral:\r\n```\r\nIn [13]: integrate(sin(x)**2/x, x)\r\nOut[13]: \r\nlog(x)   Ci(2⋅x)\r\n────── - ───────\r\n  2         2   \r\n```\r\nusing holonomic functions:\r\n```\r\nIn [20]: sympy.holonomic.from_sympy(sin(x)**2/x).integrate(x)\r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n<ipython-input-20-7ec59a73e656> in <module>()\r\n----> 1 sympy.holonomic.from_sympy(sin(x)**2/x).integrate(x)\r\n\r\n/home/certik/repos/sympy/sympy/holonomic/holonomic.py in integrate(self, *args)\r\n    525 \r\n    526         # definite integral if limits are (x0, x)\r\n--> 527         if len(args) == 1 and len(args[0]) == 3 and args[0][1] == self.x0 and args[0][2] == self.x:\r\n    528             y0 = [S(0)]\r\n    529             y0 += self.y0\r\n\r\nTypeError: object of type 'Symbol' has no len()\r\n```\r\nException, should be fixed. Let's try another way:\r\n```\r\nIn [24]: sympy.holonomic.from_sympy(sin(x)**2/x).integrate((x, 0, x))\r\nOut[24]: HolonomicFunction((4)Dx + (4*x)Dx**2 + (3)Dx**3 + (x)Dx**4, x)\r\n```\r\nLet's confirm that this is the right answer:\r\n```\r\nIn [26]: sympy.holonomic.from_sympy(_13)\r\nOut[26]: HolonomicFunction((4)Dx + (4*x)Dx**2 + (3)Dx**3 + (x)Dx**4, x), f(1) = -Ci(2)/2, f'(1) = -cos(2)/2 + 1/2, f''(1) = -1/2 + cos(2)/2 + sin(2), f'''(1) = -2*sin(2) + cos(2) + 1\r\n```\r\nThe holonomic function is indeed the same, but the initial condition was lost in 24. Any idea how to fix this?\r\n\r\ncc @shubhamtibra."},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/228540792","html_url":"https://github.com/sympy/sympy/issues/11284#issuecomment-228540792","issue_url":"https://api.github.com/repos/sympy/sympy/issues/11284","id":228540792,"user":{"login":"shubhamtibra","id":9497860,"avatar_url":"https://avatars.githubusercontent.com/u/9497860?v=3","gravatar_id":"","url":"https://api.github.com/users/shubhamtibra","html_url":"https://github.com/shubhamtibra","followers_url":"https://api.github.com/users/shubhamtibra/followers","following_url":"https://api.github.com/users/shubhamtibra/following{/other_user}","gists_url":"https://api.github.com/users/shubhamtibra/gists{/gist_id}","starred_url":"https://api.github.com/users/shubhamtibra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shubhamtibra/subscriptions","organizations_url":"https://api.github.com/users/shubhamtibra/orgs","repos_url":"https://api.github.com/users/shubhamtibra/repos","events_url":"https://api.github.com/users/shubhamtibra/events{/privacy}","received_events_url":"https://api.github.com/users/shubhamtibra/received_events","type":"User","site_admin":false},"created_at":"2016-06-25T13:21:45Z","updated_at":"2016-06-25T13:21:45Z","body":"I have made some changes in `.integrate()` at #11297 , so that it works with arbitrary limits using numerical computation. Since `0` is a singular point here, a numerical computation from `0` to `1` isn't possible however we can integrate from `1` to `0` and see if the magnitude is same with opposite sign. An example from the PR\r\n```\r\n>>> p = from_sympy(sin(x)**2/x, x0=2).integrate((x, 1, 0))\r\n>>> q = (sin(x)**2/x).integrate((x, 0, 1)).evalf()\r\n>>> p+q\r\n-1.35060015205024e-6\r\n```"}}
{"actor":{"display_login":"shubhamtibra"}}