{"action":"opened","number":9775,"pull_request":{"url":"https://api.github.com/repos/sympy/sympy/pulls/9775","id":41473847,"html_url":"https://github.com/sympy/sympy/pull/9775","diff_url":"https://github.com/sympy/sympy/pull/9775.diff","patch_url":"https://github.com/sympy/sympy/pull/9775.patch","issue_url":"https://api.github.com/repos/sympy/sympy/issues/9775","number":9775,"state":"open","locked":false,"title":"Fast `series` method for ring series","user":{"login":"shivamvats","id":6918975,"avatar_url":"https://avatars.githubusercontent.com/u/6918975?v=3","gravatar_id":"","url":"https://api.github.com/users/shivamvats","html_url":"https://github.com/shivamvats","followers_url":"https://api.github.com/users/shivamvats/followers","following_url":"https://api.github.com/users/shivamvats/following{/other_user}","gists_url":"https://api.github.com/users/shivamvats/gists{/gist_id}","starred_url":"https://api.github.com/users/shivamvats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shivamvats/subscriptions","organizations_url":"https://api.github.com/users/shivamvats/orgs","repos_url":"https://api.github.com/users/shivamvats/repos","events_url":"https://api.github.com/users/shivamvats/events{/privacy}","received_events_url":"https://api.github.com/users/shivamvats/received_events","type":"User","site_admin":false},"body":"This PR implements a `series_fast` method that takes an arbitrary `Basic` expression and expands it using sparse ring manipulations. We tried using `EX` domain for all expansion in #9614, but that proved to be too slow for our liking. This PR starts expanding over the `QQ` domain and keeps adding generators as and when required. Thus, we always work on the simplest (almost) possible domain, resulting in considerable speed-up.\r\n\r\nThe timings are extremely encouraging:\r\n```\r\nIn [31]: %timeit series_fast(sin(a**2) + cos(a)*sin(a),a,100)\r\n1 loops, best of 3: 303 ms per loop\r\n\r\nIn [32]: %timeit (sin(a**2) + cos(a)*sin(a)).series(a,0,100)\r\n1 loops, best of 3: 5.42 s per loop\r\n```\r\nBecause of the way we add generators, there is a constant overhead in expanding a given expression(irrespective of the asked order), depending on the complexity of the expression. So, for small orders, `series_fast` (yes, we need a new name!) might seem slow, but soon far outperforms `series` for even medium sized orders:\r\n```\r\nIn [34]: %timeit series_fast(p, a, 10)\r\n1 loops, best of 3: 764 ms per loop\r\n\r\nIn [35]: %timeit p.series(a,0,10)\r\n1 loops, best of 3: 561 ms per loop\r\n```\r\nHere `series_fast` is actually slower than `series` for 10 terms, but once we expand till the 100th order:\r\n```\r\nIn [36]: %timeit series_fast(p, a, 100)\r\n1 loops, best of 3: 917 ms per loop\r\n\r\nIn [37]: %timeit p.series(a,0,100)\r\n1 loops, best of 3: 6.67 s per loop\r\n```\r\nClearly, the performance advantage will grow larger with larger orders.\r\n\r\nThere is a lot of scope for optimising the code (my priority was to make it work). It also needs to be played with to find bugs. However, I feel this is the way to go.\r\n\r\ncc @certik @pernici @jksuom @thilinarmtb\r\n\r\n[ ] Fix wrong expansion of `sin(a**2 - a + 2)**5*cos(a**3 - a)`\r\n","created_at":"2015-08-03T14:42:47Z","updated_at":"2015-08-03T14:42:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sympy/sympy/pulls/9775/commits","review_comments_url":"https://api.github.com/repos/sympy/sympy/pulls/9775/comments","review_comment_url":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/9775/comments","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/c0708f6c3ead71d55e38e91941aebdac786401f4","head":{"label":"shivamvats:ring_series_fast","ref":"ring_series_fast","sha":"c0708f6c3ead71d55e38e91941aebdac786401f4","user":{"login":"shivamvats","id":6918975,"avatar_url":"https://avatars.githubusercontent.com/u/6918975?v=3","gravatar_id":"","url":"https://api.github.com/users/shivamvats","html_url":"https://github.com/shivamvats","followers_url":"https://api.github.com/users/shivamvats/followers","following_url":"https://api.github.com/users/shivamvats/following{/other_user}","gists_url":"https://api.github.com/users/shivamvats/gists{/gist_id}","starred_url":"https://api.github.com/users/shivamvats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shivamvats/subscriptions","organizations_url":"https://api.github.com/users/shivamvats/orgs","repos_url":"https://api.github.com/users/shivamvats/repos","events_url":"https://api.github.com/users/shivamvats/events{/privacy}","received_events_url":"https://api.github.com/users/shivamvats/received_events","type":"User","site_admin":false},"repo":{"id":25822792,"name":"sympy","full_name":"shivamvats/sympy","owner":{"login":"shivamvats","id":6918975,"avatar_url":"https://avatars.githubusercontent.com/u/6918975?v=3","gravatar_id":"","url":"https://api.github.com/users/shivamvats","html_url":"https://github.com/shivamvats","followers_url":"https://api.github.com/users/shivamvats/followers","following_url":"https://api.github.com/users/shivamvats/following{/other_user}","gists_url":"https://api.github.com/users/shivamvats/gists{/gist_id}","starred_url":"https://api.github.com/users/shivamvats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shivamvats/subscriptions","organizations_url":"https://api.github.com/users/shivamvats/orgs","repos_url":"https://api.github.com/users/shivamvats/repos","events_url":"https://api.github.com/users/shivamvats/events{/privacy}","received_events_url":"https://api.github.com/users/shivamvats/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shivamvats/sympy","description":"A computer algebra system written in pure Python","fork":true,"url":"https://api.github.com/repos/shivamvats/sympy","forks_url":"https://api.github.com/repos/shivamvats/sympy/forks","keys_url":"https://api.github.com/repos/shivamvats/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shivamvats/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shivamvats/sympy/teams","hooks_url":"https://api.github.com/repos/shivamvats/sympy/hooks","issue_events_url":"https://api.github.com/repos/shivamvats/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/shivamvats/sympy/events","assignees_url":"https://api.github.com/repos/shivamvats/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/shivamvats/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/shivamvats/sympy/tags","blobs_url":"https://api.github.com/repos/shivamvats/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shivamvats/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shivamvats/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/shivamvats/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shivamvats/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/shivamvats/sympy/languages","stargazers_url":"https://api.github.com/repos/shivamvats/sympy/stargazers","contributors_url":"https://api.github.com/repos/shivamvats/sympy/contributors","subscribers_url":"https://api.github.com/repos/shivamvats/sympy/subscribers","subscription_url":"https://api.github.com/repos/shivamvats/sympy/subscription","commits_url":"https://api.github.com/repos/shivamvats/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/shivamvats/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/shivamvats/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/shivamvats/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/shivamvats/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/shivamvats/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shivamvats/sympy/merges","archive_url":"https://api.github.com/repos/shivamvats/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shivamvats/sympy/downloads","issues_url":"https://api.github.com/repos/shivamvats/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/shivamvats/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/shivamvats/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/shivamvats/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shivamvats/sympy/labels{/name}","releases_url":"https://api.github.com/repos/shivamvats/sympy/releases{/id}","created_at":"2014-10-27T14:24:33Z","updated_at":"2014-11-07T04:25:04Z","pushed_at":"2015-08-03T14:14:41Z","git_url":"git://github.com/shivamvats/sympy.git","ssh_url":"git@github.com:shivamvats/sympy.git","clone_url":"https://github.com/shivamvats/sympy.git","svn_url":"https://github.com/shivamvats/sympy","homepage":"http://sympy.org/","size":79409,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sympy:master","ref":"master","sha":"646c6909546ba1d24c56888ceaba912b0bf7f584","user":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"repo":{"id":640534,"name":"sympy","full_name":"sympy/sympy","owner":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sympy/sympy","description":"A computer algebra system written in pure Python","fork":false,"url":"https://api.github.com/repos/sympy/sympy","forks_url":"https://api.github.com/repos/sympy/sympy/forks","keys_url":"https://api.github.com/repos/sympy/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sympy/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sympy/sympy/teams","hooks_url":"https://api.github.com/repos/sympy/sympy/hooks","issue_events_url":"https://api.github.com/repos/sympy/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/sympy/sympy/events","assignees_url":"https://api.github.com/repos/sympy/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/sympy/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/sympy/sympy/tags","blobs_url":"https://api.github.com/repos/sympy/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sympy/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sympy/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sympy/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/sympy/sympy/languages","stargazers_url":"https://api.github.com/repos/sympy/sympy/stargazers","contributors_url":"https://api.github.com/repos/sympy/sympy/contributors","subscribers_url":"https://api.github.com/repos/sympy/sympy/subscribers","subscription_url":"https://api.github.com/repos/sympy/sympy/subscription","commits_url":"https://api.github.com/repos/sympy/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sympy/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sympy/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sympy/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/sympy/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/sympy/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sympy/sympy/merges","archive_url":"https://api.github.com/repos/sympy/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sympy/sympy/downloads","issues_url":"https://api.github.com/repos/sympy/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/sympy/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/sympy/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/sympy/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sympy/sympy/labels{/name}","releases_url":"https://api.github.com/repos/sympy/sympy/releases{/id}","created_at":"2010-04-30T20:37:14Z","updated_at":"2015-08-03T13:51:55Z","pushed_at":"2015-08-03T14:42:48Z","git_url":"git://github.com/sympy/sympy.git","ssh_url":"git@github.com:sympy/sympy.git","clone_url":"https://github.com/sympy/sympy.git","svn_url":"https://github.com/sympy/sympy","homepage":"http://sympy.org/","size":152688,"stargazers_count":2259,"watchers_count":2259,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1108,"mirror_url":null,"open_issues_count":1953,"forks":1108,"open_issues":1953,"watchers":2259,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/9775"},"html":{"href":"https://github.com/sympy/sympy/pull/9775"},"issue":{"href":"https://api.github.com/repos/sympy/sympy/issues/9775"},"comments":{"href":"https://api.github.com/repos/sympy/sympy/issues/9775/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/sympy/pulls/9775/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sympy/sympy/pulls/9775/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/sympy/statuses/c0708f6c3ead71d55e38e91941aebdac786401f4"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":6,"additions":208,"deletions":14,"changed_files":3}}