{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/9664","labels_url":"https://api.github.com/repos/sympy/sympy/issues/9664/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/9664/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/9664/events","html_url":"https://github.com/sympy/sympy/issues/9664","id":94580865,"number":9664,"title":"Summing symbolic element","user":{"login":"ArrinasW","id":13285424,"avatar_url":"https://avatars.githubusercontent.com/u/13285424?v=3","gravatar_id":"","url":"https://api.github.com/users/ArrinasW","html_url":"https://github.com/ArrinasW","followers_url":"https://api.github.com/users/ArrinasW/followers","following_url":"https://api.github.com/users/ArrinasW/following{/other_user}","gists_url":"https://api.github.com/users/ArrinasW/gists{/gist_id}","starred_url":"https://api.github.com/users/ArrinasW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArrinasW/subscriptions","organizations_url":"https://api.github.com/users/ArrinasW/orgs","repos_url":"https://api.github.com/users/ArrinasW/repos","events_url":"https://api.github.com/users/ArrinasW/events{/privacy}","received_events_url":"https://api.github.com/users/ArrinasW/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-12T16:51:02Z","updated_at":"2015-07-13T01:19:13Z","closed_at":null,"body":"Greetings, everyone.\r\n     I am trying to use sympy calculate a perturbation problem, which looks like:\r\n    \r\n![per](https://cloud.githubusercontent.com/assets/13285424/8638804/01e256e4-28f9-11e5-8ab8-92f424a56b92.png)\r\n\r\n     In sympy, I think it's safe to use code like:(all elements are Matrices.)\r\n\r\n     i=Symbol(\"i\",integer=True)\r\n     summation( (u.H*Hamil*p.col(i))*(p.col(i).H*Hamil*u) , (i,0,5))   \r\n      \r\n     However, it gives the error:\r\n     IndexError: Invalid index a[i]\r\n     \r\n     It seems that SymPy doesn't support such operaion.\r\n     Does anyone knows solution to this?\r\n     Any advises would be appreciated.\r\n     Thanks."},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/120779426","html_url":"https://github.com/sympy/sympy/issues/9664#issuecomment-120779426","issue_url":"https://api.github.com/repos/sympy/sympy/issues/9664","id":120779426,"user":{"login":"ArrinasW","id":13285424,"avatar_url":"https://avatars.githubusercontent.com/u/13285424?v=3","gravatar_id":"","url":"https://api.github.com/users/ArrinasW","html_url":"https://github.com/ArrinasW","followers_url":"https://api.github.com/users/ArrinasW/followers","following_url":"https://api.github.com/users/ArrinasW/following{/other_user}","gists_url":"https://api.github.com/users/ArrinasW/gists{/gist_id}","starred_url":"https://api.github.com/users/ArrinasW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArrinasW/subscriptions","organizations_url":"https://api.github.com/users/ArrinasW/orgs","repos_url":"https://api.github.com/users/ArrinasW/repos","events_url":"https://api.github.com/users/ArrinasW/events{/privacy}","received_events_url":"https://api.github.com/users/ArrinasW/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T01:19:13Z","updated_at":"2015-07-13T01:19:13Z","body":"Yes,sure.\r\n@leosartaj, thanks for reply.\r\nu=Matrix([1,0,0,1,0,1j,0,0,0,0])/sqrt(3)\r\nHamil is a symbolic 10*6 matrix,\r\n![Uploading 选区_002.png…]()\r\n\r\np matrix is an identity matrix, which makes p.col(i) look like Matrix([1,0,0,0,0,0]).\r\nManually, I have done the sum, which gives the right result.\r\n\r\nAt first, I thought it is p.col(i) could not be used with i as an index.\r\nSo, a list P_orb is used to store p.col(i), and the code becomes:\r\n   summation( (u.H * Hamil * P_orb[i]) * (P_orb[i].H * Hamil * u) , (i,0,5))  \r\nRun it would give an error:\r\n   TypeError: list indices must be integers, not Symbol\r\nIt seems that SymPy have such \"symbol-index\" problem, I am hoping there might be a solution.\r\nThank you very much! "}}