DRAFT: NOT COMPLETE

Creating Notations, Templated Structures, and Tensors

Jason Harris - Wolfram Research (jasonh@wolfram.com)

Abstract

This talk will cover creating notations in Mathematica. It will progress from creating basic notations, through to details on creating templated structures via TagBoxes, and the corresponding notations to use these structures. With these techniques a “proper” implementation of Dirac's Bra Ket Notation will be presented. Several other advanced features of the notation package such as adding input aliases and the Action option will be mentioned. These techniques will culminate in a presentation of a notation for Tensors which fully works in both input and output. Finally, a highly efficient algorithm to canonicalize tensorial expressions will be demonstrated functioning with the created tensorial notation. (By an innovative technique this algorithm circumvents the dummy index relabeling problem of tensor calculus. The complete algorithm handles linear symmetries such as the Bianchi identities as well as fully accommodating partial derivatives and mixed index classes.)

Mathematics, Physics and sciences, throughout the centuries...

• Precursors...

Mathematica

Maple

Axiom

MuPad

MathCad

CAS/PI & Others

Notations

Representations in Mathematica

Creating Advanced Notations in Mathematica

Templated Structures

Bra’s, Ket’s Notations

Simple Calculation

Tensors

Simple Calulcation

Conclusions

(∫_0^∞) (E^(-x)) \[DifferentialD]x

Real men or woman only need ASCII...

Integrals, Sums, Products,etc. e.g. (∑_(i=0)^∞)(1/(i!))

Example: ring addition, ring multiplication.

\(a\(*\_ℛ\)b\( + \_ℛ\)c\)

Consider

(∫_0^∞) (E^(-(x^2))) \[DifferentialD]x

Consider the following simple integral of ∫(x^2) dx

∫(x^2) \[DifferentialD]x

Evaluation proceeds as follows:

<< Utilities`Notation`

Consider the notation a(Subscript[⊕, c])b.

Internally represent this as gplus[a,b,c].

Consider a notation for a laplace transform.

Our example of ring plus and ring times.

We remove the notations for ring addition and ring multiplication and instead add these as infix notations.

Finally, let us add inputaliases for ring addition and multiplication.

Notation[(Underscript[(∇^2), 𝒸ℴℴ𝓇𝒹𝓈__])𝒻_ ⟺ Laplacian[𝒻_,𝒸ℴℴ𝓇𝒹𝓈__]]

(Underscript[(∇^2), x,y,z])𝒻_:=(∂_(x,x))𝒻+(∂_(y,y))𝒻+(∂_(z,z))𝒻
(Underscript[(∇^2), r,θ])𝒻_:=(∂_(r,r))𝒻+(1/r)(∂_r)𝒻+(1/(r^2))(∂_(θ,θ))𝒻

(Underscript[(∇^2), x,y,z])((x^2)(y^3)(z^4))

(Underscript[(∇^2), r,θ])((r^4)Sin[2θ])

Notations are also extremly useful for programing. E.g.

\(\(𝕏["apply", {𝕏𝔸["int"], 𝒷𝓋𝒶𝓇𝓈__?"bvar"\_TagQ, 𝒷ℴ𝒹𝓎_}]\)\_→ := "Integrate"\_↘[𝒷ℴ𝒹𝓎, 𝒷𝓋𝒶𝓇𝓈]\)

\(\(Integrate\_𝒾[𝒷ℴ𝒹𝓎_, 𝒷𝓋𝒶𝓇_]\)\_← := \ 𝕏["apply", {𝕏["int"], 𝕏["bvar", {𝒷𝓋𝒶𝓇\_←}], 𝒷ℴ𝒹𝓎\_←}]\)

\(\(SMMLToBoxes[
          XMLElement["apply", {}, {XMLElement["int", _List, {}], \((bvars__)\)?\((ElementIsAQ["bvar"])\), body_}]] := 
        createBoxesFFA["Integrate", {body, bvars}];\)\)

