A quick introduction to the ColorMath package

ColorMath is a package for symbolically performing color summed calculations in QCD (SU(Nc)).

Warning: To input color structure use copy and paste, type in the FullForm, or use the short command functions. Do not try to input color structure manually, or using the math assistant pallets, this will give you Power instead of Superscript. For more info, see “Input and FullForm” below.

Loading the package

To avoid double loading of definitions, you may want to quit the kernel first:

Quit[]

In order to get started, the .m package has to be loaded from /full/path/to/your/package/ColorMath.m. Make sure you adjust the version number to the version you try to load.

Get["/data/Documents/Annatjobb/Color/Mathematica/ColorMath1.0.m"]

Basic color objects

The notation for the basic building blocks are as below.

A quark-line with quarks Q1 and Q2

(Subscript[(Superscript[δ, Q1]), Q2])

Note that lower and upper indices are different. One position is taken to define incoming quarks/outgoing anti-quarks, and the other position is used for outgoing quarks and incoming anti-quarks. What is taken to be what is a question of definition. To avoid mistakes in index placing, copy-pasting is advised. In some (older) versions of Mathematica (Subscript[(Superscript[δ, Q1]), Q2]) formats as (Subscript[((Superscript[δ, Q1])), Q2]), but the meaning is still the same i.e., FullForm[(Subscript[((Superscript[δ, Q1])), Q2])] gives the same result.

A gluon-line with gluons G1 and G2

(Superscript[Δ, {G1,G2}])

An SU(Nc) generator with quark indices Q1 and Q2 and gluon index G1

This is the color structure for a quark-gluon vertex.

(Subscript[(Superscript[(Superscript[t, {G1}]), Q2]), Q1])

Note the brackets around G1. (Again, this expression may be differently formatted in some versions of Mathematica.)

Gluons attached to an open quark line

With the above generator notation, including the {}, a set of gluons attached to the same quark-line can easily be denoted by

(Subscript[(Superscript[(Superscript[t, {G1,G2,G3}]), Q1]), Q2])

rather than by  (Subscript[(Superscript[(Superscript[t, {G1}]), Q1]), q1])(Subscript[(Superscript[(Superscript[t, {G2}]), q1]), q2])(Subscript[(Superscript[(Superscript[t, {G3}]), q2]), Q2]).

Gluons attached to a closed quark-line

If the indices Q1 and Q2 above are the same, the quark-line is closed and represents a trace of generators, this is denoted “(Superscript[o, {G1,G2,G3}])”.

(Superscript[o, {G1,G2,G3}])

The structure constants, (Superscript[f, {G1,G2,G3}]),  and the symmetric structure constants, (Superscript[d, {G1,G2,G3}])

Note that I(Superscript[f, {G1,G2,G3}]) is the color structure associated with the triple gluon vertex.

(Superscript[f, {G1,G2,G3}])/.FDToORules
(Superscript[d, {G1,G2,G3}])/.FDToORules

Above, FDToORules is a rule for replacing structure constants with closed quark-lines, and TR is the normalization of the generators (typically chosen to be 1/2 or 1),  i.e. (Superscript[o, {G1,G2}])=TR(Superscript[Δ, {G1,G2}]). The number of colors is denoted Nc.

Input

To input these color structures, use copy and paste or write in the short command functions:

δ[Q1,Q2]
Δ[G1,G2]
f[G1,G2,G3]
d[G1,G2,G3]
t[{G1,G2,G3},Q1,Q2]

See also “Input and FullForm” below.

Some basic calculations

With these objects we can do basic manipulations by using (Subscript[(Superscript[(Superscript[t, {G1}]), Q2]), Q1]) for each quark-gluon vertex, and I(Superscript[f, {g3,g2,g1}]) for each triple gluon vertex, and by making sure that internal indices are contracted by appearing twice.

If you try some basic calculations and fail, see “Common mistakes” and “Input and FullForm” below, and try out the WhatIsWrong function.

A simple example

As a simple example, consider quark anti-quark going to quark anti-quark, q1 qbar2->q3 qbar4. 

The amplitude, having an s-channel contribution, and a t-channel contribution, can be written in the form

