{"action":"created","issue":{"url":"https://api.github.com/repos/GRIFFINCollaboration/AngularCorrelationUtility/issues/10","labels_url":"https://api.github.com/repos/GRIFFINCollaboration/AngularCorrelationUtility/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/GRIFFINCollaboration/AngularCorrelationUtility/issues/10/comments","events_url":"https://api.github.com/repos/GRIFFINCollaboration/AngularCorrelationUtility/issues/10/events","html_url":"https://github.com/GRIFFINCollaboration/AngularCorrelationUtility/issues/10","id":128693610,"number":10,"title":"Accuracy","user":{"login":"SmithJK","id":10604745,"avatar_url":"https://avatars.githubusercontent.com/u/10604745?v=3","gravatar_id":"","url":"https://api.github.com/users/SmithJK","html_url":"https://github.com/SmithJK","followers_url":"https://api.github.com/users/SmithJK/followers","following_url":"https://api.github.com/users/SmithJK/following{/other_user}","gists_url":"https://api.github.com/users/SmithJK/gists{/gist_id}","starred_url":"https://api.github.com/users/SmithJK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SmithJK/subscriptions","organizations_url":"https://api.github.com/users/SmithJK/orgs","repos_url":"https://api.github.com/users/SmithJK/repos","events_url":"https://api.github.com/users/SmithJK/events{/privacy}","received_events_url":"https://api.github.com/users/SmithJK/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-26T01:40:31Z","updated_at":"2016-01-27T01:34:11Z","closed_at":null,"body":"While investigating Issue #9, did some spot checks in comparison to the Geant code written by Evan. Found some inconsistencies that were not entirely attributable to Issue #9, where the two codes produced different a2 and a4 coefficients given identical inputs. Since the code for this page came from the Geant code, this is troubling.\r\n\r\n4->2->0 with 0 mixing (and L1a=2 and L1b=3) gives the correct result in both cases though."},"comment":{"url":"https://api.github.com/repos/GRIFFINCollaboration/AngularCorrelationUtility/issues/comments/175332702","html_url":"https://github.com/GRIFFINCollaboration/AngularCorrelationUtility/issues/10#issuecomment-175332702","issue_url":"https://api.github.com/repos/GRIFFINCollaboration/AngularCorrelationUtility/issues/10","id":175332702,"user":{"login":"SmithJK","id":10604745,"avatar_url":"https://avatars.githubusercontent.com/u/10604745?v=3","gravatar_id":"","url":"https://api.github.com/users/SmithJK","html_url":"https://github.com/SmithJK","followers_url":"https://api.github.com/users/SmithJK/followers","following_url":"https://api.github.com/users/SmithJK/following{/other_user}","gists_url":"https://api.github.com/users/SmithJK/gists{/gist_id}","starred_url":"https://api.github.com/users/SmithJK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SmithJK/subscriptions","organizations_url":"https://api.github.com/users/SmithJK/orgs","repos_url":"https://api.github.com/users/SmithJK/repos","events_url":"https://api.github.com/users/SmithJK/events{/privacy}","received_events_url":"https://api.github.com/users/SmithJK/received_events","type":"User","site_admin":false},"created_at":"2016-01-27T01:34:11Z","updated_at":"2016-01-27T01:34:11Z","body":"This difference can be attributed to the changes made to the code in the commit \"some simple optimizations\" from December 1. Specifically, the changes made to the `ClebschGordan` function in `angular_corr.js`. An empty `if` statement was changed to a set of `if` and then `else if` statements. The original code was:\r\n```\r\nfor(k = 0 ; k <= 99 ; k++ ){\r\n        if( (j1+j2-j-k < 0) || (j-j1-m2+k < 0) || (j-j2+m1+k < 0) || (j1-m1-k < 0) || (j2+m2-k < 0) ){}\r\n        else{\r\n            term = Factorial(j1+j2-j-k)*Factorial(j-j1-m2+k)*Factorial(j-j2+m1+k)*Factorial(j1-m1-k)*Factorial(j2+m2-k)*Factorial(k);\r\n            if((k%2) == 1){\r\n                term = -1*term;\r\n            }\r\n            sum = sum + 1.0/term;\r\n        }\r\n    }\r\n```\r\nNow it is:\r\n```\r\nfor(k = 0 ; k <= 99 ; k++ ){\r\n        if( (j1+j2-j-k < 0) || (j1-m1-k < 0) || (j2+m2-k < 0) )\r\n            //no further terms will contribute to sum, exit loop\r\n            break\r\n        else if( (j-j1-m2+k < 0) || (j-j2+m1+k < 0)  )\r\n            //jump ahead to next term that will contribute\r\n            k = Math.max(Math.max(j-j1-m2, j-j2+m1) - 1, k);\r\n        else{\r\n            term = Factorial(j1+j2-j-k)*Factorial(j-j1-m2+k)*Factorial(j-j2+m1+k)*Factorial(j1-m1-k)*Factorial(j2+m2-k)*Factorial(k);\r\n            if((k%2) == 1){\r\n                term = -1*term;\r\n            }\r\n            sum = sum + 1.0/term;\r\n        }\r\n```\r\nI think it's actually the jump ahead to the next term that is causing the problem; when I remove that, the comparison between Geant and the website is exact. @BillMills, I'm not certain what optimization you were going for here, so I can't tell if there's a typo."}}