 FeynmanDiagrams - Maple Help

Physics[FeynmanDiagrams] - compute an expansion of the Scattering matrix for a model in coordinates representation, or the Scattering matrix element in momentum representation, and the corresponding Feynman Diagrams Calling Sequence FeynmanDiagrams(InteractionLagrangian, ...(optional arguments)...) Parameters

 InteractionLagrangian - the interaction Lagrangian depending on quantum fields Options

 • order = m : $m$ indicates the truncation order of the expansion $S=1+{S}_{1}+{S}_{2}+\mathrm{...}$ of the scattering matrix $S$ in coordinates representation, or of the corresponding matrix element $⟨f|S|i⟩$ in momentum representation. If not indicated, in coordinates representation the default value of order is 3, and in momentum representation it is automatically determined from the indicated incomingparticles, outgoingparticles and numberofloops.
 • incomingparticles = ... : when given, the output is the matrix element $⟨f|S|i⟩$ in momentum representation; incomingparticles is a list of field names representing the incoming particles $\left|i\right⟩$, and all of outgoingparticles and numberofloops should also be given.
 • outgoingparticles = ... : (required when incomingparticles are indicated), a list of field names representing the outgoing particles $⟨f|$, in $⟨f|S|i⟩$.
 • numberofloops = n : (required when incomingparticles are indicated, otherwise optional) the right-hand side is an integer, or a set of integers. This option indicates that the returned expansion $S=1+{S}_{1}+{S}_{2}+\mathrm{...}$ in coordinates representation, or the matrix element $⟨f|S|i⟩$ in momentum representation, should only include terms whose corresponding Feynman diagrams contain $n$ loops, or the numbers of loops indicated in the set of integers. When working in coordinates representation and numberofloops is not indicated, all the terms containing up to 3 loops are returned.
 • diagrams : synonyms: graphs, plot, produces, in addition, the display of the Feynman diagrams (drawings) corresponding to each term of the algebraic expression being returned. In coordinates representation, the correspondence between the terms in the output and diagrams is one-to-one. In momentum representation, only the diagrams representing different topologies are displayed.
 • output = ... : (related to momentum representation), if given, the right-hand side is probabilitydensity, so that given s incomingparticles and r outgoingparticles, the output is the average number of scattered particles per unit time and volume, having momenta within the infinitesimal volumes ${\mathrm{dp}}_{1},\mathrm{...},{\mathrm{dp}}_{r}$. That transition probability density is constructed using $⟨f|S|i⟩$ and the formula (13) of Sec.21 of ref.
 • reduciblegraphs = ... : (optional) it can be true or false (default), to include or discard from the expansion of $S$, or from the matrix element $⟨f|S|i⟩$, the terms corresponding to graphs with loops that are 1-particle reducible.
 • includetadpoles = ... : (optional) it can be true or false (default), to include or discard from the expansion of $S$, or from the matrix element $⟨f|S|i⟩$, the terms containing tadpoles, that is, lines that start and end in the same vertex.
 • numberofvertices = n : $n$ indicates that the expected output is just ${S}_{n}$, the ${n}^{\mathrm{th}}$ term of the expansion of $S$ in coordinates representation, or just $⟨f|{S}_{n}|i⟩$ in momentum representation. The Feynman diagrams of ${S}_{n}$ are the ones that contain $n$ vertices.
 • numberofexternallegs = ... : synonym numberoflegs, related to coordinates representation, the right-hand side is a positive integer, or a set of them, indicating the number of external legs of the Feynman diagrams corresponding to each term of the algebraic expression returned. Default value is all possible configurations of external legs.
 • normalproducts = ... : related to coordinates representation, the right-hand side is a function _NP(...), or a set of them, where each _NP(...) contains field names as arguments. These are the normal ordered products of unpaired fields entering $S=1+{S}_{1}+{S}_{2}+\mathrm{...}$. To these unpaired fields are associated the external legs of the related Feynman diagrams. This option is useful to specify one process (identified by the number and kind of external legs in _NP(...)) among all the possible configurations of external legs returned by default.
 • excludepropagators = ... : a list of two fields representing a propagator, or a set of these lists, indicating that terms involving these propagators are to be excluded from the output.
 • numberofverticesinloops = n : $n$ indicates that the expected output, either $S=1+{S}_{1}+{S}_{2}+\mathrm{...}$ in coordinates representation, or $⟨f|S|i⟩$, in momentum representation, should contain only terms where the loops contain n vertices (e.g. 3 = triangle, 4 = square, etc.)
 • putindicesinsquareofmomentum = ... : (optional), related to momentum representation, it can be true or false (default), to put spacetime indices in all the occurrences of squares of momentum within Feynman integrals. By default these indices are put only when the matrix element $⟨f|S|i⟩$ being returned contains no integrals.
 • gauge = ... : the right-hand side can be Feynman, Landau, unitary or arbitrary, respectively resulting in the values 1, 0, $\mathrm{\infty }$ and unset for the FeynmanDiagrams:-xi gauge parameter.
 • usepropagators = ... : the right-hand side can be true (default) or false; when set to false FeynmanDiagrams returns using an abstract representation in terms of FeynmanDiagrams:-Propagator, instead of a specific propagator whose form depends on the the spin of the underlying field.
 • externalnormalization = ... : the right-hand side can be true (default) or false. When true, the normalization factor related to the external legs follows the conventions of ; when false, these normalization factors are all set equal to 1.
 • simplifytensorindices = ... : (optional), related to momentum representation, it can be true or false (default), to perform a simplification of the tensor indices appearing in the returned $⟨f|S|i⟩$.
 • factortreelevel = ... : (optional), related to momentum representation, it can be true or false (default), to factor the tree-level terms appearing in the returned $⟨f|S|i⟩$.
 • labels = ... : related to coordinates representation, the right-hand side is a list of lists with labels (Capital letters), say $\left[\left[X\right],\left[Y\right],\mathrm{...}\right]$, representing the spacetime points used as dummy integration variables in each ${S}_{n}$. These labels also represent the points at which the interaction Lagrangians are evaluated when computing their time-ordered- products entering those integrands. Default value is the dependency of the fields of the interaction Lagrangian, as well as any other system of coordinates defined using the Coordinates command.
 • crossedpropagators = ... : related to coordinates representation, it can be true or false (default) to indicate that crossed propagators (related to crossed terms in the quadratic part of the Lagrangian) are not zero and so must be taken into account. This option only works up to order = 3
 • quiet : (optional) indicates that the computation should proceed without displaying messages on the screen, for instance regarding the matching of optional keywords Description

 • A scattering matrix $S$ relates the initial and final states, $\left|i\right⟩$ and $\left|f\right⟩$, of an interacting system. In an 4-dimensional spacetime with coordinates $X$, $S$ can be written as:

$S=T\left({ⅇ}^{i\int L\left(X\right)ⅆ{X}^{4}}\right)$

 where $i$ is the imaginary unit and $L$ is the interaction Lagrangian, written in terms of quantum fields depending on the spacetime coordinates $X$. The T symbol means time-ordered. For the terminology used in this page, see for instance chapter IV, "The Scattering Matrix", in ref.. This exponential can be expanded as

$S=1+{S}_{1}+{S}_{2}+{S}_{3}+\mathrm{...}$

 where