Amp=S(Subscript[(Superscript[(Superscript[t, {g}]), q1]), q2])(Subscript[(Superscript[(Superscript[t, {g}]), q4]), q3])+T(Subscript[(Superscript[(Superscript[t, {g}]), q1]), q3])(Subscript[(Superscript[(Superscript[t, {g}]), q4]), q2])

where S and T denote momentum space factors.

To square the amplitude we need to multiply it with its conjugate and contract the indices. Note, however, that we need to replace the summation index g with a new index. This can be done manually or by using the ReplaceDummyIndices function. To contract indices we use the CSimplify function. We can thus simply write:

CSimplify[Conjugate[Amp] ReplaceDummyIndices[Amp]]

Below some useful rules and functions acting on the color structure are listed.

CSimplify

The most general function for index contraction is CSimplify. It simplifies by contracting repeated indices in a general way, and may be the only function you need to know.

CSimplify[ (Subscript[(Superscript[(Superscript[t, {G1,G2,G3}]), Q1]), q1])(Subscript[(Superscript[δ, q1]), Q2])]

CSimplify[I (Superscript[f, {g1,g2,g3}])I(Superscript[f, {g3,g2,g1}])]

CSimplify[I (Superscript[f, {g1,g2,G3}])I(Superscript[f, {g2,g1,G4}])]

CSimplify[I (Superscript[f, {g1,g2,G3}])(Superscript[o, {g2,g1,G4}])]

For expressions containing structure constants, FDRules, which act on structure constants (see below), is first applied. After this,  remaining structure constants are by default rewritten in terms of (Superscript[o, {g1,...,gk}])s to contract remaining indices, but this can be turned off  by setting the option RemoveFD to False.

CSimplify[I (Superscript[f, {g1,g2,G3}])(Superscript[o, {g1,G4,g2}]),RemoveFD-> False]

CSimplify is based on a set of rules. All ColorMath rules have names ending with Rules, and are applied using “/.” or “//.” for repeated application.

FDRules

FDRules are special contraction rules for products of up to 3 fs and ds.

(Superscript[d, {g2,G1,g1}])(Superscript[d, {g1,G2,g3}])(Superscript[f, {g3,G3,g2}])//.FDRules

SimpleRules

SimpleRules do basic manipulations involving delta functions (δ and Δ) and quark contraction. They never increase the number of terms.

(Subscript[(Superscript[(Superscript[t, {G1,G2,G3}]), Q3]), q1])(Subscript[(Superscript[δ, q1]), Q2])//.SimpleRules
(Superscript[Δ, {G1,g2}])(Superscript[Δ, {g2,G2}])//.SimpleRules

OTSimpleRules

Contracts neighboring and next to neighboring gluons in (open and closed) quark - lines,

(Subscript[(Superscript[(Superscript[t, {G1,g2,G2,g2,g4,g4,G3}]), q1]), q1])//.OTSimpleRules

AllSimpleRules

AllSimpleRules is the set of rules acting on quark-lines and deltas which never increase the number of terms. It is the union of SimpleRules, OTSimpleRules and Remove0To2ORules, which simplifies closed quark-lines with at most two gluon indices.

(Subscript[(Superscript[(Superscript[t, {G1,g2,G2,g2,g4,g4,G3}]), q1]), q1])//.AllSimpleRules

Conjugate

The action of Conjugate has been redefined for the color structure. Note that

Conjugate[ (Subscript[(Superscript[δ, Q1]), Q2])]
Conjugate[ (Subscript[(Superscript[(Superscript[t, {G1,G2,G3}]), Q1]), Q2])]
Conjugate[ (Superscript[o, {G1,G2,G3}])]

whereas (Superscript[f, {G1,G2,G3}]) and (Superscript[d, {G1,G2,G3}]) are real.

ReplaceDummyIndices

This function replaces all summation indices with a new set of dummy indices

ReplaceDummyIndices[(Subscript[(Superscript[(Superscript[t, {g}]), q1]), q2])(Subscript[(Superscript[(Superscript[t, {g}]), q4]), q3])]

SortIndices

To Mathematica (Superscript[Δ, {G1,G2}]) is not the same as (Superscript[Δ, {G2,G1}]). Therefore, it is sometimes needed to order the indices in a default order. SortIndices is used by CSimplify.

(Superscript[Δ, {G1,G2}])-(Superscript[Δ, {G2,G1}])
SortIndices[(Superscript[Δ, {G1,G2}])-(Superscript[Δ, {G2,G1}])]

