This is documentation for Mathematica 5.2, which was
based on an earlier version of the Wolfram Language.

Creating New Notations in Mathematica

# Introduction

Mathematica 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.

This loads the Notation package and launches a palette for setting up notations.

 In[1]:=

# A Simple Example

The following declares a new notation for a function gplus.

 In[2]:=

Any input matching is now interpreted as .

 In[3]:=
 Out[3]=

Any gplus expression is now formatted in the new notation.

 In[4]:=
 Out[4]=

# Notation for the Wigner 3j Symbol

The 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 Clebsch-Gordon coefficient. This section creates a notation for 3j symbols and illustrates the use of this notation with a few simple examples.

Define the notation for the Wigner 3-j symbol.

 In[5]:=

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.

This is a typical calculation of a Wigner 3-j symbol.

 In[6]:=
 Out[6]=

The notation for 3j symbols both parses and formats correctly.

 In[7]:=
 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 input-alias for the Wigner 3j symbol to the current notebook.

Add an input alias for the Wigner 3j symbol.

 In[8]:=

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.

This defines the vectors , and .

 In[9]:=

This calculates the triple scalar product of , , and .

 In[12]:=
 Out[12]=

There are many ways to represent spherical tensors. The following is a simple, though not general approach.

This defines the spherical tensor components of , , and .

 In[13]:=

This turns off the message that the Clebsch-Gordan coefficient is unphysical.

 In[16]:=

This demonstrates an identity of the Wigner 3j symbol.

 In[17]:=
 Out[17]=

# Bras, Kets and Operators in Quantum Mechanics

The following illustrates a notational system for the Dirac bra-ket notation used in quantum mechanics.

### Modify Parenthesize and FullForm

The 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.

 In[18]:=
 In[23]:=

## Declare the notation for Operators, Bras and Kets

The following declares a notation for Operators and Eigenkets.

 In[26]:=
 In[27]:=

The 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.

This declares a notation for Kets, Bras and Brakets.

 In[28]:=

Kets will now be formatted in the notation standard in physics.

 In[31]:=
 Out[31]=
 In[32]:=
 Out[32]=

The full forms of these new objects are uniform and intuitive.

 In[33]:=
 Out[33]=

## Entering Bras and Kets

To 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.

Create input aliases for bras, kets and brakets.

 In[34]:=

Bras and kets can now be easily entered with bra and ket.

 In[37]:=
 Out[37]=

## Toy Calculations

What follows are some toy definitions and calculations to illustrate the functionality of the notation defined for Bras and Kets.

Introduce NonCommutativeTimes

 In[38]:=
 In[39]:=

Define some toy semantics.

 In[40]:=

Perform some toy calculations.

 In[43]:=
 Out[43]=
 In[44]:=
 Out[44]=
 In[45]:=
 Out[45]=
 In[46]:=
 Out[46]=
 In[47]:=
 Out[47]=
 In[48]:=
 Out[48]=
 In[49]:=
 Out[49]=

We can confirm that the following Ket represents what we desire by inspecting its full form.

 In[50]:=
 Out[50]=

## Angular Momentum

This subsection contains some simple definitions and calculations to illustrate angular momentum and raising and lowering operators in quantum mechanics.

This specifies the attributes of NonCommutativeTimes

 In[51]:=

Let us symbolize the raising and lowering operators and as well as the operator .

 In[52]:=

This defines how raising and lowering operators act on eigenstates of angular momentum.

 In[53]:=

Simple calculations can now be performed.

 In[56]:=
 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.

This specifies how NonCommutativeTimes behaves.

 In[57]:=

This defines what constants are.

 In[59]:=

Now our calculations work correctly.

 In[65]:=
 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.

 In[66]:=
 Out[66]=
 In[67]:=
 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.

Eigenstates of angular momentum are orthogonal.

 In[68]:=

We can now evaluate the decomposition of between different eigenstates of angular momentum.

 In[69]:=
 Out[69]=

Finally, for illustration let us calculate an expression involving products of operators between eigenstates.

 In[70]:=
 Out[70]=

# Category Theory Diagrams

Some 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.

This defines a notation for FunctorArrows.

 In[71]:=

This defines a notation for SquareCommutativeDiagram objects in terms of the FunctorArrows defined above.

 In[72]:=

You can confirm that the following diagram is interpreted as SquareCommutativeDiagram by changing the head so the output is not formatted.

 In[73]:=
 Out[73]=

Calculations involving diagrams can now be performed.

 In[74]:=
 Out[74]=

### A look at the rules

The following shows the MakeBoxes and MakeExpression definitions necessary to actually implement the notation for SquareCommutativeDiagrams.

 In[75]:=