${S}_{n}=\frac{{i}^{n}}{n!}\int \dots \int T\left(L\left(\mathrm{X__1}\right),\dots ,L\left(\mathrm{X__n}\right)\right)ⅆ{\mathrm{X__1}}^{4}\dots ⅆ{\mathrm{X__n}}^{4}$

 and $T\left(L\left({X}_{1}\right),\mathrm{...},L\left({X}_{n}\right)\right)$ is the time-ordered product of n interaction Lagrangians evaluated at different points. Note the factor $\frac{{i}^{n}}{n!}$ included in the definition of ${S}_{n}$ used in this page. Coordinates representation

 • The default output of FeynmanDiagrams(L(X)) is thus $S=1+{S}_{1}+{S}_{2}+{S}_{3}$ in coordinates representation, $S$ truncated by default at order = 3. The expansion of the time-ordered product entering the integrand of each ${S}_{n}$ (herein called the expansion of ${S}_{n}$) is computed using Wick's theorems, and ${S}_{n}$ itself, including the factor $\frac{{i}^{n}}{n!}$, is expressed using the FeynmanIntegral command.
 • The expansion of ${S}_{n}$ consists of a sum of terms, each of which is a product of certain pairings of the operator field functions entering $L$ times the normal product of the remaining unpaired operators of free fields. The pairings between fields are the propagators, the Green functions of the associated free fields.
 • Each term of the expansion of ${S}_{n}$ corresponds to a Feynman diagram with $n$ vertices (the number $n$ of interaction Lagrangians in ${S}_{n}$). Within the diagram, each of the pairings of fields (propagators) has a corresponding internal line, and each field entering the normal product of unpaired field operators has a corresponding external leg. Each of those terms has a different configuration of external legs (normal products of unpaired fields), and the expanded ${S}_{n}$ being returned includes all the possible configurations of external legs. The algebraic structure of the output in coordinates representation

 • Each ${S}_{n}$ is represented in the output of FeynmanDiagrams by a FeynmanIntegral, whose integrand is of the form:

$\sum _{j=1}^{k}\mathrm{sf}\left(j\right)\mathrm{_GF}\left(j\right)$

 where $k$ is a finite integer depending on n and the interaction Lagrangian, $\mathrm{sf}\left(j\right)$ are the symmetry factors, and $\mathrm{_GF}\left(j\right)$ (to each one corresponds a Feynman diagram) are functions of name _GF, of one or two arguments, of the form:

$\mathrm{_GF}\left(\mathrm{_NP}\left({f}_{i},{f}_{j},\mathrm{...}\right)\right)$

 or,

$\mathrm{_GF}\left(\mathrm{_NP}\left({f}_{p},{f}_{q},\mathrm{...}\right),\left[\left[{f}_{r},{f}_{s}\right],\left[{f}_{t},{f}_{u}\right],\mathrm{...}\right]\right)$

 The $p,q,r,s,t,u$ identify fields entering the interaction Lagrangian. The first case ($\mathrm{_GF}$ function of only one argument) corresponds to the tree-level terms (so no propagators) appearing in ${S}_{n}$, with the argument of $\mathrm{_GF}$ being (just) a function of name _NP, representing the normal product of the (unpaired) fields ${f}_{i},{f}_{j},\dots$. Each of these fields represents an external leg of the corresponding Feynman diagram. In the second case ($\mathrm{_GF}$ function of two arguments), the second argument is a list of lists, where each internal list $\left[{f}_{k},{f}_{l}\right]$ represents a pairing of two fields (a propagator) and so corresponds to a connected line in the Feynman diagram. For the external legs and connected lines, both represented by fields applied at a point, the application point $X$ identifies the vertex where the line joins the Feynman diagram.
 • Terms that have less than two unpaired fields (external legs) do not appear in the output since they violate conservation of energy-momentum or do not change the initial state of the system. Also, the ${S}_{n}$ computed only contains terms that correspond to tree-level diagrams or to diagrams with loops that are 1-particle irreducible (1PI), which do not fall into two pieces if you cut one internal line. To change this default behavior use the option reduciblegraphs = true.
 • The computational representation of ${S}_{n}$ in coordinates representation involves n (dummy) integration variables ${X}_{n}$ representing systems of coordinates. For that purpose, by default FeynmanDiagrams use the dependency of the fields in the interaction Lagrangian, as well as any other coordinates system set using Setup. When there are not enough of them, more integration labels are automatically generated, all of the form X__n, literal subscripts, displayed as ${X}_{n}$. You can indicate the use of different integration labels using the labels option.
 • Mathematical notation: When the Physics package is loaded in the Standard Graphical User Interface, the _NP function is displayed using textbook notation; for example, $\mathrm{_NP}\left(\mathrm{\phi }\left(X\right),\mathrm{\phi }\left(Y\right)\right)$ is displayed as $:{\mathrm{\phi }}\left(X\right){\mathrm{\phi }}\left(Y\right):$ and $\mathrm{_GF}\left(\mathrm{_NP}\left(\mathrm{\phi }\left(X\right),\mathrm{\phi }\left(Y\right)\right),\left[\left[\mathrm{\phi }\left(X\right),\mathrm{\phi }\left(Y\right)\right],\mathrm{...}\right]\right)$ is displayed as $:{\mathrm{\phi }}\left(X\right){\mathrm{\phi }}\left(Y\right):\left[{\mathrm{\phi }}\left(X\right),{\mathrm{\phi }}\left(Y\right)\right]\left[\mathrm{...}\right]$, the product of the time-ordered normal product (the $\mathrm{_NP}\left(\mathrm{...}\right)$ function) with the lists representing the propagators (second argument of the ${\mathrm{_GF}}_{n}$ function). Momentum representation

 • The transition probability for a process with initial and final states $\left|i\right⟩$ and $\left|f\right⟩$ in momentum representation is given by the square of the scattering matrix elements $⟨f|S|i⟩$. The states $\left|i\right⟩$ and $\left|f\right⟩$, with respectively s and r free particles, are normalized such that the average number per unit volume of each of the s and r particles is equal to one (see sec. 21.2 of ref., "Normalization of the State amplitude"). In this sense, each of the s and r fields respectively indicated in incomingparticles and outgoingparticles represent a 1-particle per unit volume with precisely defined average momentum. All the s particles in $\left|i\right⟩$ have different sets of quantum numbers, and the r particles in $\left|f\right⟩$ are only those whose momentum has been altered by the scattering process.
 • The output of FeynmanDiagrams(L(X), incomingparticles = [...], outgoingparticles = [...], numberofloops = n) is thus the S-matrix element $⟨f|S|i⟩$ in momentum representation (see formula (2) of sec. 21.1 in ref.), of the form

$⟨f|S|i⟩=F\left({p}_{i},{p}_{f}\right)\mathrm{\delta }\left(\left(\sum _{i=1}^{s}{p}_{i}\right)-\left(\sum _{f=1}^{r}{p}_{f}\right)\right)$

 The $\mathrm{\delta }$ (Dirac) is the expected singular factor due to the conservation of the energy-momentum of the s initial (incoming) and r final (outgoing) particles, and $F\left({p}_{i},{p}_{f}\right)$, also called the amplitude, is the sum of terms, in momentum representation, corresponding to Feynman diagrams with the number of loops indicated and $s+r$ external legs.
 • When the option output = probabilitydensity is given, the output is the transition probability density, that is, the average number of scattered particles per unit time and per unit volume having momenta within the infinitesimal volumes ${d}^{3}{p}_{1}\mathrm{...}{d}^{3}{p}_{r}$. That probability density is constructed using the square of the scattering matrix element ${\left|⟨f|S|i⟩\right|}^{2}$, as shown in formula (13) of sec. 21.1 of ref.:

$\mathrm{dw}={\left(2\mathrm{\pi }\right)}^{3s-4}\mathrm{n__1}\mathrm{...}\mathrm{n__s}{\left|F\left({p}_{i},{p}_{f}\right)\right|}^{2}\mathrm{\delta }\left(\left(\sum _{i=1}^{s}{p}_{i}\right)-\left(\sum _{f=1}^{r}{p}_{f}\right)\right){d}^{3}{p}_{1}\mathrm{...}{d}^{3}{p}_{r}$

 where each ${n}_{1}\mathrm{...}{n}_{s}$ represents the particle density of each of the s particles in the initial state $\left|i\right⟩$, and for an interpretation of the square of the $\mathrm{\delta }$ factor that appears in ${\left|⟨f|S|i⟩\right|}^{2}$ see sec. 64 of ref.. In order to get the number of scattered particles per unit of time and volume that happen in the final momentum region $\mathrm{\Delta }{p}_{1}$ $\mathrm{..}$ $\mathrm{\Delta }{p}_{r}$, the probability density $\mathrm{dw}$ needs to be integrated over that particular region.
 • The truncation order of $S$ in $⟨f|S|i⟩$, if not specified, is some finite n automatically derived from the interaction Lagrangian, the indicated number of loops, and the number and kind of incoming and outgoing particles. Terms ${S}_{m}$ with $m>n$ don't contribute to the indicated process.
 • Although $⟨f|S|i⟩$ in momentum representation can be computed departing from the expansion of $S$ in coordinates representation, it is simpler to compute it directly using the Feynman rules in momentum representation (for the conventions used, see chapter V of ref., "The Feynman rules and Diagrams") together with a program for the generation of the Feynman diagrams at any order, implemented in the Maple language following the presentation in ref.. The algebraic structure of the output in momentum representation

 • Each integral entering the scattering matrix element $⟨f|S|i⟩$ is represented in the output of FeynmanDiagrams using the FeynmanIntegral command. These integrals are all divergent and their physical meaning exist only after separating the finite from the infinite part, followed by redefining the masses and coupling constants of the model absorbing the infinities (the renormalization process).
 • All the momenta of the incoming and outgoing particles are represented using literal subscripts P__n (prefixed with the Capital letter P), displayed as ${P}_{n}$ where $n$ is an integer. All the momenta of the virtual particles (entering as integration labels in the Feynman integrals of the output) are represented using literal subscripts p__n (prefixed with the lowercase letter p), displayed as ${p}_{n}$ where $n$ is an integer. The momentum assignation ${P}_{n}$ follows the order of the incoming and outgoing particles. For example if you have $\mathrm{incomingparticles}=\left[\mathrm{\phi },\mathrm{\eta }\right]$ and $\mathrm{outgoingparticles}=\left[\mathrm{\theta },\mathrm{\psi }\right]$ the momenta are assigned as follows: $\mathrm{\phi }↦{P}_{1}$, $\mathrm{\eta }↦{P}_{2}$ , $\mathrm{\theta }↦{P}_{3}$ and $\mathrm{\psi }↦{P}_{4}$.
 • The energy of each incoming and outgoing particle (${0}^{\mathrm{th}}$ component of each ${{P}_{n}}^{\mathrm{\mu }}$) entering the output $⟨f|S|i⟩$ is expressed using literal subscripts E__n (prefixed with the Capital letter E), displayed as ${E}_{n}$ where $n$ is an integer.
 • When computing beyond tree-level, the propagators of fields - say $\mathrm{\phi }$ - that appear within Feynman integrals include their masses, expressed using literal subscripts, say as m__phi, prefixed with the letter m, displayed as ${m}_{\mathrm{\phi }}$. To indicate that a vector field is massless use Setup, for instance as in $\mathrm{Setup}\left(\mathrm{massless}=A\right)$.
 • For readability, the spacetime tensor indices of the square of momenta of incoming, outgoing, and virtual particles, entering denominators of propagators in the integrands of Feynman integrals, are omitted. To have these repeated indices explicitly shown, use the option putindicesinsquareofmomentum. Likewise, the spacetime indices of the 4-vectors ${{P}_{n}}^{\mathrm{\mu }}$ in the Dirac $\mathrm{\delta }$ factor of $⟨f|S|i⟩$ are only put for the tree-level terms, not when these factors are within Feynman integrals. For example, for the tree-level terms of the $\mathrm{\lambda }{\mathrm{\phi }}^{4}$ model, the input / output is presented as
 $\mathbf{>}\mathrm{FeynmanDiagrams}\left(\mathrm{\lambda }{\mathrm{\phi }\left(X\right)}^{4},\mathrm{incomingparticles}=\left[\mathrm{\phi },\mathrm{\phi }\right],\mathrm{outgoingparticles}=\left[\mathrm{\phi },\mathrm{\phi }\right],\mathrm{numberofloops}=0\right)$

$\frac{3i\mathrm{\lambda }\mathrm{\delta }\left({{P}_{1}}_{\phantom{}\phantom{\mathrm{\mu }}}^{\phantom{}\mathrm{\mu }}+{{P}_{2}}_{\phantom{}\phantom{\mathrm{\mu }}}^{\phantom{}\mathrm{\mu }}-{{P}_{3}}_{\phantom{}\phantom{\mathrm{\mu }}}^{\phantom{}\mathrm{\mu }}-{{P}_{4}}_{\phantom{}\phantom{\mathrm{\mu }}}^{\phantom{}\mathrm{\mu }}\right)}{2{\mathrm{\pi }}^{2}\sqrt{\mathrm{E__1}\mathrm{E__2}\mathrm{E__3}\mathrm{E__4}}}$

 and say for the $\mathrm{\lambda }{\mathrm{\phi }}^{3}$ model, $⟨f|S|i⟩$ with one loop,
 $\mathbf{>}\mathrm{FeynmanDiagrams}\left(\mathrm{\lambda }{\mathrm{\phi }\left(X\right)}^{3},\mathrm{incomingparticles}=\left[\mathrm{\phi }\right],\mathrm{outgoingparticles}=\left[\mathrm{\phi }\right],\mathrm{numberofloops}=1\right)$

$\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\int }\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\frac{9{\mathrm{\lambda }}^{2}\mathrm{\delta }\left(-{P}_{2}+{P}_{1}\right)}{8{\mathrm{\pi }}^{3}\sqrt{\mathrm{E__1}\mathrm{E__2}}\left(i\mathbf{\epsilon }-{{m}_{\mathrm{\phi }}}^{2}+{{p}_{2}}^{2}\right)\left({\left(-{P}_{1}-{p}_{2}\right)}^{2}-{{m}_{\mathrm{\phi }}}^{2}+i\mathbf{\epsilon }\right)}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{\mathrm{p__2}}^{4}$

 $\mathbf{>}\mathrm{FeynmanDiagrams}\left(\mathrm{\lambda }{\mathrm{\phi }\left(X\right)}^{3},\mathrm{incomingparticles}=\left[\mathrm{\phi }\right],\mathrm{outgoingparticles}=\left[\mathrm{\phi }\right],\mathrm{numberofloops}=1,\mathrm{putindicesinsquareofmomentum}\right)$