BoxesToSMML[inert[Integrate][body_, bvar_]] := 
        XMLElement["apply", {}, {XMLElement["int", {}, {}], 
            XMLElement["bvar", {}, {BoxesToSMML[bvar]}], 
            BoxesToSMML[body]}];

Other notations I use are things like:

\(a_\(?\^! \)StringQ\)

(Subscript[list, ℓ])ℯ𝓃

\(elem\ \( ∈ \_?\)\ list\)

\(elem\ \( ∉ \_?\)\ list\)

≡

≢

f[λ]\( &\_λ\)

Returning to our diagram

Parsing -> MakeExpression

Formatting -> MakeBoxes

Begin @ "Utilities`Notation`Private`";

Notation[x_(Subscript[⊕, z])_y_ ⟺ gplus[x_, y_, z_],Action -> PrintNotationRules]

End[];

description here.

Ket’s are denoted |ψ⟩

Bra’s are denoted ⟨ψ|

<<Notations`BraKet`

Add these here.

Notation[\[VerticalSeparator]ψ__⟩ ⟺ Ket[ψ__]]
Notation[⟨ψ__\[VerticalSeparator] ⟺ Bra[ψ__]]
Notation[⟨ψf__\[VerticalSeparator]ψi__⟩ ⟺ BraKet[{ψf__},{ψi__}]]

Notation[(OverHat[ℋ_]) ⟺ Operator[ℋ_]]

Notation[(Subscript[λ_, (OverHat[ℋ_])]) ⟺ EigenLabel[λ_,(OverHat[ℋ_])]]

Denote the angular momentum ket |\(j\_\(J\&^\), m\_\(\(J\_z\)\&^\)\)⟩

Denote the operation of NonCommutativeTimes by ‘·’

InfixNotation[·,NonCommutativeTimes];
SetAttributes[NonCommutativeTimes, {Flat, OneIdentity}];

Symbolize[(SubPlus[J])];Symbolize[(SubMinus[J])];Symbolize[(Subscript[J, z])]

\(\(J\_z\)\&^\)·\[VerticalSeparator]\(𝒿_\_\(J\&^\), 𝓂_\_\(\(J\_z\)\&^\)\)⟩:=𝓂 ℏ \[VerticalSeparator]\(𝒿\_\(J\&^\), 𝓂\_\(\(J\_z\)\&^\)\)⟩

(OverHat[(SubPlus[J])])·\[VerticalSeparator](Subscript[𝒿_, (OverHat[J])]),(Subscript[𝓂_, (OverHat[(Subscript[J, z])])])⟩:=ℏ (Sqrt[𝒿 (𝒿+1)-𝓂 (𝓂+1)]) \[VerticalSeparator](Subscript[𝒿, (OverHat[J])]),(Subscript[(𝓂+1), (OverHat[(Subscript[J, z])])])⟩

(OverHat[(SubMinus[J])])·\[VerticalSeparator](Subscript[𝒿_, (OverHat[J])]),(Subscript[𝓂_, (OverHat[(Subscript[J, z])])])⟩:=ℏ (Sqrt[𝒿 (𝒿+1)-𝓂 (𝓂-1)]) \[VerticalSeparator](Subscript[𝒿, (OverHat[J])]),(Subscript[(𝓂-1), (OverHat[(Subscript[J, z])])])⟩

(OverHat[(SubPlus[J])])· \[VerticalSeparator](Subscript[3, (OverHat[J])]),(Subscript[0, (OverHat[(Subscript[J, z])])])⟩

ℓ___·(𝒸_?ConstQ 𝒶_)·𝓇___:=𝒸 ℓ·𝒶·𝓇 
ℓ___·(𝒶_+𝒷_)·𝓇___:= ℓ·𝒶·𝓇 +ℓ·𝒷·𝓇

