{ "cells" : [ { "cell_origin" : "client", "cell_type" : "latex", "cells" : [ { "cell_origin" : "client", "cell_type" : "latex_view", "source" : "\\section*{Implicit versus explicit indices}\n\nWhen writing expressions which involves vectors, spinors and matrices,\none often employs an implicit notation in which some or all of the\nindices are suppressed. Examples are\n$$ a = M b\\,, \\quad \\bar{\\psi}\\gamma^{m}\\chi\\,,$$\nwhere $a$ and $b$ are vectors, $\\psi$ and~$\\chi$ are spinors and~$M$\nand~$\\gamma^{m}$ are matrices. Clearly, the computer cannot know this\nwithout some further information. In Cadabra objects can carry implicit\nindices, through the \\prop{ImplicitIndex} property. There are\nderived forms of this, e.g.~\\prop{Matrix} and~\\prop{Spinor}.\nThe following example shows how implicit indices ensure that objects\ndo not get moved through each other when sorting expressions." } ], "hidden" : true, "source" : "\\section*{Implicit versus explicit indices}\n\nWhen writing expressions which involves vectors, spinors and matrices,\none often employs an implicit notation in which some or all of the\nindices are suppressed. Examples are\n$$ a = M b\\,, \\quad \\bar{\\psi}\\gamma^{m}\\chi\\,,$$\nwhere $a$ and $b$ are vectors, $\\psi$ and~$\\chi$ are spinors and~$M$\nand~$\\gamma^{m}$ are matrices. Clearly, the computer cannot know this\nwithout some further information. In Cadabra objects can carry implicit\nindices, through the \\prop{ImplicitIndex} property. There are\nderived forms of this, e.g.~\\prop{Matrix} and~\\prop{Spinor}.\nThe following example shows how implicit indices ensure that objects\ndo not get moved through each other when sorting expressions." }, { "cell_origin" : "client", "cell_type" : "input", "cells" : [ { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property ImplicitIndex to~}\\left[a,~\\discretionary{}{}{} b\\right].\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property Matrix to~}M.\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "cells" : [ { "cell_origin" : "server", "cell_type" : "input_form", "source" : "a = M b" } ], "source" : "\\begin{dmath*}{}a = M b\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "cells" : [ { "cell_origin" : "server", "cell_type" : "input_form", "source" : "a = M b" } ], "source" : "\\begin{dmath*}{}a = M b\\end{dmath*}" } ], "source" : "{a,b}::ImplicitIndex;\nM::Matrix;\nex:= a = M b;\nsort_product(_);" }, { "cell_origin" : "client", "cell_type" : "latex", "cells" : [ { "cell_origin" : "client", "cell_type" : "latex_view", "source" : "If you had not made the property assignment in the first two lines,\nthe \\algo{sort_product} would have incorrectly swapped the matrix\nand vector, leading to a meaningless expression.\n\nIf you have more than one set of implicit indices, it is best to use a \nform of \\prop{ImplicitIndex} which makes explicit which indices are suppressed.\nIn the following example, we write consider the expression $M c b$ in which $M$ is a matrix\nacting on the vector $b$, while $c$ is a different matrix which does not act on the\nsame vector space. In other words, we consider $ M^{i}{}_{j} c^{m}{}_{n} b^{j}$.\nClearly we can also write this as $M b c$, which is indeed what \\algo{sort_product} converts it to." } ], "hidden" : true, "source" : "If you had not made the property assignment in the first two lines,\nthe \\algo{sort_product} would have incorrectly swapped the matrix\nand vector, leading to a meaningless expression.\n\nIf you have more than one set of implicit indices, it is best to use a \nform of \\prop{ImplicitIndex} which makes explicit which indices are suppressed.\nIn the following example, we write consider the expression $M c b$ in which $M$ is a matrix\nacting on the vector $b$, while $c$ is a different matrix which does not act on the\nsame vector space. In other words, we consider $ M^{i}{}_{j} c^{m}{}_{n} b^{j}$.\nClearly we can also write this as $M b c$, which is indeed what \\algo{sort_product} converts it to." }, { "cell_origin" : "client", "cell_type" : "input", "cells" : [ { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property Indices(position=free) to~}\\left[i,~\\discretionary{}{}{} j\\right].\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property Indices(position=free) to~}\\left[m,~\\discretionary{}{}{} n\\right].\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property ImplicitIndex to~}M.\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property ImplicitIndex to~}b.\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property ImplicitIndex to~}c.\\end{dmath*}" } ], "source" : "{i,j}::Indices(vector);\n{m,n}::Indices(spinor);\nM::ImplicitIndex(M^{i}_{j});\nb::ImplicitIndex(b^{i});\nc::ImplicitIndex(c^{m}_{n});" }, { "cell_origin" : "client", "cell_type" : "input", "cells" : [ { "cell_origin" : "server", "cell_type" : "latex_view", "cells" : [ { "cell_origin" : "server", "cell_type" : "input_form", "source" : "M c b" } ], "source" : "\\begin{dmath*}{}M c b\\end{dmath*}" } ], "source" : "ex:= M c b;" }, { "cell_origin" : "client", "cell_type" : "input", "cells" : [ { "cell_origin" : "server", "cell_type" : "latex_view", "cells" : [ { "cell_origin" : "server", "cell_type" : "input_form", "source" : "M b c" } ], "source" : "\\begin{dmath*}{}M b c\\end{dmath*}" } ], "source" : "sort_product(_);" }, { "cell_origin" : "client", "cell_type" : "latex", "cells" : [ { "cell_origin" : "client", "cell_type" : "latex_view", "source" : "Such explicit property information is also respected by operators like \\prop{Trace}.\nThe following example shows how to remove objects from traces when they do not\ncarry any indices on which the trace acts." } ], "hidden" : true, "source" : "Such explicit property information is also respected by operators like \\prop{Trace}.\nThe following example shows how to remove objects from traces when they do not\ncarry any indices on which the trace acts." }, { "cell_origin" : "client", "cell_type" : "input", "cells" : [ { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property Trace to~}Tr\\left(\\#\\right).\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "cells" : [ { "cell_origin" : "server", "cell_type" : "input_form", "source" : "Tr(M c M)" } ], "source" : "\\begin{dmath*}{}Tr\\left(M c M\\right)\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "cells" : [ { "cell_origin" : "server", "cell_type" : "input_form", "source" : "c Tr(M M)" } ], "source" : "\\begin{dmath*}{}c Tr\\left(M M\\right)\\end{dmath*}" } ], "source" : "Tr{#}::Trace(indices=vector);\nex:= Tr( M c M );\nuntrace(_);" }, { "cell_origin" : "client", "cell_type" : "latex", "cells" : [ { "cell_origin" : "client", "cell_type" : "latex_view", "source" : "\\subsection*{Converting between implicit and explicit}\n\nIt is possible to convert from implicit indices to explicit indices, that is, make Cadabra write out all implicit indices explicitly.\nFor this to work you need to have declared an \\prop{ImplicitIndex} property which lists the explicit indices of the object.\nCadabra will then take care of creating index lines." } ], "hidden" : true, "source" : "\\subsection*{Converting between implicit and explicit}\n\nIt is possible to convert from implicit indices to explicit indices, that is, make Cadabra write out all implicit indices explicitly.\nFor this to work you need to have declared an \\prop{ImplicitIndex} property which lists the explicit indices of the object.\nCadabra will then take care of creating index lines." }, { "cell_origin" : "client", "cell_type" : "input", "cells" : [ { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property Indices(position=free) to~}\\left[i,~\\discretionary{}{}{} j,~\\discretionary{}{}{} k\\right].\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property ImplicitIndex to~}a.\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "source" : "\\begin{dmath*}{}\\text{Attached property ImplicitIndex to~}M.\\end{dmath*}" }, { "cell_origin" : "server", "cell_type" : "latex_view", "cells" : [ { "cell_origin" : "server", "cell_type" : "input_form", "source" : "M a" } ], "source" : "\\begin{dmath*}{}M a\\end{dmath*}" } ], "source" : "{i,j,k}::Indices;\na::ImplicitIndex(a^{i});\nM::ImplicitIndex(M^{i}_{j});\nex:= M a;" }, { "cell_origin" : "client", "cell_type" : "input", "cells" : [ { "cell_origin" : "server", "cell_type" : "latex_view", "cells" : [ { "cell_origin" : "server", "cell_type" : "input_form", "source" : "M^{i}_{j} a^{j}" } ], "source" : "\\begin{dmath*}{}M^{i}\\,_{j} a^{j}\\end{dmath*}" } ], "source" : "explicit_indices(ex);" }, { "cell_origin" : "client", "cell_type" : "latex", "cells" : [ { "cell_origin" : "client", "cell_type" : "latex_view", "source" : "Note how dummy indices were introduced automatically." } ], "hidden" : true, "source" : "Note how dummy indices were introduced automatically." }, { "cell_origin" : "client", "cell_type" : "input", "source" : "" } ], "description" : "Cadabra JSON notebook format", "version" : 1 }