$\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\int }\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\frac{9{\mathrm{\lambda }}^{2}\mathrm{\delta }\left(-{{P}_{2}}_{\phantom{}\phantom{\mathrm{\beta }}}^{\phantom{}\mathrm{\beta }}+{{P}_{1}}_{\phantom{}\phantom{\mathrm{\beta }}}^{\phantom{}\mathrm{\beta }}\right)}{8{\mathrm{\pi }}^{3}\sqrt{\mathrm{E__1}\mathrm{E__2}}\left(i\mathbf{\epsilon }-{{m}_{\mathrm{\phi }}}^{2}+{{p}_{2}}_{\mathrm{\mu }}{{p}_{2}}_{\phantom{}\phantom{\mathrm{\mu }}}^{\phantom{}\mathrm{\mu }}\right)\left(\left(-{{P}_{1}}_{\mathrm{\alpha }}-{{p}_{2}}_{\mathrm{\alpha }}\right)\left(-{{P}_{1}}_{\phantom{}\phantom{\mathrm{\alpha }}}^{\phantom{}\mathrm{\alpha }}-{{p}_{2}}_{\phantom{}\phantom{\mathrm{\alpha }}}^{\phantom{}\mathrm{\alpha }}\right)-{{m}_{\mathrm{\phi }}}^{2}+i\mathbf{\epsilon }\right)}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{\mathrm{p__2}}^{4}$

 • The infinitesimal $\mathbf{\epsilon }$ entering the denominators of propagators are all expressed using the FeynmanDiagrams:-epsilon command. The U and V spinors entering the output when there are spinor fields, as well as the polarization vector when there are vector fields, are all respectively expressed using FeynmanDiagrams:-Uspinor, FeynmanDiagrams:-Vspinor and FeynmanDiagrams:-PolarizationVector, correspondingly displayed as $\mathbit{u}$, $\mathbit{v}$ and $\mathbf{ϵ}$ (see ref. and the Examples section). The input representing the interaction Lagrangian

 • Given an interaction Lagrangian, FeynmanDiagrams considers a field of the problem any function of spacetime variables (set using Coordinates or Setup). It is recommended that you also set the field operators as quantum operator using Setup, and fields that were not set as quantum operators are automatically set as such when you call FeynmanDiagrams.
 • To represent the Dagger of a complex field, say $C\left(X\right)$, use Dagger, as in Dagger(C(X)) or Dagger(C[mu](X)). To represent spinor fields, use anticommutative functions. For that purpose, you can set an anticommutative prefix using Setup. To represent the Dirac conjugate of a spinor field, say Q(X), use conjugate, as in conjugate(Q(X)).
 • When working in momentum representation beyond tree-level, the propagators of vector field that appear within Feynman integrals include their mass. To indicate that a field is massless use Setup, for instance as in $\mathrm{Setup}\left(\mathrm{massless}=A\right)$.
 • When matrix multiplication (e.g. of spinors) enters the interaction Lagrangian, you can enter the expression representing it with the matrix (spinorial) indices explicit. For example, for an interaction Lagrangian in quantum electrodynamics (QED) involving Dirac matrices, you can use conjugate(Q[j](X)) * Dgamma[mu][j,k] * Q[k](X) * A[mu](X) where Q[j](X) and conjugate(Q[j](X)) respectively represent a spinor field and its Dirac conjugate. Note that, depending on the case, the spinor and even spacetime indices can be omitted entirely without ambiguity (see the Examples section).
 • The summation convention for spacetime, gauge, and spinor repeated indices in products entering the interaction Lagrangian is automatically used by FeynmanDiagrams. The options for changing the default output

 • Several options are available to change the default output of FeynmanDiagrams in coordinates and in momentum representation. See the Parameters section above. These options can be used alone or together and are illustrated in the Examples section. Briefly, to compute, in coordinates representation, only the terms that involve diagrams:
 – with $j$ external legs use the option numberofexternallegs = j;
 – with some specific external legs specifying a particular physical process use the option normalproducts = ...;
 and for both coordinates and momentum representation,
 – to truncate the expansion of $S$ or of $⟨f|S|i⟩$ at an order different than the default use the option order = m;
 – to compute only one term ${S}_{n}$ of the expansion of $S$ or of $⟨f|S|i⟩$, use the option numberofvertices = n;
 – to compute only the terms that involve diagrams with $k$ loops (tree-level is $k=0$) use the option numberofloops = k;
 – to additionally display the diagrams (drawings) corresponding to the terms appearing in the returned output use the option diagrams;
 NOTE: the vertices of the drawings are displayed in red and encircled in black, and the current implementation of FeynmanDiagrams can only draw the diagrams than contain up to 3 vertices.
 • When computing in coordinates representation up to order = m, it is convenient to previously set m coordinate systems using Setup or Coordinates to avoid having FeynmanDiagrams introducing labels to represent the $m$ spacetime coordinates that enter the FeynmanIntegrals (each ${S}_{n}$). When additional labels are necessary, they are all of the form ${X}_{n}$, expressed using literal subscripts X__n, where $n$ is an integer.
 • When using the normalproducts, excludepropagators or crossedpropagators options, the fields entering the right-hand sides can be referenced by just their names, or also with their functionality. This can be used, for example, to filter out the propagator $\left[f\left(X\right),g\left(Y\right)\right]$ only, or all the propagators of the form $\left[f,g\right]$, which would include as well $\left[f\left(X\right),g\left(X\right)\right]$ and $\left[f\left(Y\right),g\left(Y\right)\right]$. Examples

Load the package, set three coordinate systems and set $\mathrm{\phi }$ to represent a quantum operator

 > $\mathrm{with}\left(\mathrm{Physics}\right):$
 > $\mathrm{Setup}\left(\mathrm{mathematicalnotation}=\mathrm{true},\mathrm{coordinates}=\left[X,Y,Z\right],\mathrm{quantumoperators}=\mathrm{φ}\right)$
 ${}\mathrm{Systems of spacetime coordinates are:}{}\left\{X=\left(\mathrm{x1}{,}\mathrm{x2}{,}\mathrm{x3}{,}\mathrm{x4}\right){,}Y=\left(\mathrm{y1}{,}\mathrm{y2}{,}\mathrm{y3}{,}\mathrm{y4}\right){,}Z=\left(\mathrm{z1}{,}\mathrm{z2}{,}\mathrm{z3}{,}\mathrm{z4}\right)\right\}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{coordinatesystems}}{=}\left\{{X}{,}{Y}{,}{Z}\right\}{,}{\mathrm{mathematicalnotation}}{=}{\mathrm{true}}{,}{\mathrm{quantumoperators}}{=}\left\{{\mathrm{\phi }}\right\}\right]$ (1)

Let $L$ be the interaction Lagrangian

 > $L≔\mathrm{λ}{\mathrm{φ}\left(X\right)}^{4}$
 ${L}{≔}{\mathrm{\lambda }}{}{{\mathrm{\phi }}{}\left({X}\right)}^{{4}}$ (2)

The expansion of $S$ in coordinates representation up to order = 3 is given by

 > $S=\mathrm{FeynmanDiagrams}\left(L\right)$
 ${S}{=}{1}{+}{\mathrm{%FeynmanIntegral}}{}\left({\mathrm{λ}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right)\right)\right){,}\left[\left[{X}\right]\right]\right){+}{\mathrm{%FeynmanIntegral}}{}\left({96}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){+}{16}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){+}{72}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right){+}{\mathrm{%FeynmanIntegral}}{}\left({1728}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){+}{10368}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){+}{2592}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){+}{3456}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){+}{10368}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){+}{576}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]{,}\left[{Z}\right]\right]\right)$ (3)

To compute only the tree-level terms of this result use numberofloops = 0. To produce the diagrams together with the algebraic expression of ${S}_{\mathrm{treelevel}}$, pass also the optional argument diagrams

 > $\mathit{S__treelevel}=\mathrm{FeynmanDiagrams}\left(L,\mathrm{numberofloops}=0,\mathrm{diagrams}\right)$   $\mathrm{S__treelevel}{=}{1}{+}{\mathrm{%FeynmanIntegral}}{}\left({\mathrm{λ}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right)\right)\right){,}\left[\left[{X}\right]\right]\right){+}{\mathrm{%FeynmanIntegral}}{}\left({16}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right){+}{\mathrm{%FeynmanIntegral}}{}\left({576}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]{,}\left[{Z}\right]\right]\right)$ (4)

The expansion of $S$  in coordinates representation to a specific order shows in a compact way the topology of the underlying Feynman diagrams. In the result above there are three terms, with 4, 6 and 8 external legs respectively. A $⟨f|S|i⟩$ element in momentum representation corresponding to the term with 4 external legs is one where there are 2 incoming and 2 outgoing particles

 > $\mathrm{FeynmanDiagrams}\left(L,\mathrm{incomingparticles}=\left[\mathrm{φ},\mathrm{φ}\right],\mathrm{outgoingparticles}=\left[\mathrm{φ},\mathrm{φ}\right],\mathrm{numberofloops}=0,\mathrm{diagrams}\right)$ $\frac{\frac{{3}{}{I}}{{2}}{}{\mathrm{\lambda }}{}{\mathrm{\delta }}{}\left({\mathrm{P__1}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}{+}{\mathrm{P__2}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}{-}{\mathrm{P__3}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}{-}{\mathrm{P__4}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}\right)}{{{\mathrm{\pi }}}^{{2}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}{}\mathrm{E__3}{}\mathrm{E__4}}}$ (5)

