{"action":"created","comment":{"url":"https://api.github.com/repos/sympy/sympy/pulls/comments/68585338","id":68585338,"diff_hunk":"@@ -253,6 +253,79 @@ def elm_domain(expr, intrvl):\n         return _domain\n \n \n+def periodicity(f, symbol):\n+    \"\"\"Returns the period of a given function, if possible.\n+\n+    Examples\n+    ========\n+    >>> from sympy import Symbol, sin, cos\n+    >>> from sympy.calculus.util import periodicity\n+    >>> x = Symbol('x')\n+    >>> f = sin(x) + sin(2*x) + sin(3*x)\n+    >>> periodicity(f, x)\n+    2*pi\n+    >>> periodicity(sin(x)*cos(x), x)\n+    pi\n+    \"\"\"\n+    from sympy import simplify, lcm_list\n+    from sympy.functions.elementary.trigonometric import TrigonometricFunction\n+\n+    orig_f = f\n+    f = simplify(orig_f)\n+    period = None\n+\n+    if isinstance(f, TrigonometricFunction):\n+        period = f.period(symbol)\n+\n+    if f.is_Mul:\n+        _, g = f.as_independent(symbol, as_Add=False)\n+        if isinstance(g, TrigonometricFunction):\n+            period = g.period(symbol)\n+\n+    if f.is_Add:\n+        periods = []\n+        for g in f.args:\n+            if g.is_Mul:\n+                coeff, _ = g.as_independent(symbol)\n+                if coeff.is_number and coeff < 0:\n+                    raise NotImplementedError(\"Periods of only certain \"\n+                                              \"trigonometric functions can be \"\n+                                              \"calculated using this method.\")\n+\n+            periods.append(periodicity(g, symbol))\n+\n+        period = lcm_fraction(periods)\n+\n+    if period is not None and orig_f.subs(symbol, symbol + period) == orig_f:\n+        return period\n+\n+    else:\n+        raise NotImplementedError(\"Periods of only certain trigonometric functions\"\n+                                  \" can be calculated using this method.\")\n+\n+\n+def lcm_fraction(fractions):\n+    \"\"\"Returns the LCM of a list of fractions.\n+\n+    Examples\n+    ========\n+    >>> from sympy import S, pi\n+    >>> from sympy.calculus.util import lcm_fraction\n+    >>> lcm_fraction([S(1)/2, S(3)/4, S(5)/6])\n+    15/2\n+    >>> lcm_fraction([2*pi, 3*pi, pi, pi/2])","path":"sympy/calculus/util.py","position":64,"original_position":64,"commit_id":"29fe31953f1fded0034621bf57ae28a1e94b0bf0","original_commit_id":"29fe31953f1fded0034621bf57ae28a1e94b0bf0","user":{"login":"kshitij10496","id":12427142,"avatar_url":"https://avatars.githubusercontent.com/u/12427142?v=3","gravatar_id":"","url":"https://api.github.com/users/kshitij10496","html_url":"https://github.com/kshitij10496","followers_url":"https://api.github.com/users/kshitij10496/followers","following_url":"https://api.github.com/users/kshitij10496/following{/other_user}","gists_url":"https://api.github.com/users/kshitij10496/gists{/gist_id}","starred_url":"https://api.github.com/users/kshitij10496/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kshitij10496/subscriptions","organizations_url":"https://api.github.com/users/kshitij10496/orgs","repos_url":"https://api.github.com/users/kshitij10496/repos","events_url":"https://api.github.com/users/kshitij10496/events{/privacy}","received_events_url":"https://api.github.com/users/kshitij10496/received_events","type":"User","site_admin":false},"body":"This was one of the cases where `lcm_list` fails.\r\nI would appreciate some discussion on whether to have this functionality or develop a workaround `lcm_list`\r\nso that it works for us.\r\n\r\nPing @asmeurer @jksuom @hargup @aktech ","created_at":"2016-06-27T14:26:18Z","updated_at":"2016-06-27T14:26:18Z","html_url":"https://github.com/sympy/sympy/pull/11277#discussion_r68585338","pull_request_url":"https://api.github.com/repos/sympy/sympy/pulls/11277","_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments/68585338"},"html":{"href":"https://github.com/sympy/sympy/pull/11277#discussion_r68585338"},"pull_request":{"href":"https://api.github.com/repos/sympy/sympy/pulls/11277"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/sympy/pulls/11277","id":74992428,"html_url":"https://github.com/sympy/sympy/pull/11277","diff_url":"https://github.com/sympy/sympy/pull/11277.diff","patch_url":"https://github.com/sympy/sympy/pull/11277.patch","issue_url":"https://api.github.com/repos/sympy/sympy/issues/11277","number":11277,"state":"open","locked":false,"title":"Implementing method to determine the period of some trigonometric functions","user":{"login":"kshitij10496","id":12427142,"avatar_url":"https://avatars.githubusercontent.com/u/12427142?v=3","gravatar_id":"","url":"https://api.github.com/users/kshitij10496","html_url":"https://github.com/kshitij10496","followers_url":"https://api.github.com/users/kshitij10496/followers","following_url":"https://api.github.com/users/kshitij10496/following{/other_user}","gists_url":"https://api.github.com/users/kshitij10496/gists{/gist_id}","starred_url":"https://api.github.com/users/kshitij10496/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kshitij10496/subscriptions","organizations_url":"https://api.github.com/users/kshitij10496/orgs","repos_url":"https://api.github.com/users/kshitij10496/repos","events_url":"https://api.github.com/users/kshitij10496/events{/privacy}","received_events_url":"https://api.github.com/users/kshitij10496/received_events","type":"User","site_admin":false},"body":"This PR is an attempt at computing the period of a simple trigonometric function.\r\nBy _simple_, I mean functions of the form : ` trig_func(a*x + b)`\r\n\r\nThe period for such functions is given by : `general_period / Abs(a)`,\r\nwhere `general_period` is the period of `trig_func(x)`.\r\n\r\nPing @hargup @aktech @asmeurer @Shekharrajak ","created_at":"2016-06-23T17:13:41Z","updated_at":"2016-06-27T14:26:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"63d4e3240520e4f9278fe994f3018d970a15630d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sympy/sympy/pulls/11277/commits","review_comments_url":"https://api.github.com/repos/sympy/sympy/pulls/11277/comments","review_comment_url":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/11277/comments","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/29fe31953f1fded0034621bf57ae28a1e94b0bf0","head":{"label":"kshitij10496:periodicity","ref":"periodicity","sha":"29fe31953f1fded0034621bf57ae28a1e94b0bf0","user":{"login":"kshitij10496","id":12427142,"avatar_url":"https://avatars.githubusercontent.com/u/12427142?v=3","gravatar_id":"","url":"https://api.github.com/users/kshitij10496","html_url":"https://github.com/kshitij10496","followers_url":"https://api.github.com/users/kshitij10496/followers","following_url":"https://api.github.com/users/kshitij10496/following{/other_user}","gists_url":"https://api.github.com/users/kshitij10496/gists{/gist_id}","starred_url":"https://api.github.com/users/kshitij10496/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kshitij10496/subscriptions","organizations_url":"https://api.github.com/users/kshitij10496/orgs","repos_url":"https://api.github.com/users/kshitij10496/repos","events_url":"https://api.github.com/users/kshitij10496/events{/privacy}","received_events_url":"https://api.github.com/users/kshitij10496/received_events","type":"User","site_admin":false},"repo":{"id":43112313,"name":"sympy","full_name":"kshitij10496/sympy","owner":{"login":"kshitij10496","id":12427142,"avatar_url":"https://avatars.githubusercontent.com/u/12427142?v=3","gravatar_id":"","url":"https://api.github.com/users/kshitij10496","html_url":"https://github.com/kshitij10496","followers_url":"https://api.github.com/users/kshitij10496/followers","following_url":"https://api.github.com/users/kshitij10496/following{/other_user}","gists_url":"https://api.github.com/users/kshitij10496/gists{/gist_id}","starred_url":"https://api.github.com/users/kshitij10496/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kshitij10496/subscriptions","organizations_url":"https://api.github.com/users/kshitij10496/orgs","repos_url":"https://api.github.com/users/kshitij10496/repos","events_url":"https://api.github.com/users/kshitij10496/events{/privacy}","received_events_url":"https://api.github.com/users/kshitij10496/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kshitij10496/sympy","description":"A computer algebra system written in pure Python","fork":true,"url":"https://api.github.com/repos/kshitij10496/sympy","forks_url":"https://api.github.com/repos/kshitij10496/sympy/forks","keys_url":"https://api.github.com/repos/kshitij10496/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kshitij10496/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kshitij10496/sympy/teams","hooks_url":"https://api.github.com/repos/kshitij10496/sympy/hooks","issue_events_url":"https://api.github.com/repos/kshitij10496/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/kshitij10496/sympy/events","assignees_url":"https://api.github.com/repos/kshitij10496/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/kshitij10496/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/kshitij10496/sympy/tags","blobs_url":"https://api.github.com/repos/kshitij10496/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kshitij10496/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kshitij10496/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/kshitij10496/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kshitij10496/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/kshitij10496/sympy/languages","stargazers_url":"https://api.github.com/repos/kshitij10496/sympy/stargazers","contributors_url":"https://api.github.com/repos/kshitij10496/sympy/contributors","subscribers_url":"https://api.github.com/repos/kshitij10496/sympy/subscribers","subscription_url":"https://api.github.com/repos/kshitij10496/sympy/subscription","commits_url":"https://api.github.com/repos/kshitij10496/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/kshitij10496/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/kshitij10496/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/kshitij10496/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/kshitij10496/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/kshitij10496/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kshitij10496/sympy/merges","archive_url":"https://api.github.com/repos/kshitij10496/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kshitij10496/sympy/downloads","issues_url":"https://api.github.com/repos/kshitij10496/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/kshitij10496/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/kshitij10496/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/kshitij10496/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kshitij10496/sympy/labels{/name}","releases_url":"https://api.github.com/repos/kshitij10496/sympy/releases{/id}","deployments_url":"https://api.github.com/repos/kshitij10496/sympy/deployments","created_at":"2015-09-25T05:55:24Z","updated_at":"2016-05-28T16:21:12Z","pushed_at":"2016-06-27T14:19:10Z","git_url":"git://github.com/kshitij10496/sympy.git","ssh_url":"git@github.com:kshitij10496/sympy.git","clone_url":"https://github.com/kshitij10496/sympy.git","svn_url":"https://github.com/kshitij10496/sympy","homepage":"http://sympy.org/","size":78071,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"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":1,"default_branch":"master"}},"base":{"label":"sympy:master","ref":"master","sha":"7f8d7142ef4233ed1692427203e03a4af9ee33d1","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}","deployments_url":"https://api.github.com/repos/sympy/sympy/deployments","created_at":"2010-04-30T20:37:14Z","updated_at":"2016-06-27T12:51:35Z","pushed_at":"2016-06-27T14:19:10Z","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":119517,"stargazers_count":2945,"watchers_count":2945,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1485,"mirror_url":null,"open_issues_count":2412,"forks":1485,"open_issues":2412,"watchers":2945,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/11277"},"html":{"href":"https://github.com/sympy/sympy/pull/11277"},"issue":{"href":"https://api.github.com/repos/sympy/sympy/issues/11277"},"comments":{"href":"https://api.github.com/repos/sympy/sympy/issues/11277/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/sympy/pulls/11277/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sympy/sympy/pulls/11277/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/sympy/statuses/29fe31953f1fded0034621bf57ae28a1e94b0bf0"}}}}
{"actor":{"display_login":"kshitij10496"}}