ConstQ[𝒶𝓇ℊ𝓈_Times]:=And @@ ConstQ /@ List @@ 𝒶𝓇ℊ𝓈
ConstQ[𝒶𝓇ℊ𝓈_Plus]:=And @@ ConstQ /@ List @@ 𝒶𝓇ℊ𝓈
ConstQ[((𝒸_)^(𝓃_))]:=ConstQ[𝒸]∧ConstQ[𝓃]
ConstQ[_?NumberQ]:=True
ConstQ[_Symbol]:=True
ConstQ[_]:=False

(OverHat[(SubPlus[J])])·(OverHat[(SubMinus[J])])·\[VerticalSeparator](Subscript[j, (OverHat[J])]),(Subscript[m, (OverHat[(Subscript[J, z])])])⟩

In angular momentum theory,  (OverHat[(J^2)]) has the eigenvalue j (j+1) (ℏ^2) .

((1/2) ((OverHat[(SubPlus[J])])·(OverHat[(SubMinus[J])])+(OverHat[(SubMinus[J])])·(OverHat[(SubPlus[J])]))+(OverHat[(Subscript[J, z])])·(OverHat[(Subscript[J, z])]))·\[VerticalSeparator](Subscript[j, (OverHat[J])]),(Subscript[m, (OverHat[(Subscript[J, z])])])⟩

Simplify @ %

⟨(Subscript[𝒿1_, (OverHat[J])]),(Subscript[𝓂1_, (OverHat[(Subscript[J, z])])])\[VerticalSeparator]·\[VerticalSeparator](Subscript[𝒿2_, (OverHat[J])]),(Subscript[𝓂2_, (OverHat[(Subscript[J, z])])])⟩:=(Subscript[δ, 𝒿1,𝒿2])(Subscript[δ, 𝓂1,𝓂2])

⟨\(k\_\(J\&^\), n\_\(\(J\_z\)\&^\)\)\[VerticalSeparator]·\(\(J\_+\)\&^\)·\(\(J\_z\)\&^\)·\((\(\(J\_-\)\&^\) + \(\(J\_+\)\&^\))\)· \[VerticalSeparator]\(3\_\(J\&^\), 0\_\(\(J\_z\)\&^\)\)⟩

InputForm[HoldForm[⟨\(k\_\(J\&^\), n\_\(\(J\_z\)\&^\)\)\[VerticalSeparator]·\(\(J\_+\)\&^\)·\(\(J\_z\)\&^\)·\((\(\(J\_-\)\&^\) + \(\(J\_+\)\&^\))\)· \[VerticalSeparator]\(3\_\(J\&^\), 0\_\(\(J\_z\)\&^\)\)⟩]]

Under small perturbations of the Hamiltonian, it is possible to calculate changes in the eigenvectors to a certain order.  Here is the new eigenvector to first order for a perturbation W which is proportional to  λ (X^4).

\[VerticalSeparator]\(\(n\^′\)\_\(H\&^\)\)⟩=\[VerticalSeparator]\(n\_\(H\&^\)\)⟩+(∑_(i ≠ n))((\[VerticalSeparator]\(i\_\(H\&^\)\)⟩·⟨\(i\_\(H\&^\)\)\[VerticalSeparator]·\(W\&^\)·\[VerticalSeparator]\(n\_\(H\&^\)\)⟩)/((Subscript[ℰ, n]) - (Subscript[ℰ, i])))//Act//Collect[#,\[VerticalSeparator]_⟩,Simplify]&

A typically tensor might look like T({{a,  ,  }, { , b, c}})