To compute the S-matrix element in momentum representation corresponding to the term with 6 external legs, change in the input above $\left[\mathrm{\phi },\mathrm{\phi }\right]$ by $\left[\mathrm{\phi },\mathrm{\phi },\mathrm{\phi }\right]$, and to get the element corresponding to 8 external legs use $\left[\mathrm{\phi },\mathrm{\phi },\mathrm{\phi },\mathrm{\phi }\right]$. The following computes the expansion of $S$ up to order = 3, only the terms corresponding to diagrams with two external legs

 > $\mathrm{FeynmanDiagrams}\left(L,\mathrm{numberofexternallegs}=2,\mathrm{diagrams}\right)$   ${\mathrm{%FeynmanIntegral}}{}\left({96}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right){+}{\mathrm{%FeynmanIntegral}}{}\left({3456}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){+}{10368}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]{,}\left[{Z}\right]\right]\right)$ (6)

Already from the diagrams, in this result there are terms with either 2 or 3 loops. The transition probability density for a process with two external legs - say one incoming and one outgoing particle - so corresponding to the first term with 2 loops, is then

 > $\mathrm{FeynmanDiagrams}\left(L,\mathrm{incomingparticles}=\left[\mathrm{φ}\right],\mathrm{outgoingparticles}=\left[\mathrm{φ}\right],\mathrm{numberofloops}=2,\mathrm{diagrams},\mathrm{output}=\mathrm{probabilitydensity}\right)$ ${\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ProbabilityDensity}}{}\left(\frac{{1}}{{2}}{}\frac{{\mathrm{%mul}}{}\left({{n}}_{{i}}{,}{i}{=}{1}{..}{1}\right){}{{\mathrm{abs}}{}\left({F}\right)}^{{2}}{}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right){}{\mathrm{%mul}}{}\left({{\mathrm{dP_}}}_{{f}}^{{3}}{,}{f}{=}{1}{..}{1}\right)}{{\mathrm{π}}}{,}{F}{=}{\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left(\frac{\frac{{3}}{{8}}{}{I}{}{{\mathrm{λ}}}^{{2}}}{{{\mathrm{π}}}^{{7}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}}{}\left({\left(\mathrm{P__1}{+}\mathrm{p__2}{+}\mathrm{p__3}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__2}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__3}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__2}\right]\right]\right){,}\left[\left[\mathrm{p__3}\right]\right]\right)\right)$ (7)

In the above, the spacetime indices in the square of momenta (denominators of propagators) entering the amplitude F are implicit. To make those indices explicit, use the option putindicesinsquareofmomentum

 > $F=\mathrm{FeynmanDiagrams}\left(L,\mathrm{incoming}=\left[\mathrm{φ}\right],\mathrm{outgoing}=\left[\mathrm{φ}\right],\mathrm{numberofloops}=2,\mathrm{putindices}\right)$
 ${F}{=}{\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left(\frac{\frac{{3}}{{8}}{}{I}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{Dirac}}{}\left({-}{\mathrm{P__2}}_{{\mathrm{~beta}}}{+}{\mathrm{P__1}}_{{\mathrm{~beta}}}\right)}{{{\mathrm{π}}}^{{7}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}}{}\left(\left({\mathrm{P__1}}_{{\mathrm{μ}}}{+}{\mathrm{p__2}}_{{\mathrm{μ}}}{+}{\mathrm{p__3}}_{{\mathrm{μ}}}\right){}\left({\mathrm{P__1}}_{{\mathrm{~mu}}}{+}{\mathrm{p__2}}_{{\mathrm{~mu}}}{+}{\mathrm{p__3}}_{{\mathrm{~mu}}}\right){-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__2}}_{{\mathrm{ν}}}{}{\mathrm{p__2}}_{{\mathrm{~nu}}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__3}}_{{\mathrm{α}}}{}{\mathrm{p__3}}_{{\mathrm{~alpha}}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__2}\right]\right]\right){,}\left[\left[\mathrm{p__3}\right]\right]\right)$ (8)

Up to order = 3, all the terms of the expansion of $S$ that contain three loops (see (6)) actually have only 2 external legs, and the corresponding Feynman Diagrams only 3 vertices

 > $\mathrm{FeynmanDiagrams}\left(L,\mathrm{numberofloops}=3\right)$
 ${\mathrm{%FeynmanIntegral}}{}\left({3456}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){+}{10368}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]{,}\left[{Z}\right]\right]\right)$ (9)

A corresponding S-matrix element in momentum representation:

 > $\mathrm{FeynmanDiagrams}\left(L,\mathrm{incomingparticles}=\left[\mathrm{φ}\right],\mathrm{outgoingparticles}=\left[\mathrm{φ}\right],\mathrm{numberofloops}=3\right)$
 ${\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left(\frac{{9}}{{32}}{}\frac{{{\mathrm{λ}}}^{{3}}{}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right)}{{{\mathrm{π}}}^{{11}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}}{}\left({\left(\mathrm{p__3}{+}\mathrm{p__4}{+}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\left({-}\mathrm{P__1}{+}\mathrm{P__2}{-}\mathrm{p__3}{-}\mathrm{p__4}{-}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__3}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__4}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__5}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__3}\right]\right]\right){,}\left[\left[\mathrm{p__4}\right]\right]\right){,}\left[\left[\mathrm{p__5}\right]\right]\right){+}{2}{}{\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left(\frac{{9}}{{32}}{}\frac{{{\mathrm{λ}}}^{{3}}{}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right)}{{{\mathrm{π}}}^{{11}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}}{}\left({\left({-}\mathrm{P__2}{+}\mathrm{p__4}{+}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\left({-}\mathrm{P__1}{+}\mathrm{P__2}{-}\mathrm{p__3}{-}\mathrm{p__4}{-}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__3}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__4}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__5}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__3}\right]\right]\right){,}\left[\left[\mathrm{p__4}\right]\right]\right){,}\left[\left[\mathrm{p__5}\right]\right]\right){+}{\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left(\frac{{9}}{{32}}{}\frac{{{\mathrm{λ}}}^{{3}}{}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right)}{{{\mathrm{π}}}^{{11}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}}{}\left({\left({-}\mathrm{P__1}{-}\mathrm{p__2}{+}\mathrm{P__2}{-}\mathrm{p__4}{-}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__2}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\left({-}\mathrm{P__2}{+}\mathrm{p__4}{+}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__4}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__5}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__2}\right]\right]\right){,}\left[\left[\mathrm{p__4}\right]\right]\right){,}\left[\left[\mathrm{p__5}\right]\right]\right)$ (10)

To compute only one term, say ${S}_{2}$, and for instance including terms with tadpoles use the options numberofvertices = 2 and includetadpoles

 > ${S}_{2}=\mathrm{FeynmanDiagrams}\left(L,\mathrm{numberofvertices}=2,\mathrm{includetadpoles}\right)$
 ${{S}}_{{2}}{=}{\mathrm{%FeynmanIntegral}}{}\left({16}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){+}{144}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){+}{96}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){+}{72}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right)$ (11)

Consider an interaction Lagrangian involving two fields. To indicate that $\mathrm{\eta }$ also represents a quantum field operator ($\mathrm{\phi }$ got set as quantum operator at the beginning), use Setup.

 > $\mathrm{Setup}\left(\mathrm{quantumoperators}=\mathrm{η}\right)$
 $\left[{\mathrm{quantumoperators}}{=}\left\{{\mathrm{\eta }}{,}{\mathrm{\phi }}\right\}\right]$ (12)
 > $\mathit{L__2}≔\mathrm{λ}{\mathrm{φ}\left(X\right)}^{4}+\mathrm{σ}{\mathrm{η}\left(X\right)}^{3}$
 $\mathrm{L__2}{≔}{\mathrm{\lambda }}{}{{\mathrm{\phi }}{}\left({X}\right)}^{{4}}{+}{\mathrm{\sigma }}{}{{\mathrm{\eta }}{}\left({X}\right)}^{{3}}$ (13)

