{"id":10717,"date":"2021-07-14T15:51:11","date_gmt":"2021-07-14T19:51:11","guid":{"rendered":"https:\/\/spinor.info\/weblog\/?p=10717"},"modified":"2021-07-17T00:40:28","modified_gmt":"2021-07-17T04:40:28","slug":"tensor-algebra","status":"publish","type":"post","link":"https:\/\/spinor.info\/weblog\/?p=10717","title":{"rendered":"Tensor algebra"},"content":{"rendered":"<p>The other day, someone asked a question: Can the <a href=\"https:\/\/www.vttoth.com\/CMS\/projects\/61\">itensor package<\/a> in <a href=\"https:\/\/maxima.sourceforge.io\/\">Maxima<\/a> calculate the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Laplace%E2%80%93Beltrami_operator\">Laplace-Beltrami operator<\/a> applied to a scalar field in the presence of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Torsion_tensor\">torsion<\/a>?<\/p>\n<p>Well, it can. But I was very happy to get this question because it allowed me to uncover some long-standing, subtle bugs in the package that prevented some essential simplifications and in some cases, even produced nonsensical results.<\/p>\n<p>With these fixes, Maxima now produces a beautiful result, as evidenced by this nice newly created demo, which I am about to add to the package:<\/p>\n<pre style=\"margin-left: 0.5in; margin-right: 0.5in; background-color: #eee; font-size: 9pt;\"><span style=\"color: #0000ff;\">(%i1)<\/span> <strong>if get('itensor,'version) = false then load(itensor)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i2)<\/span> <span style=\"color: #008000;\">\"First, we set up the basic properties of the system\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i3)<\/span> <strong>imetric(g)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i4) <span style=\"color: #008000;\">\"Demo is faster in 3D but works for other values of dim, too\"<\/span> \r\n(%i5)<\/span> <strong>dim:3<\/strong>\r\n<span style=\"color: #0000ff;\">(%i6)<\/span> <span style=\"color: #008000;\">\"We declare symmetries of the metric and other symbols\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i7)<\/span> <strong>decsym(g,2,0,[sym(all)],[])<\/strong>\r\n<span style=\"color: #0000ff;\">(%i8)<\/span> <strong>decsym(g,0,2,[],[sym(all)])<\/strong>\r\n<span style=\"color: #0000ff;\">(%i9)<\/span> <strong>components(g([a],[b]),kdelta([a],[b]))<\/strong>\r\n<span style=\"color: #0000ff;\">(%i10)<\/span> <strong>decsym(levi_civita,0,dim,[],[anti(all)])<\/strong>\r\n<span style=\"color: #0000ff;\">(%i11)<\/span> <strong>decsym(itr,2,1,[anti(all)],[])<\/strong>\r\n<span style=\"color: #0000ff;\">(%i12)<\/span> <span style=\"color: #008000;\">\"It is useful to set icounter to avoid indexing conflicts\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i13)<\/span> <strong>icounter:100<\/strong>\r\n<span style=\"color: #0000ff;\">(%i14)<\/span> <span style=\"color: #008000;\">\"We choose the appropriate convention for exterior algebra\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i15)<\/span> <strong>igeowedge_flag:true<\/strong>\r\n<span style=\"color: #0000ff;\">(%i16)<\/span> <span style=\"color: #008000;\">\"Now let us calculate the Laplacian of a scalar field and simplify\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i17)<\/span> <strong>canform(hodge(extdiff(hodge(extdiff(f([],[]))))))<\/strong>\r\n<span style=\"color: #0000ff;\">(%i18)<\/span> <strong>contract(expand(lc2kdt(%)))<\/strong>\r\n<span style=\"color: #0000ff;\">(%i19)<\/span> <strong>ev(%,kdelta)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i20)<\/span> <strong>D1:ishow(canform(%))\r\n<span style=\"color: #ff0000;\">                  %1 %2  %3 %4                 %1 %2            %1 %2\r\n(%t20)   (- f    g      g      g     ) + f    g      + f       g\r\n             ,%4  ,%3           %1 %2     ,%2  ,%1      ,%1 %2\r\n<\/span><\/strong><span style=\"color: #0000ff;\">(%i21)<\/span> <span style=\"color: #008000;\">\"We can re-express the result using Christoffel symbols, too\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i22)<\/span> <strong>ishow(canform(conmetderiv(D1,g)))\r\n<span style=\"color: #ff0000;\">               %1 %4  %2 %5      %3                   %1 %2      %3\r\n(%t22) 2 f    g      g      ichr2      g      - f    g      ichr2\r\n          ,%5                    %1 %2  %3 %4    ,%3             %1 %2\r\n                                              %1 %3      %2               %1 %2\r\n                                      - f    g      ichr2      + f       g\r\n                                         ,%3             %1 %2    ,%1 %2\r\n<\/span><\/strong><span style=\"color: #0000ff;\">(%i23)<\/span> <span style=\"color: #008000;\">\"Nice. Now let us repeat the same calculation with torsion\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i24)<\/span> <strong>itorsion_flag:true<\/strong>\r\n<span style=\"color: #0000ff;\">(%i25)<\/span> <strong>canform(hodge(extdiff(hodge(extdiff(f([],[]))))))<\/strong>\r\n<span style=\"color: #0000ff;\">(%i26)<\/span> <span style=\"color: #008000;\">\"Additional simplifications are now needed\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i27)<\/span> <strong>contract(expand(lc2kdt(%th(2))))<\/strong>\r\n<span style=\"color: #0000ff;\">(%i28)<\/span> <strong>ev(%,kdelta)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i29)<\/span> <strong>canform(%)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i30)<\/span> <strong>ev(%,ichr2)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i31)<\/span> <strong>ev(%,ikt2)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i32)<\/span> <strong>ev(%,ikt1)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i33)<\/span> <strong>ev(%,g)\r\n<span style=\"color: #0000ff;\">(%i34)<\/span> ev(%,ichr1)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i35)<\/span> <strong>contract(rename(expand(canform(%))))<\/strong>\r\n<span style=\"color: #0000ff;\">(%i36)<\/span> <strong>flipflag:not flipflag<\/strong>\r\n<span style=\"color: #0000ff;\">(%i37)<\/span> <strong>D2:ishow(canform(%th(2)))\r\n<span style=\"color: #ff0000;\">                %1 %2  %3 %4                 %1 %2    %3            %1 %2\r\n(%t37) (- f    g      g      g     ) + f    g      itr      + f    g\r\n           ,%1         ,%2    %3 %4     ,%1           %2 %3    ,%1  ,%2\r\n                                                                          %1 %2\r\n                                                               + f       g\r\n                                                                  ,%1 %2\r\n<\/span><\/strong><span style=\"color: #0000ff;\">(%i38)<\/span> <span style=\"color: #008000;\">\"Another clean result; can also be expressed using Christoffel symbols\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i39)<\/span> <strong>ishow(canform(conmetderiv(D2,g)))\r\n<span style=\"color: #ff0000;\">               %1 %2  %3 %4      %5                   %1 %2    %3\r\n(%t39) 2 f    g      g      ichr2      g      + f    g      itr\r\n          ,%1                    %2 %3  %4 %5    ,%1           %2 %3\r\n                     %1 %2      %3            %2 %3      %1               %1 %2\r\n             - f    g      ichr2      - f    g      ichr2      + f       g\r\n                ,%1             %2 %3    ,%1             %2 %3    ,%1 %2\r\n<\/span><\/strong><span style=\"color: #0000ff;\">(%i40)<\/span> <span style=\"color: #008000;\">\"Finally, we see that the two results differ only by torsion\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i41)<\/span> <strong>ishow(canform(D2-D1))\r\n<span style=\"color: #ff0000;\">                                   %1 %2    %3\r\n(%t41)                       f    g      itr\r\n                              ,%1           %2 %3\r\n<\/span><\/strong><span style=\"color: #0000ff;\">(%i42)<\/span> <span style=\"color: #008000;\">\"Last but not least, d^2 is not nilpotent in the presence of torsion\"<\/span>\r\n<span style=\"color: #0000ff;\">(%i43)<\/span> <strong>extdiff(extdiff(f([],[])))<\/strong>\r\n<span style=\"color: #0000ff;\">(%i44)<\/span> <strong>ev(%,icc2,ikt2,ikt1)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i45)<\/span> <strong>canform(%)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i46)<\/span> <strong>ev(%,g)<\/strong>\r\n<span style=\"color: #0000ff;\">(%i47)<\/span> <strong>ishow(contract(%))\r\n<span style=\"color: #ff0000;\">                                       %3\r\n(%t47)                         f    itr\r\n                                ,%3    %275 %277\r\n<\/span><\/strong><span style=\"color: #0000ff;\">(%i48)<\/span> <span style=\"color: #008000;\">\"Reminder: when dim = 2n, the Laplacian is -1 times these results.\"<\/span>\r\n<\/pre>\n<p>The learning curve is steep and there are many pitfalls, but itensor remains an immensely powerful package.<\/p>\n<fb:like href='https:\/\/spinor.info\/weblog\/?p=10717' send='true' layout='standard' show_faces='true' width='450' height='65' action='like' colorscheme='light' font='lucida grande'><\/fb:like>","protected":false},"excerpt":{"rendered":"<p>The other day, someone asked a question: Can the itensor package in Maxima calculate the Laplace-Beltrami operator applied to a scalar field in the presence of torsion? Well, it can. But I was very happy to get this question because it allowed me to uncover some long-standing, subtle bugs in the package that prevented some <a href='https:\/\/spinor.info\/weblog\/?p=10717' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-10717","post","type-post","status-publish","format-standard","hentry","category-computer-algebra","category-49-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/10717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10717"}],"version-history":[{"count":16,"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/10717\/revisions"}],"predecessor-version":[{"id":10740,"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/10717\/revisions\/10740"}],"wp:attachment":[{"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spinor.info\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}