Quantum Algebra

http://library.wolfram.com/infocenter/MathSource/4898/

César Augusto Guerra Gutiérrez
guerra_cesar@ yahoo.com

Departamento de Ciencias – Sección Física  
Potificia Universidad Católica del Perú
Av. Universitaria cdra. 18, San Miguel
Lima-32 PERU. Telf. (511) 4602870

Installation

After unzip the file QAFiles.zip you will find a directory named QuantumAlgebra that you should place in one of the following standard directories

ToFileName[ {$TopDirectory,  "AddOns",  "Applications"}]

ToFileName[ {$PreferencesDirectory,  "AddOns",  
        "Applications"}]

QuantumAlgebra directory contains three files named  QuantumAlgebra.m,  QANotations.nb and QAPalette.nb. The last two files are inside FrontEnd/Palettes directory. QANotations.nb is not really a palette but a notebook which contains notations. If you want, you can change it to other place where Mathematica can find it. Together with those files it is included the file you are reading: QuantumAlgebra.nb.  This file is a tutorial about how to use Quantum Algebra package. You can place it any where.

Loading the Package

The command to load the package must be put lonely in a single cell. Also, no more than this single cell must be selected for evaluation. The reason for this restriction is that the package QuantumAlgebra.m  evaluates the notebook QANotations.nb  containing notations, using functions that send this evaluation to the tail of all evaluations the kernel have to do. Thus, you should wait while notations are being loaded. A little window will alert you while notations are being loaded

Notations are defined using the Utilities`Notation.m  package that comes with Mathematica. The internal boxes of this notations reference some styles which are added to the notebook when the package is loaded. If there is not a notebook–based front end available the step of calling notations is avoided.

The reason why I didn't put notations inside the package QuantumAlgebra.m is that they contain large box structures or definitions made by Utilities`Notation.m. If we leave it in a notebook the box structures are hidden, and the file is easy to read and modify if desired. I should said that I changed some of the options of  the notebook QANotations.nb so that it can be editable. You can change this behavior using the Option Inspector.

Two see the symbols defined in the package just type

Names["QuantumAlgebra`QuantumAlgebra`*"]

As usual, you can request  information of any of the symbols defined in the package by typing ?command. Usefull information about notation is included for objects that use them. For instance,

?Operator

Operators

Operators can be introduced with the usual notation using aliases or by typing them with the keybord. Typing using the keyboard is described, for example in the Mathematica Book. Information about aliases for a given object can be requested with ?object. 
For example to type an operator A we type Esc op Esc and the fill in the placeholder with A, finally we type Ctrl ␣ (control–space) to leave the out of the operator. The following operators had been typed using aliases for the first two, and the keyboard the for last two

\({A\&^, B\&^\^†, C\&^, D\&^\^†}\)

There are no aliases to type superscripts and subscripts for operators, so the keyboard is the only way to introduce them. The following operators were constructed by first creating the operators using aliases, and then written the scripts with the keyboard

\({A\&^\^3, \(B\&^\)\_i\%j, \(C\&^\)\_2\%†, \(D\&^\)\_y\%\(w, †\), \((J\&^)\)\^†}\)

Note that a dagger as a superscript of an operator A represents a new operator. This new operator is  the associated hermitian operator to A.

Internally, for evaluation with the kernel, operators are treated as objects with head Operator. We can see this by requesting the full form representation