In the expansion of $S$, there are no terms with one external leg $\mathrm{\phi }$ and another $\mathrm{\eta }$, that would be represented as a normal product of unpaired fields $\mathrm{_NP}\left(\mathrm{\phi },\mathrm{\eta }\right)$

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{normalproducts}=\mathrm{_NP}\left(\mathrm{φ},\mathrm{η}\right)\right)$
 ${0}$ (14)

Compute, one at a time, the terms entering the expansion of $S$ up to order 2 that have 0 (tree-level), 1, 2 and 3 loops

 > $\mathit{S__treelevel}=\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{order}=2,\mathrm{numberofloops}=0\right)$
 $\mathrm{S__treelevel}{=}{1}{+}{\mathrm{%FeynmanIntegral}}{}\left({\mathrm{λ}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right)\right)\right){+}{\mathrm{σ}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({X}\right)\right)\right){,}\left[\left[{X}\right]\right]\right){+}{\mathrm{%FeynmanIntegral}}{}\left({9}{}{{\mathrm{σ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({Y}\right){,}{\mathrm{η}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({Y}\right)\right]\right]\right){+}{16}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right)$ (15)
 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{order}=2,\mathrm{numberofloops}=1\right)$
 ${\mathrm{%FeynmanIntegral}}{}\left({72}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){+}{18}{}{{\mathrm{σ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({Y}\right)\right]{,}\left[{\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({Y}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right)$ (16)
 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{order}=2,\mathrm{numberofloops}=2\right)$
 ${\mathrm{%FeynmanIntegral}}{}\left({96}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right)$ (17)
 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{order}=2,\mathrm{numberofloops}=3\right)$
 ${0}$ (18)

Indeed, to see terms with three loops you'd need to consider the expansion of $S$ up to $\mathrm{order}=3$ at least

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{order}=3,\mathrm{numberofloops}=3,\mathrm{diagrams}\right)$  ${\mathrm{%FeynmanIntegral}}{}\left({3456}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){+}{10368}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]{,}\left[{Z}\right]\right]\right)$ (19)

A corresponding S-matrix element in momentum representation with 1 incoming and 1 outgoing particles

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{incomingparticles}=\left[\mathrm{φ}\right],\mathrm{outgoingparticles}=\left[\mathrm{φ}\right],\mathrm{numberofloops}=3\right)$
 ${\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left(\frac{{9}}{{32}}{}\frac{{{\mathrm{λ}}}^{{3}}{}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right)}{{{\mathrm{π}}}^{{11}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}}{}\left({\left(\mathrm{p__3}{+}\mathrm{p__4}{+}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\left({-}\mathrm{P__1}{+}\mathrm{P__2}{-}\mathrm{p__3}{-}\mathrm{p__4}{-}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__3}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__4}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__5}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__3}\right]\right]\right){,}\left[\left[\mathrm{p__4}\right]\right]\right){,}\left[\left[\mathrm{p__5}\right]\right]\right){+}{2}{}{\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left(\frac{{9}}{{32}}{}\frac{{{\mathrm{λ}}}^{{3}}{}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right)}{{{\mathrm{π}}}^{{11}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}}{}\left({\left({-}\mathrm{P__2}{+}\mathrm{p__4}{+}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\left({-}\mathrm{P__1}{+}\mathrm{P__2}{-}\mathrm{p__3}{-}\mathrm{p__4}{-}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__3}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__4}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__5}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__3}\right]\right]\right){,}\left[\left[\mathrm{p__4}\right]\right]\right){,}\left[\left[\mathrm{p__5}\right]\right]\right){+}{\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left({\mathrm{%FeynmanIntegral}}{}\left(\frac{{9}}{{32}}{}\frac{{{\mathrm{λ}}}^{{3}}{}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right)}{{{\mathrm{π}}}^{{11}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}}{}\left({\left({-}\mathrm{P__1}{-}\mathrm{p__2}{+}\mathrm{P__2}{-}\mathrm{p__4}{-}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__2}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\left({-}\mathrm{P__2}{+}\mathrm{p__4}{+}\mathrm{p__5}\right)}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__4}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__5}}^{{2}}{-}{\mathrm{m__φ}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__2}\right]\right]\right){,}\left[\left[\mathrm{p__4}\right]\right]\right){,}\left[\left[\mathrm{p__5}\right]\right]\right)$ (20)

Compute the terms entering the integrand of ${S}_{3}$, having four external legs (normal ordered products involving four fields). For the interaction Lagrangian ${L}_{2}$, the normal products of unpaired fields in ${S}_{3}$ only involve the $\mathrm{\phi }$ field

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{numberofvertices}=3,\mathrm{numberoflegs}=4\right)$
 ${\mathrm{%FeynmanIntegral}}{}\left({2592}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){+}{10368}{}{{\mathrm{λ}}}^{{3}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Z}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]{,}\left[{Z}\right]\right]\right)$ (21)