Similarly (Superscript[f, {G1,G2,G3}])≠(Superscript[f, {G2,G3,G1}]), etc.

Defining Tensors

For processes with more than a few partons it is useful to define tensors and do calculations in terms of these, for example a basis for q1 qbar2->q3 qbar4 g5 is

(Subscript[Vector181, {q1_,q2_,q3_,q4_,g5_}]):=(Subscript[(Superscript[δ, q1]), q2])(Subscript[(Superscript[(Superscript[t, {g5}]), q4]), q3])
(Subscript[Vector818, {q1_,q2_,q3_,q4_,g5_}]):=(Subscript[(Superscript[(Superscript[t, {g5}]), q1]), q2])(Subscript[(Superscript[δ, q4]), q3])
(Subscript[Vector888s, {q1_,q2_,q3_,q4_,g5_}]):=Module[{i1,i2},(Subscript[(Superscript[(Superscript[t, {i1}]), q1]), q2])(Subscript[(Superscript[(Superscript[t, {i2}]), q4]), q3])(Superscript[d, {i1,i2,g5}])]
(Subscript[Vector888a, {q1_,q2_,q3_,q4_,g5_}]):=Module[{i1,i2},(Subscript[(Superscript[(Superscript[t, {i1}]), q1]), q2])(Subscript[(Superscript[(Superscript[t, {i2}]), q4]), q3])I(Superscript[f, {i1,i2,g5}])]

Here it is essential that we use pattern matching underscores on the left hand side, and that the dummy summation indices are contained in modules to guarantee uniqueness. For this reason we also use “:=”, rather than “=”.
(The names of these tensors are formed by first using the total multiplet of parton 1 and 2, then parton 3 and 4, and finally parton 3, 4 and 5.)

As we have used Module, we need not worry about changing dummy indices. This is automatically taken care of :

(Subscript[Vector888a, {q1,q2,q3,q4,g5}])
(Subscript[Vector888a, {q1,q2,q3,q4,g5}])

Having defined these tensors, we may do manipulations with them, like calculating scalar products:

CSimplify[(Subscript[Vector888a, {q1,q2,q3,q4,g5}])Conjugate[(Subscript[Vector888a, {q1,q2,q3,q4,g5}])]]

We will see below that there are simpler ways of calculating scalar products.

Some tensor examples

Here some useful functions acting on objects defined as above, for example (Subscript[Vector181, {q1_,q2_,q3_,q4_,g5_}]):= ... , are introduced.

CDot

CDot calculates scalar products of vectors.

CDot[Vector888a,Vector888s]
CDot[Vector888a]

In the second case it is implicit that the scalar product is taken between Vector888a and itself.

We may define a basis using these basis vectors.

OurBasis={Vector181,Vector818,Vector888s,Vector888a};

The scalar product of a list of vectors can also be taken by using CDot:

CDot[OurBasis]

CNorm

Similarly the norms are given by CNorm:

CNorm[OurBasis]

CDotMatrix

For non-orthogonal bases one is  interested in the scalar product between all basis vectors. This is calculated by CDotMatrix.

SPM=CDotMatrix[OurBasis];
MatrixForm[%]

CGamma

The effect of gluon exchange between two partons on a basis vector is also often needed. This is the case both for gluon resummation calculations, and for next to leading order calculations with a loop from gluon exchange between external legs. It is calculated using the function CGamma, which takes as arguments the basis (i.e. a List of the names of the basis vectors), the parton numbers (i.e. the place of the index in the tensor definition), and, optionally, the scalar product matrix and its inverse. The result is contained in a matrix, where the effect of gluon exchange between parton1 and parton2 on vector j is  contained in column j. Thus element ij is the i component of the resulting vector.

By default, consistency checks are made. It is checked that the new vector squared and its basis decomposed version squared agree, and that orthonormal bases results in symmetric matrices. Both checks are turned off using MakeChecks -> False.

CGamma[OurBasis,1,2]

By default, a general non-orthogonal basis is assumed. For orthogonal bases, orthonormal bases and trace bases (where each basis vector is one product of open and closed quark-lines) the calculations may be improved by setting the option BasisType. Furthermore, progress information can be turned off using Verbose -> False.

