FeynmanDiagrams - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Physics : FeynmanDiagrams

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




the interaction Lagrangian depending on quantum fields



order = m : m indicates the truncation order of the expansion S=1+S1+S2+... 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 i, 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+S1+S2+... 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 dp1,...,dpr. That transition probability density is constructed using f|S|i and the formula (13) of Sec.21 of ref.[1]


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 Sn, the nth term of the expansion of S in coordinates representation, or just f|Sn|i in momentum representation. The Feynman diagrams of Sn 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+S1+S2+.... 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+S1+S2+... 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,  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 [1]; 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 X,Y,..., representing the spacetime points used as dummy integration variables in each Sn. 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



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



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.[1]. This exponential can be expanded as






and TLX1,...,LXn is the time-ordered product of n interaction Lagrangians evaluated at different points. Note the factor inn! included in the definition of Sn used in this page.

Coordinates representation


The default output of FeynmanDiagrams(L(X)) is thus S=1+S1+S2+S3 in coordinates representation, S truncated by default at order = 3. The expansion of the time-ordered product entering the integrand of each Sn (herein called the expansion of Sn) is computed using Wick's theorems, and Sn itself, including the factor inn!, is expressed using the FeynmanIntegral command.


The expansion of Sn 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 Sn corresponds to a Feynman diagram with n vertices (the number n of interaction Lagrangians in Sn). 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 Sn being returned includes all the possible configurations of external legs.

The algebraic structure of the output in coordinates representation


Each Sn is represented in the output of FeynmanDiagrams by a FeynmanIntegral, whose integrand is of the form:



where k is a finite integer depending on n and the interaction Lagrangian, sfj are the symmetry factors, and _GFj (to each one corresponds a Feynman diagram) are functions of name _GF, of one or two arguments, of the form:






The p,q,r,s,t,u identify fields entering the interaction Lagrangian. The first case (_GF function of only one argument) corresponds to the tree-level terms (so no propagators) appearing in Sn, with the argument of _GF being (just) a function of name _NP, representing the normal product of the (unpaired) fields fi,fj,. Each of these fields represents an external leg of the corresponding Feynman diagram. In the second case (_GF function of two arguments), the second argument is a list of lists, where each internal list fk,fl 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 Sn 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 Sn in coordinates representation involves n (dummy) integration variables Xn 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 Xn. 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, _NPφX,φY is displayed as φXφY and _GF_NPφX,φY,φX,φY,... is displayed as φXφYφX,φY..., the product of the time-ordered normal product (the _NP... function) with the lists representing the propagators (second argument of the _GFn function).

Momentum representation


The transition probability for a process with initial and final states i and f in momentum representation is given by the square of the scattering matrix elements f|S|i. The states i and f, 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.[1], "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 i have different sets of quantum numbers, and the r particles in f 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.[1]), of the form



The δ (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 Fpi,pf, 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 3p1 ...d 3pr. That probability density is constructed using the square of the scattering matrix element f|S|i2, as shown in formula (13) of sec. 21.1 of ref.[1]:

dw=2π3s4n__1...n__sFpi,pf2δi=1spif=1rpf d 3p1 ...d 3pr


where each n1...ns represents the particle density of each of the s particles in the initial state i, and for an interpretation of the square of the δ factor that appears in f|S|i2 see sec. 64 of ref.[3]. In order to get the number of scattered particles per unit of time and volume that happen in the final momentum region Δp1 .. Δpr, the probability density 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 Sm 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.[1], "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.[4].

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 Pn 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 pn where n is an integer. The momentum assignation Pn follows the order of the incoming and outgoing particles. For example if you have incomingparticles=φ,η and outgoingparticles=θ,ψ the momenta are assigned as follows: φP1, ηP2 , θP3 and ψP4.


The energy of each incoming and outgoing particle (0th component of each Pnμ) entering the output f|S|i is expressed using literal subscripts E__n (prefixed with the Capital letter E), displayed as En where n is an integer.


When computing beyond tree-level, the propagators of fields - say φ - that appear within Feynman integrals include their masses, expressed using literal subscripts, say as m__phi, prefixed with the letter m, displayed as mφ. To indicate that a vector field is massless use Setup, for instance as in Setupmassless=A.


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 Pnμ in the Dirac δ 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 λφ4 model, the input / output is presented as





and say for the λφ3 model, f|S|i with one loop,



9λ2δP2+P18π3E__1E__2iεmφ2+p22P1p22mφ2+iεⅆp__2 4



9λ2δP2ββ+P1ββ8π3E__1E__2iεmφ2+p2μp2μμP1αp2αP1ααp2ααmφ2+iεⅆp__2 4


The infinitesimal ε 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 u, v and ϵ (see ref.[2] 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 CX, 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 Setupmassless=A.


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 Sn 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 Sn). When additional labels are necessary, they are all of the form Xn, 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 fX,gY only, or all the propagators of the form f,g, which would include as well fX,gX and fY,gY.


Load the package, set three coordinate systems and set φ to represent a quantum operator



Systems of spacetime coordinates are:X=x1,x2,x3,x4,Y=y1,y2,y3,y4,Z=z1,z2,z3,z4




Let L be the interaction Lagrangian




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




To compute only the tree-level terms of this result use numberofloops = 0. To produce the diagrams together with the algebraic expression of Streelevel, pass also the optional argument diagrams




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




To compute the S-matrix element in momentum representation corresponding to the term with 6 external legs, change in the input above φ,φ by φ,φ,φ, and to get the element corresponding to 8 external legs use φ,φ,φ,φ. The following computes the expansion of S up to order = 3, only the terms corresponding to diagrams with two external legs




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




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




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




A corresponding S-matrix element in momentum representation:




To compute only one term, say S2, and for instance including terms with tadpoles use the options numberofvertices = 2 and includetadpoles




Consider an interaction Lagrangian involving two fields. To indicate that η also represents a quantum field operator (φ got set as quantum operator at the beginning), use Setup.







In the expansion of S, there are no terms with one external leg φ and another η, that would be represented as a normal product of unpaired fields _NPφ,η




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













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




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




Compute the terms entering the integrand of S3, having four external legs (normal ordered products involving four fields). For the interaction Lagrangian L2, the normal products of unpaired fields in S3 only involve the φ field




To get the corresponding S-matrix element in momentum representation, replace numberoflegs=4 by a process with the same four legs, for example incoming=φ,outgoing=φ,φ,φ and numberofloops=2. Considering S2 instead, you also get normal products of η fields




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




Following is an example with the interaction Lagrangian of Quantum Electrodynamics (QED). First, define the vector field Aμ.


Defined objects with tensor properties



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.


* Partial match of 'op' against keyword 'quantumoperators'




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 Qj&conjugate0;




Compute S2, only the terms with 4 external legs, so all the corresponding graphs have no loops, and display the diagrams




As shown next, there are only two terms entering the integrand of S2 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.[1]) and are given by




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):




In this result we see the propagator of the field Aμ with a mass mA. To indicate that this field is massless use


* Partial match of 'massless' against keyword 'masslessfields'




Now the propagator for Aμ is the one of a massless vector field:







In the two self-energy expressions above we see the u-spinor uQ and the polarization vector ϵA.

Compute S3 for this model, keeping only the terms with 3 external legs




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.


The products in the given expression check ok.

The repeated indices per term are: ...,...,..., the free indices are: ...



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