FORM (external)

FORM is a symbolic manipulation program by Jos Vermaseren and the FORM developers, made for expressions far too large to fit in memory. BootLoops runs FORM unmodified for three jobs: the algebra of Dirac tracestraces of products of gamma matrices: the spin algebra that turns a squared amplitude into scalar products of momenta and color factors, FORM 5's Feynman-diagram generator, and FORM 5's arbitrary-precision multiple zeta valuesnested sums $\zeta(s_1,\dots,s_k)=\sum_{n_1\gt\cdots\gt n_k\ge 1} n_1^{-s_1}\cdots n_k^{-s_k}$, constants that appear in the expansions of many loop integrals, used as a cross-check on constants.

Where it comes from

FORM was written by Jos Vermaseren and later developed with Jan Kuipers, Takahiro Ueda, Jens Vollinga, Ben Ruijl, Josh Davies, Toshiaki Kaneko and Coenraad Marinissen. The threaded build TFORM is by M. Tentyukov and Vermaseren. BootLoops adds no code inside FORM: it builds FORM from the authors' source and calls it as form (or tform). It adds the Python package Formglue around FORM, and the worked example on this page.

PartSourceAuthors
The Model QCD block of enum_1loop.frm, used as writtenThe FORM reference manualVermaseren and the FORM developers
The FORM job template in Formglue's form_hyper.py, which follows HyperFORM's example drivers line for lineHyperFORMA. Kardos, S.-O. Moch and O. Schnetz
New code: the other Formglue modules and the rest of the worked exampletools/formglue/Code by Claude

Please cite the authors' papers when you use FORM or HyperFORM. BootLoops is not affiliated with or endorsed by the authors of either.

What it does

You write a short program in FORM's own language and run it from the command line. The program declares symbols, vectors, indices and functions, defines expressions with Local, and applies substitution rules (id old = new;) and built-in operations in modules, each closed by .sort. FORM never holds a whole expression as a tree. It streams the terms through each module one at a time and merge-sorts the result, spilling to disk when needed. It does exactly what the program says: no automatic simplification, integration or equation solving.

For particle physics FORM provides gamma matrices (g_), $d$-dimensional Dirac traces (tracen), index contraction, wildcard patterns and repeat loops, enough to write SU($N$) color algebra in a few lines. Results are exact, with rational coefficients. The threaded build tform runs the same programs on several cores.

FORM 5 adds the two features BootLoops relies on most:

FORM is a separate program from the mpmath library that BootLoops otherwise uses, so agreement between the two values is a meaningful check.

FORM has these limits:

Examples

Tree-level $gg\to q\bar q$ in massless QCD, checked against the textbook. gg2qq.frm multiplies the three-diagram amplitude by its conjugate with physical gluon polarization sums, takes the $d$-dimensional trace with tracen,1;, and imposes massless kinematics. It then reduces the color factors with the SU($N$) Fierz identity, which removes a pair of color matrices with a summed index. That step, copied from the file, shows what FORM code looks like. NF is the number of colors and the preprocessor variable CFIERZ holds -1/(2*NF):

repeat;
  id TrF(?x,a0?,?y)*TrF(?z,a0?,?w) = 1/2*TrF(?x,?w,?z,?y) `CFIERZ'*TrF(?x,?y)*TrF(?z,?w);
  id TrF(?x,a0?,?y,a0?,?z)         = 1/2*TrF(?x,?z)*TrF(?y) `CFIERZ'*TrF(?x,?y,?z);
  id TrF(a0?) = 0;
  id TrF      = NF;
endrepeat;

With FORM installed (see Requirements), run FORM and then the check from the package directory tools/formglue/examples/gg2qq/. Set FORM_BIN if the binary is not called form:

form gg2qq.frm
python3 check_gg2qq.py

FORM prints Msq, the squared amplitude summed over spins, polarizations and colors and divided by $g^4$. It is a polynomial in $s$, $t$, $u$ and their inverses with d and NF symbolic, also written to gg2qq.out. FORM 4.3 and 5.0.1 give identical output. The check script reruns FORM, averages over the initial state, sets $d=4$, $N=3$, $u=-s-t$, and tests exact equality with the textbook result (Ellis, Stirling and Webber),

$$\overline{|\mathcal M|^2}/g^4 \;=\; \frac{t^2+u^2}{6\,tu}\;-\;\frac{3}{8}\,\frac{t^2+u^2}{s^2}\,.$$

The script then reruns with form -D MUT=1 gg2qq.frm (three-gluon vertex sign flipped) and -D MUT=2 (wrong $1/N$ term in the Fierz identity) and requires both comparisons to fail. It prints a PASS: line per step and exits 0. Exit code 1 means a comparison went the wrong way, and 2 that FORM or SymPy is missing.