As partons 1 and 2 are in a manifest multiplet in this basis, the result of the exchange is just a constant for each basis vector. Exchanging a gluon between parton 1 and 3 we get a less simple result.

CGamma[OurBasis,1,3,SPM,Inverse[SPM], BasisType-> OrthogonalBasis, Verbose-> False]

More information about the functions and rules can be obtained using ? Name, for example for CGamma we can read about sign conventions:

?CGamma

Input and FullForm

To successfully use ColorMath it is essential to use color tensors which have the correct FullForm.

The FullForm of the color objects are

FullForm[(Subscript[(Superscript[δ, Q1]), Q2])]

FullForm[(Superscript[Δ, {G1,G2}])]

FullForm[(Subscript[(Superscript[(Superscript[t, {G1}]), Q2]), Q1])]

FullForm[(Superscript[f, {G1,G2,G3}])]

FullForm[(Superscript[o, {G1,G2,G3}])]

In particular, note that Superscript, not Power is used.

Input

Short command functions

You can also get the color structure by using the functions:

δ[Q1,Q2]
Δ[G1,G2]
f[G1,G2,G3]
d[G1,G2,G3]
t[{G1,G2,G3},Q1,Q2]

For convenience the quark and gluon delta functions can also be accessed by using:

delta[Q1,Q2]
Delta[G1,G2]

Greek indices

Greek indices may be input by using Esc, typing the latin alphabet representation, and pushing Esc again, for example Esc  Delta  Esc results in

Δ

For Δ and δ it is enough to use Esc  D Esc, and Esc  d Esc respectively.

Subscript

To enter subscript, for example (Subscript[Tens, a]) write Tens, then Ctrl + underscore (or Ctrl + minus), then a

(Subscript[Tens, a])

FullForm[(Subscript[Tens, a])]

Superscript

Unfortunately there is no keyboard shortcut for Superscript (Power formats as Superscript, but is not Superscript). To get started, it is advised to copy the color structures, or to write in the FullForm:

Superscript[f,{I1,I2,I3}]

For extensive usage you may consider changing the file where Mathematica keyboard shortcuts are defined.

Common mistakes

Below is a list of mistakes you might encounter.

Wrong FullForm

In the below, it looks like q2 could be contracted, but it is not:

CSimplify[(Subscript[(δ^Q1), q2])(Subscript[(δ^q2), Q2])]

The reason is that Power is used instead of Superscript.

FullForm[(Subscript[(δ^Q1), q2]) (Subscript[(δ^q2), Q2])]

Below, I (Superscript[f, {A,A,B}]) should be 0, but it is not:

CSimplify[(Superscript[If, {A,A,B}])]

Why? FullForm reveals than answer:

FullForm[(Superscript[If, {A,A,B}])]

We should have

CSimplify[I Superscript[f,List[A,A,B]]]

For spotting this, the function WhatIsWrong might be useful:

WhatIsWrong[(Subscript[(δ^Q1), Q2])]

WhatIsWrong[(Superscript[If, {A,A,B}])]

WhatIsWrong[(Superscript[δ, {A,A}])]

Repeated dummy index

If an index appears more than twice the result is not defined and will depend on the computation order:

CSimplify[I(Superscript[f, {G1,G2,g1}])I(Superscript[f, {g1,G3,G4}])Conjugate[I(Superscript[f, {G1,G2,g1}])I(Superscript[f, {g1,G3,G4}])]]

CSimplify[I(Superscript[f, {G1,G2,g1}])I(Superscript[f, {g1,G3,G4}])Conjugate[I(Superscript[f, {G1,G2,g2}])I(Superscript[f, {g2,G3,G4}])]]

Forgotten underscores in tensors

If the pattern matching underscores are forgotten, a tensor can only be used with the indices with which it was defined.

(Subscript[MyVec1, {G1,G2,G3,G4}]):=(((Superscript[Δ, {G1,G2}]) (Superscript[Δ, {G3,G4}]))/(-1+(Nc^2)))

(Subscript[MyVec1, {a,b,c,d}])

By using underscore we get pattern matching and can use any indices.

(Subscript[MyVec2, {G1_,G2_,G3_,G4_}]):=(((Superscript[Δ, {G1,G2}]) (Superscript[Δ, {G3,G4}]))/(-1+(Nc^2)))

(Subscript[MyVec2, {a,b,c,d}])