To get the corresponding S-matrix element in momentum representation, replace $\mathrm{numberoflegs}=4$ by a process with the same four legs, for example $\mathrm{incoming}=\left[\mathrm{\phi }\right],\mathrm{outgoing}=\left[\mathrm{\phi },\mathrm{\phi },\mathrm{\phi }\right]$ and $\mathrm{numberofloops}=2$. Considering ${S}_{2}$ instead, you also get normal products of $\mathrm{\eta }$ fields

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{numberofvertices}=2,\mathrm{numberoflegs}=4\right)$
 ${\mathrm{%FeynmanIntegral}}{}\left({72}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){+}{9}{}{{\mathrm{σ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({Y}\right){,}{\mathrm{η}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({Y}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right)$ (22)

For this Lagrangian and configuration of vertices and external legs, ${S}_{2}$ includes a term (with symmetry factor = 96) to which corresponds a 1-particle reducible diagram that is also a tadpole:

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__2},\mathrm{numberofvertices}=2,\mathrm{numberoflegs}=4,\mathrm{reducible},\mathrm{tadpoles},\mathrm{diagrams}\right)$   ${\mathrm{%FeynmanIntegral}}{}\left({96}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){+}{72}{}{{\mathrm{λ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]{,}\left[{\mathrm{φ}}{}\left({X}\right){,}{\mathrm{φ}}{}\left({Y}\right)\right]\right]\right){+}{9}{}{{\mathrm{σ}}}^{{2}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({Y}\right){,}{\mathrm{η}}{}\left({Y}\right)\right){,}\left[\left[{\mathrm{η}}{}\left({X}\right){,}{\mathrm{η}}{}\left({Y}\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right)$ (23)

Following is an example with the interaction Lagrangian of Quantum Electrodynamics (QED). First, define the vector field ${A}_{\mathrm{\mu }}$.

 > $\mathrm{Define}\left({A}_{\mathrm{μ}}\right)$
 $\mathrm{Defined objects with tensor properties}$
 $\left\{{{A}}_{{\mathrm{\mu }}}{,}{{\mathrm{\gamma }}}_{{\mathrm{\mu }}}{,}{{\mathrm{\sigma }}}_{{\mathrm{\mu }}}{,}{{\partial }}_{{\mathrm{\mu }}}{,}{{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{\mathrm{\epsilon }}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{X}}_{{\mathrm{\mu }}}{,}{{Y}}_{{\mathrm{\mu }}}{,}{{Z}}_{{\mathrm{\mu }}}\right\}$ (24)

Set the type of letter used to represent spinor indices (you can change this setting according to your preference using Setup) and set $A$ as a quantum operator.

 > $\mathrm{Setup}\left(\mathrm{spinorindices}=\mathrm{lowercaselatin_is},\mathrm{anticommutativeprefix}=Q,\mathrm{op}=\left\{A,Q\right\}\right)$
 $\mathrm{* Partial match of \text{'}}\mathrm{op}\mathrm{\text{'} against keyword \text{'}}\mathrm{quantumoperators}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{anticommutativeprefix}}{=}\left\{{Q}\right\}{,}{\mathrm{quantumoperators}}{=}\left\{{A}{,}{Q}{,}{\mathrm{\eta }}{,}{\mathrm{\phi }}\right\}{,}{\mathrm{spinorindices}}{=}{\mathrm{lowercaselatin_is}}\right]$ (25)

So, to represent spinor indices, use lowercase Latin letters from i to s, the spinor fields will be represented by any name prefixed by $Q$, and the matrix indices related to the matrix product involving Dirac matrices are written explicitly in the interaction Lagrangian. Use conjugate to represent the Dirac conjugate $\stackrel{&conjugate0;}{{Q}_{j}}$

 > $\mathit{L__QED}≔\mathrm{α}\stackrel{&conjugate0;}{{Q}_{j}\left(X\right)}{{\mathrm{Dgamma}}_{\mathrm{μ}}}_{j,k}{Q}_{k}\left(X\right){A}_{\mathrm{μ}}\left(X\right)$
 $\mathrm{L__QED}{≔}{\mathrm{\alpha }}{}\stackrel{{&conjugate0;}}{{{Q}}_{{j}}{}\left({X}\right)}{}{{Q}}_{{k}}{}\left({X}\right){}{{A}}_{{\mathrm{\mu }}}{}\left({X}\right){}{\left({{\mathrm{\gamma }}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}\right)}_{{j}{,}{k}}$ (26)

Compute ${S}_{2}$, only the terms with 4 external legs, so all the corresponding graphs have no loops, and display the diagrams

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__QED},\mathrm{numberofvertices}=2,\mathrm{numberoflegs}=4,\mathrm{diagrams}\right)$   ${\mathrm{%FeynmanIntegral}}{}\left({{\mathrm{α}}}^{{2}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~mu}}}}_{{j}{,}{k}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{i}{,}{l}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({{Q}}_{{k}}{}\left({X}\right){,}{{Q}}_{{l}}{}\left({Y}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{i}}{}\left({Y}\right)\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{j}}{}\left({X}\right)\right)\right){,}\left[\left[{{A}}_{{\mathrm{α}}}{}\left({Y}\right){,}{{A}}_{{\mathrm{μ}}}{}\left({X}\right)\right]\right]\right){-}{{\mathrm{α}}}^{{2}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~mu}}}}_{{j}{,}{k}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{i}{,}{l}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({{A}}_{{\mathrm{μ}}}{}\left({X}\right){,}{{A}}_{{\mathrm{α}}}{}\left({Y}\right){,}{{Q}}_{{k}}{}\left({X}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{i}}{}\left({Y}\right)\right)\right){,}\left[\left[{{Q}}_{{l}}{}\left({Y}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{j}}{}\left({X}\right)\right)\right]\right]\right){-}{{\mathrm{α}}}^{{2}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~mu}}}}_{{j}{,}{k}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{i}{,}{l}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({{A}}_{{\mathrm{μ}}}{}\left({X}\right){,}{{A}}_{{\mathrm{α}}}{}\left({Y}\right){,}{{Q}}_{{l}}{}\left({Y}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{j}}{}\left({X}\right)\right)\right){,}\left[\left[{{Q}}_{{k}}{}\left({X}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{i}}{}\left({Y}\right)\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right)$ (27)

As shown next, there are only two terms entering the integrand of ${S}_{2}$ with two external legs. They both have one loop, and correspond to the self-energy of the photon and the electron (page 218 of ref.) and are given by

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__QED},\mathrm{numberofvertices}=2,\mathrm{numberoflegs}=2,\mathrm{diagrams}\right)$  ${\mathrm{%FeynmanIntegral}}{}\left({-}{2}{}{{\mathrm{α}}}^{{2}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~mu}}}}_{{j}{,}{k}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{i}{,}{l}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({{Q}}_{{k}}{}\left({X}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{i}}{}\left({Y}\right)\right)\right){,}\left[\left[{{Q}}_{{l}}{}\left({Y}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{j}}{}\left({X}\right)\right)\right]{,}\left[{{A}}_{{\mathrm{α}}}{}\left({Y}\right){,}{{A}}_{{\mathrm{μ}}}{}\left({X}\right)\right]\right]\right){-}{{\mathrm{α}}}^{{2}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~mu}}}}_{{j}{,}{k}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{i}{,}{l}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({{A}}_{{\mathrm{μ}}}{}\left({X}\right){,}{{A}}_{{\mathrm{α}}}{}\left({Y}\right)\right){,}\left[\left[{{Q}}_{{l}}{}\left({Y}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{j}}{}\left({X}\right)\right)\right]{,}\left[{{Q}}_{{k}}{}\left({X}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{i}}{}\left({Y}\right)\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]\right]\right)$ (28)

where the diagram with two spinor legs is the electron self-energy. The corresponding S-matrix elements in momentum representation (numberofvertices = 2 can be given, but in this case is not necessary):

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__QED},\mathrm{incomingparticles}=\left[Q\right],\mathrm{outgoing}=\left[Q\right],\mathrm{numberofloops}=1,\mathrm{diagrams}\right)$ ${-}{\mathrm{%FeynmanIntegral}}{}\left(\frac{{1}}{{8}}{}\frac{{{{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{Uspinor}}}_{{Q}}}_{{i}}{}\left(\mathrm{P__1_}\right){}{\mathrm{conjugate}}{}\left({{{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{Uspinor}}}_{{Q}}}_{{l}}{}\left(\mathrm{P__2_}\right)\right){}{{\mathrm{α}}}^{{2}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{l}{,}{m}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~nu}}}}_{{n}{,}{i}}{}\left(\left({\mathrm{P__1}}_{{\mathrm{β}}}{+}{\mathrm{p__2}}_{{\mathrm{β}}}\right){}{{{\mathrm{Dgamma}}}_{{\mathrm{~beta}}}}_{{m}{,}{n}}{+}\mathrm{m__Q}{}{{\mathrm{KroneckerDelta}}}_{{m}{,}{n}}\right){}\left({-}{{\mathrm{g_}}}_{{\mathrm{α}}{,}{\mathrm{ν}}}{+}\frac{{\mathrm{p__2}}_{{\mathrm{ν}}}{}{\mathrm{p__2}}_{{\mathrm{α}}}}{{\mathrm{m__A}}^{{2}}}\right){}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right)}{{{\mathrm{π}}}^{{3}}{}\left({\left(\mathrm{P__1}{+}\mathrm{p__2}\right)}^{{2}}{-}{\mathrm{m__Q}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__2}}^{{2}}{-}{\mathrm{m__A}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__2}\right]\right]\right)$ (29)

