Creating New Notations in Mathematica Jason Harris IntroductionMathematica understands most standard mathematical notations such as integrals, sums, products, etc. But in many mathematical fields, particularly pure mathematics, a variety of additional specific notations are used. The programmability of input and output in Mathematica makes it possible to introduce these kinds of notations, and to integrate them into your work. The Notation package provides a variety of utilities allowing you to flexibly and extensively create and add your own notations to a Mathematica session. The full documentation for the package can be found here. Without the Notation package creating and defining your own notations can be laborious and problematic. A Simple Example
Out[3]=  
Out[4]=  
Notation for the Wigner 3j SymbolThe Wigner 3j Symbol is used in the coupling of angular momenta in quantum mechanics. The 3j symbol is a more symmetric form of a corresponding ClebschGordon coefficient. This section creates a notation for 3j symbols and illustrates the use of this notation with a few simple examples. This notation consists of a 32 GridBox with round braces subscripted by 3j. There are many other notational forms that could have been chosen including ones with hidden TagBoxes.
Out[6]=  
Out[7]=  
This notation for the Wigner 3j symbol can now be freely used in calculations, greatly increasing readability in certain cases. Furthermore, for ease of input we can add an inputalias for the Wigner 3j symbol to the current notebook. A blank template of a Wigner 3j symbol can now be created by typing 3j in any input cell. The following is a short example illustrating an identity involving the Wigner 3j symbol.
Out[12]=  
There are many ways to represent spherical tensors. The following is a simple, though not general approach.
Out[17]=  
Bras, Kets and Operators in Quantum MechanicsThe following illustrates a notational system for the Dirac braket notation used in quantum mechanics. Modify Parenthesize and FullFormThe following code is used to fix the formatting of tag boxes and full form. This correction is not central to the points being illustrated in this notebook, but is necessary for correct formatting. Declare the notation for Operators, Bras and KetsThe following notations for bras, kets, and brakets depend on specific styles that have been added to the style sheet of this notebook. These styles are necessary to give the bras, kets and brakets the correct visual and structural properties.
Out[31]=  
Out[32]=  
Out[33]=  
Entering Bras and KetsTo enter complex templates consisting of tag boxes and other underlying structures it is desirable to add input aliases to the current notebook. Creating input aliases for bras and kets is a perfect illustration of this.
Out[37]=  
Toy CalculationsWhat follows are some toy definitions and calculations to illustrate the functionality of the notation defined for Bras and Kets.
Out[43]=  
Out[44]=  
Out[45]=  
Out[46]=  
Out[47]=  
Out[48]=  
Out[49]=  
Out[50]=  
Angular MomentumThis subsection contains some simple definitions and calculations to illustrate angular momentum and raising and lowering operators in quantum mechanics.
Out[56]=  
To progress further we must add some basic properties to our NonCommutativeTimes. The following is a crude implementation of multiple linearity over addition and multiple linearity over constants, however it is sufficient for the purpose of illustration. The following rules state that constants can be factored out of a NonCommutativeTimes expression, and that NonCommutativeTimes distributes over addition.
Out[65]=  
In angular momentum theory the operator has the eigenvalue on eigenstates of angular momentum. It is usually a textbook calculation to show that the operator can be decomposed into operators involving , and . Let us verify that this is the case.
Out[66]=  
Out[67]=  
For those that know enough about quantized angular momentum it is evident that the calculation above shows that is equivalent to . Let us extend our implementation of angular momentum a little further and note that the eigenstates of angular momentum are orthogonal. We can now evaluate the decomposition of between different eigenstates of angular momentum.
Out[69]=  
Finally, for illustration let us calculate an expression involving products of operators between eigenstates.
Out[70]=  
Category Theory DiagramsSome of the most complicated notation found anywhere occurs in category theory. This section gives some simple examples of how category theory diagrams can be set up as notations in Mathematica. The following example comes from the section on natural transformations in Birkhoff and MacLane's Algebra.
Out[73]=  
Out[74]=  
A look at the rules