\(TagBox[
        RowBox[{"T", \ 
            GridBox[{{"a", ""}, {"", "b"}}]}], \ "Tensor"] // DisplayForm\)

<< Tensors`

Notations

Notation[\(ℓ𝒽𝓈_\( := \&~\)𝓇𝒽𝓈_\) ⟺ TensorSetDelayed[ℓ𝒽𝓈_, 𝓇𝒽𝓈_]];
InfixNotation[∖,Complement]

Tensorial Assignment

\(\((ℓ𝒽𝓈_\( := \&~\)𝓇𝒽𝓈_)\) := 
With[{𝒹𝓊𝓂𝓂𝒾ℯ𝓈 = 
            DummyIndices[𝓇𝒽𝓈]∖\ 
              DummyIndices[ℓ𝒽𝓈]}, ℓ𝒽𝓈 := 
          Module[𝒹𝓊𝓂𝓂𝒾ℯ𝓈, 𝓇𝒽𝓈]]\)

Resolution of the Christoffel symbol

Γ({{λ_,  ,  }, { , α_, β_}})  \( := \&~\)  (1/2) g({{λ, μ}, { ,  }}) (g({{ ,  ,  ,  }, {α, μ, ,, β}})+g({{ ,  ,  ,  }, {μ, β, ,, α}})-g({{ ,  ,  ,  }, {α, β, ,, μ}}))

For illustration, let us verify the first Bianchi identity

Γ({{λ_,  ,  }, { , α_, β_}})=.

R({{ ,  ,  ,  }, {γ_, σ_, μ_, ν_}})\( := \&~\)g({{ ,  }, {γ, λ}})(Γ({{λ,  ,  ,  ,  }, { , σ, μ, ,, ν}})-Γ({{λ,  ,  ,  ,  }, { , σ, ν, ,, μ}})+Γ({{α,  ,  }, { , σ, ν}})  Γ({{λ,  ,  }, { , α, μ}})-Γ({{α,  ,  }, { , σ, μ}})  Γ({{λ,  ,  }, { , α, ν}}))

ℯ𝓍𝓅𝓇 = ReIndex @ Expand [R({{ ,  ,  ,  }, {α, β, γ, δ}})+R({{ ,  ,  ,  }, {α, γ, δ, β}})+R({{ ,  ,  ,  }, {α, δ, β, γ}})]

\(DeclareSymmetries[Γ, 
      3, {\(\((2 ↔ 3)\)\_+\)}]\)
\(DeclareSymmetries[g, 
      2, {\(\((1 ↔ 2)\)\_+\)}]\)

We can simply canonicalize the above expression to show our result.

Canonicalize[ℯ𝓍𝓅𝓇]

Canonicalize[R({{a, b, c, d}, { ,  ,  ,  }})R({{i, j,  ,  }, { ,  , a, d}})R({{ ,  ,  ,  }, {i, b, c, j}})]

Canonicalize[R({{d,  ,  ,  }, { , a, c, b}}) R({{m,  , i, o}, { , j,  ,  }}) R({{ , c,  , j}, {d,  , m,  }}) R({{ ,  , b, a}, {i, o,  ,  }})+R({{c,  , j,  }, { , d,  , m}}) R({{d,  , a, b}, { , c,  ,  }}) R({{i, o, m,  }, { ,  ,  , j}}) R({{ ,  ,  ,  }, {i, o, a, b}})-R({{i,  , a,  }, { , o,  , b}}) R({{j,  , o,  }, { , m,  , i}}) R({{ , b,  , c}, {d,  , a,  }}) R({{ , m,  , d}, {j,  , c,  }})]//Timing

Other examples of higher symmetries and canonicalizations.

Reiteration: Christoffel in terms of the metric

Γ({{λ_,  ,  }, { , α_, β_}})  \( := \&~\)  (1/2) g({{λ, μ}, { ,  }}) (g({{ ,  ,  ,  }, {α, μ, ,, β}})+g({{ ,  ,  ,  }, {μ, β, ,, α}})-g({{ ,  ,  ,  }, {α, β, ,, μ}}))

In an alternative system:

withmetric = 
{Gam[i_, k_, 
            l_] :> 
Module[{m}, 
DefES[
              1/2 gc[i, 
                  m]*(PD[g[m, k], x[l]] + PD[g[m, l], x[k]] - 
                    PD[g[k, l], x[m]]), {m}, 
              ESRange -> $ESDimension]]};

Pushing the boundries of the notations which we can use and represent and compute with is a necessary, and extremly desirable goal. From typset notations like the above through to diagramatic notations, Wolfram research is pursing this goal. There is a bright future ahead.