The three tree-level diagrams for gg → qq̄: t- and u-channel quark exchange and the s-channel three-gluon vertex.
The three tree diagrams, drawn by render_gg2qq_diagrams.py from the vertex lists the FORM 5 generator emits for this process at loop order zero.

Generating the one-loop diagrams with FORM 5. enum_1loop.frm declares a QCD model with one quark flavor (qua/QUA), ghosts and the gluon self-couplings, then calls the generator and counts the terms. The arguments of diagrams_ are the model, the incoming and outgoing particles, the external momenta, the set kint of internal-momentum names, the loop count and the filters:

L T2 = diagrams_(QCD,{glu,glu},{qua,QUA},{p1,p2,q1,q2},kint,1,
    `OnShell_'+`NoTadpole_'+`NoSnail_');
.sort
#$n2 = termsin_(T2);
#write "COUNT gg_qqbar_1loop_onshell = `$n2'"

form enum_1loop.frm prints four such COUNT lines: 3 tree diagrams, 109 connected one-loop diagrams, 30 once tadpoles, snails and self-energy insertions on external legs are dropped, and 7 one-particle-irreducible ones. The set of 30 is written to enum_1loop.out. Formglue then assigns loop momenta. Its script form_route.py is in tools/formglue/, two directories above the example: python3 form_route.py enum_1loop.out --externals p1,p2,q1,q2 prints a line beginning ROUTED 30 diagrams, all self-checks PASS.

For the box marked in the figure, box_numerator.frm carries the algebra to an integrand: the trace against the conjugate tree, the color factors, and the loop-momentum dot products collected into $k^2$, $k\cdot p_1$, $k\cdot p_2$, $k\cdot p_3$. Its two TERMS lines report 4427 terms after the $d$-dimensional trace and 1225 in the integrand-ready polynomial. That polynomial is the input to an integration-by-parts reductionthe linear-algebra step that rewrites every integral of a family in terms of a small basis of master integrals program such as Kira.

The 30 on-shell one-loop diagrams for gg → qq̄ in a grid, with diagram 21, a box, outlined in red.
The 30 one-loop diagrams in enum_1loop.out, numbered by the generator's own indices; dashed lines are ghosts and the red frame marks the box treated in box_numerator.frm.

A multiple zeta value to 120 digits. The complete program below is one of Formglue's test fixtures (tests/fixtures/routing_glue/cap_float.frm). MZV=4 is the largest weight (sum of indices) FORM should prepare for, and Format floatprecision prints the full working precision:

#StartFloat 120d, MZV=4
Format floatprecision;
L FORACLE = mzv_(2,1);
Evaluate;
Print +f;
.end

The recorded output beside the fixture ends with

   FORACLE =
      1.2020569031595942853997381615114499907649862923404988817922715553418382\
      0578631309018645587360933525814619915779526071942e+00;

The value is $\zeta(3)$, as Euler's identity $\zeta(2,1)=\zeta(3)$ requires. FORM puts the outer index first, $\zeta(2,1)=\sum_{m\gt n\ge1}m^{-2}n^{-1}$. The backslash is FORM's own line wrapping, one reason to parse its output with Formglue. Formglue's form_oracle.py runs the same engine from Python and from the command line.

Requirements

Source and references

FORM is written in C and its source is in the FORM repository. Formglue is tools/formglue/ in the BootLoops repository, with the worked example under examples/gg2qq/; the README.md there lists its files. FORM and HyperFORM are not bundled with it and are run as separate programs.

ReferenceWhat it supplies
J.A.M. Vermaseren, New features of FORM, arXiv:math-ph/0010025FORM
J. Kuipers, T. Ueda, J.A.M. Vermaseren and J. Vollinga, FORM version 4.0, arXiv:1203.6543FORM 4
J. Davies, T. Kaneko, C. Marinissen, T. Ueda and J.A.M. Vermaseren, FORM 5.0, arXiv:2601.19982Floating point, multiple zeta values and the diagram generator, which builds on T. Kaneko's GRACE
M. Tentyukov and J.A.M. Vermaseren, Comput. Phys. Commun. 181 (2010) 1419The threaded build tform
A. Kardos, S.-O. Moch and O. Schnetz, HyperFORM, arXiv:2607.01163; code: HyperFORMA FORM 5 package that integrates hyperlogarithms (iterated integrals with simple poles) over Feynman parameters; the example drivers that form_hyper.py follows
Ellis, Stirling and Webber, QCD and Collider PhysicsThe textbook result of the first example

← back to the tools index