\(FullForm /@ {A\&^, A\&^\^†, 
          A\&^\_\(i, j, k\), \(A\&^\)\_\(i, j, k\)\%†, 
          A\&^\^\(m, n, p\), \((A\&^\^\(m, n, p\))\)\^†, 
\(A\&^\)\_\(i, j, k\)\%\(p, m, n\), \((\(A\&^\)\_\(i, j, k\)\%\(m, n, p\))\)\^†} // TableForm\)

As can be seen above the hermitian operation on an operator is defined as a new operator which is labeled in the full representation with an "H" string constant.

Becuse of the full form representation for an operator object, troubles can appear if we use the label of an operator for other purposes. For example if we want to set the variable a as

Mathematica will enter on an infinite loop beacause \(TraditionalForm\`a\&^\) uses a in its internal form.

Bras and Kets

Standard bras and kets from Dirac notation can be introduced only using aliases, this time we can not use the keyboard. The reason is that these objects have rather long internal boxes for properly display. These boxes are what the kernel can convert to the full form represenatation. 
You should take a look to the information supplied for the Bra, Ket, and Braket objets, to see which aliases are provided for this objects. For example a simple ket can be entered with Esc ket Esc. The following objects were introduced using only aliases

{\[VerticalSeparator]ψ⟩,⟨j\[VerticalSeparator],⟨ψ\[VerticalSeparator]ϕ⟩,(Subscript[\[VerticalSeparator]ψ⟩, x]),(Subscript[\[VerticalSeparator]ψ⟩, w]^w),(Subscript[, q])⟨τ\[VerticalSeparator],(Subscript[⟨ϕ\[VerticalSeparator]ψ⟩, t]^q)}

If for reason you want to erase one of these objects, you have to select all the object and erase it or just erase the arguments and relplace them with others. You can not, for example, erase only a left braket.

Internally, Bras, Kets and Brakets are treated by the kernel as objects with heads Bra, Ket, and Braket respectively. Look at the special forms when superscripts and subscripts are used

FullForm/@{\[VerticalSeparator]n⟩,⟨ψ\[VerticalSeparator],⟨q\[VerticalSeparator]p⟩,(Subscript[\[VerticalSeparator]η, μ, ν⟩, x]),(Subscript[, q]^p)(Subscript[⟨ψ\[VerticalSeparator]φ⟩, q]^p)}//TableForm

"Products" between quantum objects

We can represent the action of an operator on bras and kets, or any other usefull action of one of them to another one, with a non commutative operation. The package uses an already defined operator with this property: NonCommutativeMultiply. Notations that can be used for this operation are  **  or center dot: Esc . Esc

Here are some examples

{\(a\&^ ** s\&^\),\(f\&^·q\&^\),\(a\&^\)·\[VerticalSeparator]a⟩,⟨e\[VerticalSeparator]·\(t\&^\),⟨t\[VerticalSeparator]·\[VerticalSeparator]w⟩}

Note that the non commutative product between a bra and a ket represents the inner product and parse with usual notation.

QAProductExpand

Every thing that is not a bra, ket or operator object are treated as simple complex numbers. However care must be taken to form products.

Here ξ, i, ℏ are treated as simple numbers.

⟨q\[VerticalSeparator]·\((I\ ℏ\ H\&^)\)·\(f\&^\)·\((\(-ξ\)\ T\&^)\)·\[VerticalSeparator]w⟩

The non–commutative product between complex numbers and quantum objects is not defined. So in the next case i, ℏ seem to be treated as operators

⟨q\[VerticalSeparator]·I· ℏ· \(H\&^\)·\(f\&^\)·\((\(-ξ\)\ T\&^)\)·\[VerticalSeparator]w⟩

The function QAProductExpand transform products in which constants (not quantum objects) are involved

⟨q\[VerticalSeparator]·I· ℏ· \(H\&^\)·\(f\&^\)·\((\(-ξ\)\ T\&^)\)·\[VerticalSeparator]w⟩//QAProductExpand

This behaivor is not set up automatically because of speed reasons. Here is an example in which this kind of  products subtlely appears

\(\((α  a\&^ + β  b\&^)\)·\((γ 
             c\&^ + δ  d\&^ + 1)\)\)

% // QAProductExpand

The best way to go around this problem is to use the identity operator as

\(\((α  a\&^ + β  b\&^)\)·\((γ 
             c\&^ + δ  d\&^ + 1\&^)\)\)

However in some special cases there is not major problem

\({1\&^·a, a·1\&^, a\&^·0, 
      0·1, 0\&^·q, 0\&^·a\&^}\)

The cero operator can be treated as the cero number. Here are some examples with bras and kets

{⟨q\[VerticalSeparator]·\(1\&^\)·\(a\&^\),\(a\&^\)·\(0\&^\)·\[VerticalSeparator]w⟩,⟨e\[VerticalSeparator]·\((ℏ\ 1\&^)\)·\[VerticalSeparator]f⟩}

⟨q\[VerticalSeparator]·\(1\&^\)·\[VerticalSeparator]q⟩·⟨q\[VerticalSeparator]·ℏ ·\(a\&^\)·\[VerticalSeparator]w⟩

% // QAProductExpand

QAPowerExpand

As can be seen above, products of sums are expanded automatically. However, this is not true for powers. The QAPowerExpand function does the job

\(a\&^\^3 // QAPowerExpand\)

\(\(\(\((a\&^ + b\&^ + 
              c\&^)\)\^3\)\(//\)\(QAPowerExpand\)\(\ \)\)\)

\(\((a\&^\^†)\)\^5 // QAPowerExpand\)

\(\((ℏ\ ω  w\&^ + ℏ\ Ω  t\&^\^† + η  u\&^ + τ  1\&^ + 0\&^)\)\^2 // QAPowerExpand\)

Testing Linear Properties

Usual linear properties in quantum mechanics are implemented. For example, lets check it for the inner product

⟨q\[VerticalSeparator]·((α/(Sqrt[2]))\[VerticalSeparator]s⟩+(β/(Sqrt[2]))\[VerticalSeparator]p⟩)

Here we show the action of operators on superposition of  bras and kets

\(A\&^\)·((α/(Sqrt[2]))\[VerticalSeparator]r⟩+(β/(Sqrt[2]))\[VerticalSeparator]s⟩)

(λ(1/(Sqrt[2]))⟨a\[VerticalSeparator]+λ(2/(Sqrt[2]))⟨b\[VerticalSeparator] )·\(A\&^\)

Here is a product that could represent a hamiltonian matrix element

(Subscript[, x])⟨a\[VerticalSeparator]·\((\ H\&^\_1\  + \(\(\ \)\(H\)\)\&^\_2 + V\&^\_12)\)·(Subscript[\[VerticalSeparator]b⟩, x])

Setting New Definitions

To go further in a calculation we have to attach rules to operators, bras or kets using its heads. This rules, of course, depend on the problem at hand.

Suppose for example, that we want to define the action of the mometum operator on a wave function in the coordinate representation. Then we could enter something like

\(P\&^\_x\ @\((ψ[x] + φ[x])\)\)

we clean this definition with

Because a wave function is really a projection (a constant for QuantumAlgebra.m), we can not use center dot to form  products as we did before. That is the reason why I used @ to represent the "product" in the above definition. A more elaborated definition would be

(Subscript[, x])⟨x - x0\[VerticalSeparator]·\(P\&^\_x\)·(\[VerticalSeparator]ψ⟩+\[VerticalSeparator]φ⟩)

We clean or definition with

To end this section, let's define the action of creation operator on eigenstates of the harmonic oscillator hamiltonian

(1/(Sqrt[5!]))\(\((a\&^\^†)\)\^5\)·\[VerticalSeparator]0⟩//QAPowerExpand

Hermitian acting on Operators

To take the hermitian operation we have two alternative commands SuperDagger or  Hermitian. Also, the superdagger notationis available

\({Hermitian[h\&^], SuperDagger[t\&^], f\&^\^†}\)

When the hermitian operation acts on simple operators we get new operators which are  labeled with the "H" character in the full form representation

\(\(\(\ \)\(FullForm /@ {a\&^\^†, \(a\&^\)\_i\%†, 
          a\&^\^\(i, †\), \((\(a\&^\)\_i\%j)\)\^†} // 
      TableForm\)\)\)

Hermitian acting on Expressions

When the hermitian operation acts on other structures usual rules of quantum mechanics are applied. Note that the complex conjuagtion parse with the standard notation

\(\((c  b\&^·a\&^\^6)\)\^†\)

Here first we expand the power, then we perform the hermitian operation

\(Hermitian[\((\ ξ  c\&^\^† + 3  I  q\&^)\)^3 // 
        QAPowerExpand]\)

in this case we first perform the hermitian operation and then expand the power

\(Hermitian[\((\ ξ  c\&^\^† + 3  I  q\&^)\)^3] // 
      QAPowerExpand\)

the results are the same

% == %%

The hermitian operation can be applied to expressions containing several quantum objects. The rule is simple. Kets transform to bras, bras transform to kets, operators transform to the associated hermitian operators, complex numbers to its complex conjugate number and finally the order is reversed

(SuperDagger[( λ\(a\&^\)·\[VerticalSeparator]q⟩·⟨w\[VerticalSeparator]·\(h\&^\^†\) )])

Commutator

We can enter commutators using the head Commutator or using standard notation that can be enterd with the alias Esc com Esc or with the keyboard. Rules are defined to simplify commutators automatically

\(Commutator[3\ a\&^, 10  b\&^]\)

\(\(\([a\&^ + b\&^, a\&^ - b\&^]\)\_-\)\)

Common properties for commutators are defined

\({\(\([a\&^, 
            a\&^]\)\_-\), \(\([a\&^, b\&^]\)\_-\)\^†}\)

\({\(\([a\&^, f[a\&^]]\)\_-\), \(\([f[a\&^, b\&^], 
            a\&^]\)\_-\)}\)

Expand And Contract

Note that commutators are not expanded in terms of the product of operators. If needed QACommutatorExpand does this job

\(\(\(\([a\&^ + c\&^·d\&^, 3  a\&^ + b\&^]\)\_-\) // 
        QACommutatorExpand\) // Expand\)

In contrast, the command QACommutatorContract attemps to convert sum of products to a expression containing commutators. Let's try it with a simple expression

\(\(\([a\&^, b\&^]\)\_-\) // QACommutatorExpand\)

% // QACommutatorContract

Now suppose we have a more complex expression

\(expr = \(\([a\&^ + 
                w\&^, \(\([c\&^, \(\([q\&^, w\&^]\)\_-\)]\)\_-\)]\)\_-\) // 
        QACommutatorExpand\)

expr // QACommutatorContract

in this case we don't get our original expression. This is because the program chooses the operators and the order to  group them into commutators. We can change this behavior by giving to QAPowerContract a second argument. This could be a list containing two operators whose commutator should appear in the final expression, or a list of lists of pairs of operators whose commutators should appear in the final expression

\(expr // QACommutatorContract[#, {q\&^, w\&^}] &\)

\(% // QACommutatorContract[#, {c\&^, \(\([q\&^, 
                  w\&^]\)\_-\)}] &\)

\(% // QACommutatorContract[#, {a\&^, \(\([c\&^, \(\([q\&^, 
                        w\&^]\)\_-\)]\)\_-\)}] &\)

\(% // QACommutatorContract[#, {w\&^, \(\([c\&^, \(\([q\&^, 
                        w\&^]\)\_-\)]\)\_-\)}] &\)

all this transformations can be done at once

\(expr // 
      QACommutatorContract[#, {{q\&^, 
              w\&^}, {c\&^, \(\([q\&^, 
                    w\&^]\)\_-\)}, {a\&^, \(\([c\&^, \(\([q\&^, 
                          w\&^]\)\_-\)]\)\_-\)}, {w\&^, \(\([c\&^, \(\([q\&^, 
                          w\&^]\)\_-\)]\)\_-\)}}] &\)

Several operations on quantum objects (operators, bras and kets) can be performed with the QAExpandAll command which applies to its argument three commands,  QAPowerExpand, QAProductExpand and QACommutatorExpand  in this order.

\(\(\((\(\([a\&^, b\&^]\)\_-\)·b\&^ + 2·b\&^)\)\^2 // 
        QAExpandAll\) // QAPowerContract\)

As an example let's check a well known identity

\(\(\([x\&^, \(\([y\&^, z\&^]\)\_-\)]\)\_-\) + \(\([y\&^, \(\([z\&^, 
                    x\&^]\)\_-\)]\)\_-\) + \(\([z\&^, \(\([x\&^, 
                    y\&^]\)\_-\)]\)\_-\) // QACommutatorExpand\)

Defining Commutators

An important thing to remember in working with commutators is that the commutator between operators must be an operator. For example if we try to simplify the expression

\(\(\([a\&^·b\&^, 
          a\&^·b\&^·b\&^]\)\_-\)\)

using commutation rules for the operators a and b (two definitions for each pair of operators) defined as

then, not well defined products appear (remember that ξ is treated as a simple number)

\(\(\([a\&^·a\&^, 
          b\&^·b\&^·b\&^]\)\_-\)\)

% // QAProductExpand

Instead we redefine the commutators, so each one of them equals to an operator. We use the identity operator for this matter

\(\(\([a\&^·a\&^, 
          b\&^·b\&^·b\&^]\)\_-\)\)

QAOrdering

Sometimes what we want to manipulate are sums of products of operators using commutation rules so they can have a defined order, for example normal ordering in quantum field theory. In this case, the form, the commutators are defined above  are not usefull. In the following example we want all a operators to appear before b ones

\(expr = 
      b\&^·b\&^·a\&^·a\&^ + 
        b\&^·a\&^·b\&^·a\&^ + 
        a\&^·a\&^·b\&^·b\&^\)

The command QAOrdering recives two arguments. The first is the expression we want to transform. The second is a list of operators  in the order we want they appear in the transformed expression.

\(QAOrdering[expr, {a\&^, b\&^}] // Expand\)

note that the commutator between a and b had been used internally. In the next example we want the expression to be in normal order, it means creation operators before annihilation operators

\(expr = 
      a\&^\_1·
          a\&^\_2·\(a\&^\)\_1\%†·\(a\&^\)\_2\%† + \(a\&^\)\_1\%†·
          a\&^\_1·\(a\&^\)\_2\%†·a\&^\_2 + 
        a\&^\_2·\(a\&^\)\_1\%†·
          a\&^\_1·\(a\&^\)\_2\%†\)

so we simple enter

\(QAOrdering[
      expr, {\(a\&^\)\_1\%†, \(a\&^\)\_2\%†, a\&^\_1, 
        a\&^\_2}]\)

Almost all products in the last expression are normal order products excepting terms like

\(a\&^\_1·\(\([a\&^\_2, \(a\&^\)\_1\%†]\)\_-\)·\(a\&^\)\_2\%†\)

wich can't be ordered because the commutator is not known, and not rules were defined for these products. Let's define the commutators and check it again

\(QAOrdering[
      expr, {\(a\&^\)\_1\%†, \(a\&^\)\_2\%†, a\&^\_1, 
        a\&^\_2}]\)

Exp Operator

Exponential operators are implemented with the defined  Exp function. No special internal form is defined

\(Exp[T\&^]\)

However this is treated as a operator. In general every expression that contains operators is considered to be an operator. All commands defined above apply to them

\(\(\([\(-U\&^\), Exp[T\&^]\^†]\)\_-\) // 
      QACommutatorExpand\)

% // QACommutatorContract

BCHRelation

A well known formula to expand an exponential of a sum of operators in terms of products of exponential is the  Baker–Campbell–Hausdorff relation:

\(TraditionalForm\`\(\(If\ \ \ \ \ [
            A\&^, \(\([A\&^, 
                  B\&^]\)\_-\)]\)\_-\) = \ \(\(\([B\&^, \(\([A\&^, 
                    B\&^]\)\_-\)]\)\_-\) = 
        0\ \ \ \ \ then\)\)

\(TraditionalForm\`e\^\(A\&^\  + \ B\&^\) = \(e\^A\&^\) \(e\^B\&^\) e\^\(-\(\(\(1\/2\)[A\&^, B\&^]\)\_-\)\)\)

This relation is implemented with the command BCHRelation

\(Exp[α  a\&^\^† - \(α\^*\) a\&^] // 
      BCHRelation\)

As we see, if the commutator is not defined BCHRelation don't know how to check the neccesary conditions to expand the expression, so let's define the commutators

\(Exp[α  a\&^\^† - \(α\^*\) a\&^] // 
      BCHRelation\)

The condition apply and we get the expanded product of exponentials. Note the the order in which the arguments enter to the algorithm is important to get what we want.

\(Exp[\(-\(α\^*\)\) a\&^ + α  a\&^\^†] // 
      BCHRelation\)

First Form

Series power expansion of a function that depends only on one operator, around a certain multiple of the identity operator or cero point, up to any desired term can be entered as follows

\(QASeries[f[a\&^], {a\&^, 0\&^, 4}]\)

we should note that by default evaluation of factorials is holded

% // ReleaseHold

QASeries doesn't return a series object, but a polynomial expression on the operator variable. A very common expansion is that for exponential operator

\(QASeries[Exp[α  a\&^], {a\&^, 0, 4}]\)

We can find the expansion around a value diferent of cero point using the identity operator

\(QASeries[Sin[a\&^ + ϕ  1\&^], {a\&^, s  1\&^, 3}]\)

% // ReleaseHold // QAPowerExpand // Expand // 
      QAPowerContract

Second Form

QASeries can expand an expression like \(TraditionalForm\`\(e\^A\&^\) \(B\&^\) e\^\(-A\&^\)\) using the following identity

\(TraditionalForm\`\(\(If\ \ \ [A\&^, B\&^]\)\_-\) ≠ 
      0\ \ then\)

\(TraditionalForm\`\(e\^A\&^\) \(B\&^\) e\^\(-A\&^\) = \(\(B\&^\)\(+\)\(\([A\&^, 
              B\&^]\)\_-\)\(+\)\(\(\(1\/\(2!\)\)[
              A\&^, \(\([A\&^, 
                    B\&^]\)\_-\)]\)\_-\)\(+\)\(…\)\(\ \ \ \ \ \ \ \ \ \ \)\)\)

In this case a special sintax is used, for instance in the example the number 5 above represents the number of terms to be included in the expansion

\(QASeries[\ Exp[T\&^]·U\&^·Exp[\(-T\&^\)]\ , 
      5]\)

As before evaluation of factorials is holded.

% // ReleaseHold

Holding factorials is a good visual form to check the resulting series expansion as shown in the next example

\(\(Exp[T\&^]·U\&^·Exp[\(-T\&^\)] // 
        QASeries[#, 10] &\) // 
      Collect[#, {a\&^, \(-E\^\(I\ ξ\)\) 
              a\&^\^†}] &\)

We have shown that

\(TraditionalForm\`\(exp(
          T\&^)\) \(U\&^\) \(exp(\(-T\&^\))\) = \(cosh(ρ)\)\ \ a\&^ - i\ e\^\(\(\ \)\(i\ ξ\)\)\ \(sinh(ρ)\)\ a\&^\^†\)

QASet and QAClear

QASet is designed to make several definitions with quantum objects at the same time. We will see the variety of definitions that this command can set up in the following examples. One thing to remember about this command is that it can't handle definitions with restrictions, or with complex patterns, such as, use of opcional patterns.  If the definition you want to state is complicated, you should do it by your means, attaching rules to quantum objects. The syntax is easy: write a definition using Set or SetDelayed and then wrapper it with QASet.

QAClear clears definitions made by  QASet. To use it unset the definition as you would do anyone and then wrapper it with QAClear.

Definition type 1

Let's define the commutator of two operators as

and test some commutators in which these operators appear

\({\(\([u\&^, v\&^]\)\_-\), \(\([v\&^, u\&^]\)\_-\), \(\([u\&^, 
            v\&^\^2]\)\_-\), \(\([v\&^, Exp[u\&^]]\)\_-\)}\)

We see that the last term can't be evaluated. This is because the defined commutator between the two operators is very general. For instance, nothing can be said about the commutator between the operators and their commutator. Let's clear all definitions

Let's see what happens if we try with a more specific commutator

Then more rules can be defined because in this case the operators involved commutes with their commutator

\({\(\([u\&^, v\&^]\)\_-\), \(\([u\&^, v\&^\^3]\)\_-\), \(\([v\&^, 
            u\&^\^2]\)\_-\), \(\([u\&^, 
            Exp[ω  v\&^\^3]]\)\_-\)}\)

Suppose we have a more complex definition in which patterns are involved

\({\(\([X\&^\_2, P\&^\_2]\)\_-\), \(\([P\&^\_1, 
            X\&^\_3]\)\_-\), \(\([\(P\&^\)\_1\%3, \(X\&^\)\_1\%2]\)\_-\), \(\([X\&^\_1, Exp[Ω  P\&^\_2]]\)\_-\)}\)

we see that even if we use a commutator, which commutes with both operators, extra definitions are not setup. In those cases you should define them by your own. For example

\({\(\([X\&^\_2, \(P\&^\)\_3\%2]\)\_-\), \(\([X\&^\_2, \(P\&^\)\_2\%5]\)\_-\), \(\([X\&^\_2, \(P\&^\)\_2\%2]\)\_-\)}\)

we clear all definitions with

Definition type 2

We give here other definitions that QASet can handle in which commutators appear. Again this eorks well if not complex patterns are given.

In the following example the commutator between an operator and a commutator is defined

then all equivalent forms changing the order of the operators are defined

\({\(\([P\&^, \(\([Q\&^, R\&^]\)\_-\)]\)\_-\), \(\([\(\([Q\&^, 
                  R\&^]\)\_-\), P\&^]\)\_-\)}\)

We can define the commutator of two commutators as

again, all equivalent forms changing the order of the operators are defined, for example

\(\(\([\(\([x\&^\_4, x\&^\_3]\)\_-\), \(\([x\&^\_2, 
                x\&^\_1]\)\_-\)]\)\_-\)\)

The following expression is the expanded form of the commutator two input lines above, this expression don't simplify as we would like

\(x\&^\_1·x\&^\_2·x\&^\_3·x\&^\_4 - 
      x\&^\_1·x\&^\_2·x\&^\_4·x\&^\_3 - 
      x\&^\_2·x\&^\_1·x\&^\_3·x\&^\_4 + 
      x\&^\_2·x\&^\_1·x\&^\_4·x\&^\_3 - 
      x\&^\_3·x\&^\_4·x\&^\_1·x\&^\_2 + 
      x\&^\_3·x\&^\_4·x\&^\_2·x\&^\_1 + 
      x\&^\_4·x\&^\_3·x\&^\_1·x\&^\_2 - 
      x\&^\_4·x\&^\_3·x\&^\_2·
        x\&^\_1\)

we can manipulate the expression to find the answer

\(% // QACommutatorContract[#, {{x\&^\_1, x\&^\_2}, {x\&^\_3, 
              x\&^\_4}}] &\)

% // QACommutatorContract

We clear all definitions with

Definition type 3

If we have two operators that commute between them several definitions are setup at once

\({\(\([m\&^, n\&^]\)\_-\), \(\([n\&^, m\&^\^3]\)\_-\), \(\([Exp[m\&^], 
            Exp[n\&^]]\)\_-\)}\)

Definition type 4

We can enter a definition  in which two operators commutes with their commutator.

so the following commutators can be computed

\({\ \(\([K\&^, J\&^\^2]\)\_-\), \(\([J\&^, 
            Exp[ω\ K\&^\^4]]\)\_-\)\ , \(\([K\&^\^3, 
            J\&^\^3]\)\_-\)}\)

Let's show that the answer for the last term was the correct one. First,  we clear all definitions

Let's suppose that the commutator of \(TraditionalForm\`J\&^\) and \(TraditionalForm\`K\&^\) is \(TraditionalForm\`L\&^\). We can define it giving two definitions as

and the we suppose that \(TraditionalForm\`J\&^\) and \(TraditionalForm\`K\&^\) commute with their commutator.

the trick resides on the order the operators are given in the answer

\(\(\(\(\(\([K\&^\^3, J\&^\^3]\)\_-\) // QAPowerExpand\) // 
          QAOrdering[#, {L\&^, J\&^, K\&^}] &\) // Expand\) // 
      QAPowerContract\)

Comparing this result with the given above we see that they coincide. Indeed the formula used by QASet to handle this kind of commutators was infered testing several cases using QAOrdering. Before including in the package  this formula was proved by induction.

Definition type 5

With QASet it is posible to define the action of an operator on a ket and some consequences. For example the bra aaociated equation automatically holds. In the following example we define an eigenvalue expression for the operator \(TraditionalForm\`\(\(Q\&^\)\(.\)\)\)

{ \(Q\&^\)·(Subscript[\[VerticalSeparator]ϵ, ξ⟩, Q]),(Subscript[, Q])⟨q, p\[VerticalSeparator]·\(Q\&^\^†\),\(Q\&^\^2\)·(Subscript[\[VerticalSeparator]q, p⟩, Q]),(Subscript[, Q])⟨ν, μ\[VerticalSeparator]·\(E\^\(Ω 
                 Q\&^\^†\)\)}

we clear definitions as before

Note that QASet could set up all these definitions because the equation we gave to it was an eigenvalue equation. We also mention that the operator in the argument of QASet can't be a pattern.

The harmonic oscillator in quantum mechanics

The Hamiltonian for a particle of mass m placed in an harmonic potential in terms of position and momentum operators is given by

for these operators we implement the commutation relation according to

The problem of finding the eigenvalues for such hamiltonian is nicely solved by introducing creation and annihilation operators, which are related to the position and mometum operators according to the folowing rule

the inverse relation is

\(rule2 = \(Solve[{a\&^\^† == \((\(\@\(\(m\ ω\)\/\(2  ℏ\)\)\) X\&^ - \(I\/\@\(2  m\ ℏ\ ω\)\) 
                      P\&^)\), 
              a\&^ == \((\(\@\(\(m\ ω\)\/\(2  ℏ\)\)\) 
                      X\&^ + \(I\/\@\(2  m\ ℏ\ ω\)\) 
                      P\&^)\)}, {X\&^, P\&^}]\)[\([1]\)] // 
        Simplify\)

From the commutation relation for momentum and position operators the commuttion relation for these new operators can be found

\(\(\([a\&^, a\&^\^†]\)\_-\) /. rule1 // PowerExpand\)

We implement this commutator as a definition

The replacing hamiltonian reduces to

\(\(\(H\&^ /. rule2 // QAPowerExpand\) // Factor\) // 
      QAOrdering[#, {a\&^\^†, a\&^}] &\)

So the problem of finding eigenstates of the HO reduces to find the eigenstates of the number operator defined as

This problem can be solved and what one obtains is a set of infinite eigenstates labeled as   |n⟩ with eigenvalue n, where the allowed values fo n are n = 0, 1, 2  …This solutions for a basis in the hilbert space

The action of  \(TraditionalForm\`a\&^, a\&^\^†\)on these eigenstates can be found, and we introduce them as defintions to work with

Definition of coherent states

Coherent states are well known as quasi-classical states for the harmonic oscillator. This state  can be expressed as a linear superposition of the infinite fock states which are eigenstates of the harmonic oscillator hamiltonian.

Formally a coherent state is an eigenstate of the annihilation operator. We can introduce it as a definition to work with.

Note that the eigenkets of the annihilation operator have a subscript label "α", so they are not confused with the engeinkets of the number operator.

Expanding the coherent state in the fock basis and applying the annihilation operator we have (sum over n is implied on the r.h.s of equation)

\(a\&^\)·(Subscript[\[VerticalSeparator]α⟩, α])==\(a\&^\)·(c[n]\[VerticalSeparator]n⟩)

where the sum on the hand r.h.s of equation runs from 1to ∞. Replacing the expansion for the coherent state on the l.h.s shifted by one so it too runs from 1 to ∞ we have

α (Subscript[\[VerticalSeparator]α⟩, α])==(Sqrt[n]) c[n] \[VerticalSeparator]-1 + n⟩/.(Subscript[\[VerticalSeparator]α⟩, α])->c[n - 1]\[VerticalSeparator]n - 1⟩

the solution of the last equation gives the following expression (sum over n implied)

and the correspondent bra

normalization of the coherent state assuming that c0 is real gives a simple equation to solve (sum over n on the r.h.s)

(Subscript[, α])⟨α\[VerticalSeparator]·(Subscript[\[VerticalSeparator]α⟩, α])==1

This sum is, of course the exponential

\(∑\+\(n = 0\)\%∞\( c0\ α\^n\ \(c0\^*\)\ \((\(α\^*\))\)\^n\)\/\(n!\) == 1\)

So we got our final expression for a coherent state

(Subscript[|α⟩,  α])=\(e\^\(-\(\(|\)\(\ \)\(α\)\(\ \)\( | \^2\)\(\(/\)\(\ \)\(2\)\)\)\)\)(∑_(n = 0)^∞)((α^n)/(Sqrt[n!]))|n⟩

Coherent states: minimun uncertainty states

Before going on, we clear the definition of the coherent state in terms of fock states. We also enter the normalization of coherent states to work automatically

The expectation values of the position operator and its square when the system is in a coherent state can be calulated as

⟨X⟩_α=(Subscript[, α])⟨α\[VerticalSeparator]·\(X\&^\)·(Subscript[\[VerticalSeparator]α⟩, α])/.rule2//PowerExpand//FullSimplify

⟨(X^2)⟩_α=(Subscript[, α])⟨α\[VerticalSeparator]·\(X\&^\^2\)·(Subscript[\[VerticalSeparator]α⟩, α])/.rule2//QAPowerExpand//
					\(QAOrdering[#, {a\&^\^†, a\&^}] &\)//FullSimplify

the uncertainty in the position is given by

\(Δx = \(\@\(⟨X\^2⟩\_α - ⟨X⟩\_α\^2\) // 
          FullSimplify\) // PowerExpand\)

Similarly the expectation values of the momentum operator and its square when the system is in a coherent state can be calulated as

⟨P⟩_α=(Subscript[, α])⟨α\[VerticalSeparator]·\(P\&^\)·(Subscript[\[VerticalSeparator]α⟩, α])/.rule2//Factor//
					PowerExpand//FullSimplify

⟨(P^2)⟩_α=(Subscript[, α])⟨α\[VerticalSeparator]·\(P\&^\^2\)·(Subscript[\[VerticalSeparator]α⟩, α])/.rule2//QAPowerExpand//
					\(QAOrdering[#, {a\&^\^†, a\&^}] &\)//FullSimplify

and the uncertainty in the momentum give us

\(Δp = \(\@\(⟨P\^2⟩\_α - ⟨P⟩\_α\^2\) // 
          FullSimplify\) // PowerExpand\)

with those results the product of the uncertainties gives the minimun value

Δx Δp

The displacement operator

We define the displacement operators as

let's apply this operator to the vacuum fock state

𝒟[α]·\[VerticalSeparator]0⟩//BCHRelation

expanding in series both exponential (note that we need to expand the powers because we have not defined rules for the action of powers of \(TraditionalForm\`a\&^, a\&^\^†\)on fock states, thus we have to apply one operator each time to the vacuum)

thus we have

\(E\^\(-\(\(α\ \(α\^*\)\)\/2\)\)\) exp2·exp1·\[VerticalSeparator]0⟩//ReleaseHold

this is not other thing, but the definition of the coherent state in terms of fock states. So we state that the displacement operator applied on vacuum generates a coherent state

(Subscript[|α⟩,  α])=𝒟(α)| 0⟩=\(e\^\(-\(\(|\)\(\ \)\(α\)\(\ \)\( | \^2\)\(\(/\)\(\ \)\(2\)\)\)\)\)(∑_(n = 0)^∞)((α^n)/(Sqrt[n!]))|n⟩

One over property of the displacement operator can be derived using the expansion formula for expressions like \(TraditionalForm\`\(e\^A\&^\) \(B\&^\) e\^\(-A\&^\)\) as explained in part 7

\(QASeries[\ 𝒟[α]\^†·
          a\&^·𝒟[α], 10] // 
      ReleaseHold\)

\(QASeries[\ 𝒟[α]\^†·
          a\&^\^†·𝒟[α], 10] // 
      ReleaseHold\)

Evolution of initial coherent state

As we said above the fock states are eigenkets of the number operator. We want to set up this fact as a definition to work with.

with this definition the hamiltonian operator is given by

\(TraditionalForm\`H\&^ = ℏ\ ω\ \((𝒩\&^ + 
            1\/2)\)\)

droping the cero point energy (taking it as a reference) the hamiltonian reads

\(TraditionalForm\`H\&^ = ℏ\ ω  𝒩\&^\)

so the evolution operator is given by

If the state of the system at initial time is a coherent state the at time t we have (sum over n is implied in the definition of the coherent state)

\[VerticalSeparator]ψ, t⟩=𝒰[t]·((E^(-Abs[α]^2/
                  2))((α^n)/(Sqrt[n!]))\[VerticalSeparator]n⟩)

It's easy to see from these result that a time t the state will also be coherent

|ψ, t⟩ =  (Subscript[|\(α\ e\^\(\(-i\)\ ω\ t\)\)⟩,  α])

Wave packet associated with a coherent state

For the following calculation we will need the action of the exponential operators of \(TraditionalForm\`P\&^\) and \(TraditionalForm\`X\&^\) on position bras

Suppose that the wave function for the ground state of the harmonic oscillator is given by

to obtain the wave packet for the coherent state we can apply the displacement operator to the vacuum to generate the coherent state and then project into the x–representation

ψ[x]=(Subscript[, x])⟨x\[VerticalSeparator]·𝒟[α]·\[VerticalSeparator]0⟩

replacing raising and lowering operators by position and momentum operators we get

\(\(ψ[x] /. rule1\) /. 
      Exp[x_] :> Exp[Collect[x, {X\&^, P\&^}]]\)

and changing manually the order of the two expressions on the exponential operator and applying the Baker–Campbell–Hausdorff relation

ψ[x]=(Subscript[, x])⟨x\[VerticalSeparator]·\(E\^\(\((\(-\(\(I\ α\)\/\(\@2\ \@\(m\ ω\ ℏ\)\)\)\) - \(I\ \(α\^*\)\)\/\(\@2\ \@\(m\ ω\ ℏ\)\))\)\ P\&^ + \((\(α\ \@\(\(m\ ω\)\/ℏ\)\)\/\@2 - \(\@\(\(m\ ω\)\/ℏ\)\ \(α\^*\)\)\/\@2)\)\ X\&^\)\)·\[VerticalSeparator]0⟩//BCHRelation//QAProductExpand

simplifying  the result we find

ψ[x] = ψ[x] // PowerExpand // ExpandAll // 
        FullSimplify

After a closer look to this expression we recognize the mean values of position and momentum operators calculated above, thus the wave function associated with the coherent state is given by

\(TraditionalForm\`ψ(
        x) = \(e\^\(\(-\ i\)\ \(ℛ(α)\) \(ℐ(α)\)\)\) e\^\(\(\(\(\ \)\(\(i\)\(\ \)\(x\)\(\ \ \)\)\)\/ℏ\) ⟨\ P\ ⟩\_α\)\ \(\(ϕ\_0\)(\ 
          x - ⟨\ X\ ⟩\_α\ )\)\)

Feagin, James M.
Quantum methods with mathematica
Santa Clara, CA. : Springer, 1994

Wolfram, Stephen 
The Mathematica book Edicion: 3rd ed. 
Cambridge : University Press, 1996

Jason, Harris 
Creating New Notations in Mathematica
Demo distributed with Mathematica.

Jason, Harris 
Notation.m – A Package for Defining New Notation
Package distributed with Mathematica.