In this result we see the propagator of the field ${A}_{\mathrm{\mu }}$ with a mass ${m}_{A}$. To indicate that this field is massless use

 > $\mathrm{Setup}\left(\mathrm{massless}=A\right)$
 $\mathrm{* Partial match of \text{'}}\mathrm{massless}\mathrm{\text{'} against keyword \text{'}}\mathrm{masslessfields}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{masslessfields}}{=}\left\{{A}\right\}\right]$ (30)

Now the propagator for ${A}_{\mathrm{\mu }}$ is the one of a massless vector field:

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__QED},\mathrm{incomingparticles}=\left[Q\right],\mathrm{outgoing}=\left[Q\right],\mathrm{numberofloops}=1\right)$
 ${-}{\mathrm{%FeynmanIntegral}}{}\left({-}\frac{{1}}{{8}}{}\frac{{{{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{Uspinor}}}_{{Q}}}_{{i}}{}\left(\mathrm{P__1_}\right){}{\mathrm{conjugate}}{}\left({{{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{Uspinor}}}_{{Q}}}_{{l}}{}\left(\mathrm{P__2_}\right)\right){}{{\mathrm{α}}}^{{2}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{l}{,}{m}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~nu}}}}_{{n}{,}{i}}{}\left(\left({\mathrm{P__1}}_{{\mathrm{β}}}{+}{\mathrm{p__2}}_{{\mathrm{β}}}\right){}{{{\mathrm{Dgamma}}}_{{\mathrm{~beta}}}}_{{m}{,}{n}}{+}\mathrm{m__Q}{}{{\mathrm{KroneckerDelta}}}_{{m}{,}{n}}\right){}{{\mathrm{g_}}}_{{\mathrm{α}}{,}{\mathrm{ν}}}{}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right)}{{{\mathrm{π}}}^{{3}}{}\left({\left(\mathrm{P__1}{+}\mathrm{p__2}\right)}^{{2}}{-}{\mathrm{m__Q}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__2}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__2}\right]\right]\right)$ (31)
 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__QED},\mathrm{incomingparticles}=\left[A\right],\mathrm{outgoing}=\left[A\right],\mathrm{numberofloops}=1,\mathrm{diagrams}\right)$ ${-}{\mathrm{%FeynmanIntegral}}{}\left(\frac{{1}}{{16}}{}\frac{{{{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{PolarizationVector}}}_{{A}}}_{{\mathrm{ν}}}{}\left(\mathrm{P__1_}\right){}{\mathrm{conjugate}}{}\left({{{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{PolarizationVector}}}_{{A}}}_{{\mathrm{α}}}{}\left(\mathrm{P__2_}\right)\right){}{{\mathrm{α}}}^{{2}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{n}{,}{i}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~nu}}}}_{{m}{,}{l}}{}\left(\left({\mathrm{P__1}}_{{\mathrm{β}}}{+}{\mathrm{p__2}}_{{\mathrm{β}}}\right){}{{{\mathrm{Dgamma}}}_{{\mathrm{~beta}}}}_{{i}{,}{m}}{+}\mathrm{m__Q}{}{{\mathrm{KroneckerDelta}}}_{{i}{,}{m}}\right){}\left(\mathrm{m__Q}{}{{\mathrm{KroneckerDelta}}}_{{l}{,}{n}}{+}{\mathrm{p__2}}_{{\mathrm{κ}}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~kappa}}}}_{{l}{,}{n}}\right){}{\mathrm{Dirac}}{}\left({-}\mathrm{P__2}{+}\mathrm{P__1}\right)}{{{\mathrm{π}}}^{{3}}{}\sqrt{\mathrm{E__1}{}\mathrm{E__2}}{}\left({\left(\mathrm{P__1}{+}\mathrm{p__2}\right)}^{{2}}{-}{\mathrm{m__Q}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right){}\left({\mathrm{p__2}}^{{2}}{-}{\mathrm{m__Q}}^{{2}}{+}{I}{}{\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ε}}\right)}{,}\left[\left[\mathrm{p__2}\right]\right]\right)$ (32)

In the two self-energy expressions above we see the u-spinor ${\mathbit{u}}_{Q}$ and the polarization vector ${\mathbf{ϵ}}_{A}$.

Compute ${S}_{3}$ for this model, keeping only the terms with 3 external legs

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__QED},\mathrm{numberofvertices}=3,\mathrm{numberoflegs}=3,\mathrm{diagrams}\right)$   ${\mathrm{%FeynmanIntegral}}{}\left({-}{6}{}{{\mathrm{α}}}^{{3}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~mu}}}}_{{j}{,}{k}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{i}{,}{l}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~beta}}}}_{{m}{,}{n}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({{A}}_{{\mathrm{μ}}}{}\left({X}\right){,}{{Q}}_{{l}}{}\left({Y}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{m}}{}\left({Z}\right)\right)\right){,}\left[\left[{{Q}}_{{n}}{}\left({Z}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{j}}{}\left({X}\right)\right)\right]{,}\left[{{Q}}_{{k}}{}\left({X}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{i}}{}\left({Y}\right)\right)\right]{,}\left[{{A}}_{{\mathrm{α}}}{}\left({Y}\right){,}{{A}}_{{\mathrm{β}}}{}\left({Z}\right)\right]\right]\right){-}{{\mathrm{α}}}^{{3}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~mu}}}}_{{j}{,}{k}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{i}{,}{l}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~beta}}}}_{{m}{,}{n}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({{A}}_{{\mathrm{μ}}}{}\left({X}\right){,}{{A}}_{{\mathrm{α}}}{}\left({Y}\right){,}{{A}}_{{\mathrm{β}}}{}\left({Z}\right)\right){,}\left[\left[{{Q}}_{{l}}{}\left({Y}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{j}}{}\left({X}\right)\right)\right]{,}\left[{{Q}}_{{k}}{}\left({X}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{m}}{}\left({Z}\right)\right)\right]{,}\left[{{Q}}_{{n}}{}\left({Z}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{i}}{}\left({Y}\right)\right)\right]\right]\right){-}{{\mathrm{α}}}^{{3}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~mu}}}}_{{j}{,}{k}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~alpha}}}}_{{i}{,}{l}}{}{{{\mathrm{Dgamma}}}_{{\mathrm{~beta}}}}_{{m}{,}{n}}{}{\mathrm{_GF}}{}\left({\mathrm{_NP}}{}\left({{A}}_{{\mathrm{μ}}}{}\left({X}\right){,}{{A}}_{{\mathrm{α}}}{}\left({Y}\right){,}{{A}}_{{\mathrm{β}}}{}\left({Z}\right)\right){,}\left[\left[{{Q}}_{{n}}{}\left({Z}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{j}}{}\left({X}\right)\right)\right]{,}\left[{{Q}}_{{k}}{}\left({X}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{i}}{}\left({Y}\right)\right)\right]{,}\left[{{Q}}_{{l}}{}\left({Y}\right){,}{\mathrm{conjugate}}{}\left({{Q}}_{{m}}{}\left({Z}\right)\right)\right]\right]\right){,}\left[\left[{X}\right]{,}\left[{Y}\right]{,}\left[{Z}\right]\right]\right)$ (33)

Note the introduction of spacetime indices (covariant as subscripts and contravariant as superscripts) and spinor indices (all presented as subscripts) by FeynmanDiagrams; this preserves the summation convention for repeated indices by avoiding occurrences of indices more than once in each product. To verify for correctness, the indices and noncommutative products use Check.

 > $\mathrm{Check}\left(,'\mathrm{all}'\right)$
 $\mathrm{The products in the given expression check ok.}$
 $\mathrm{The repeated indices per term are:}\left[\left\{\mathrm{...}\right\}{,}\left\{\mathrm{...}\right\}{,}\mathrm{...}\right]\mathrm{, the free indices are:}\left\{\mathrm{...}\right\}$
 $\left[\left\{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{i}{,}{j}{,}{k}{,}{l}{,}{m}{,}{\mathrm{\mu }}{,}{n}\right\}{,}\left\{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{i}{,}{j}{,}{k}{,}{l}{,}{m}{,}{\mathrm{\mu }}{,}{n}\right\}{,}\left\{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{i}{,}{j}{,}{k}{,}{l}{,}{m}{,}{\mathrm{\mu }}{,}{n}\right\}\right]{,}{\varnothing }$ (34)

The transition probability density corresponding to the term with three external vector-boson legs

 > $\mathrm{FeynmanDiagrams}\left(\mathit{L__QED},\mathrm{incomingparticles}=\left[A\right],\mathrm{outgoingparticles}=\left[A,A\right],\mathrm{numberofloops}=1,\mathrm{diagrams},\mathrm{output}=\mathrm{probabilitydensity}\right)$ ${\mathrm{Physics}}{:-}{\mathrm{FeynmanDiagrams}}{:-}{\mathrm{ProbabilityDensity}}{}\left(\frac{{1}}{{2}}\right)$