Physics for Maple 2021 - 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 : Updates : Physics for Maple 2021


Maple provides a state-of-the-art environment for algebraic computations in Physics, with emphasis on ensuring that the computational experience is as natural as possible. The theme of the Physics project for Maple 2021 has been the consolidation of the functionality introduced in previous releases, together with significant enhancements in the areas of Particle Physics, Quantum Mechanics, Tensor computations and General Relativity.

As part of its commitment to providing the best possible computational environment in Physics, Maplesoft launched a Maple Physics: Research and Development website in 2014, which enabled users to download research versions of the package, ask questions, and provide feedback. The results from this accelerated exchange have been incorporated into the Physics package in Maple 2021. The presentation below illustrates both the novelties and the kind of mathematical formulations that can now be performed.


Feynman Diagrams and Feynman Integrals

Simplification of products of Dirac matrices

Manipulation and simplification of expressions involving non-commutative tensor operators

Functional differentiation and differentiation of spinors

New commands ToCovariant and ToContravariant

Weyl scalars, Petrov types and canonical forms for tetrads

Documentation advanced examples


See Also

Feynman Diagrams and Feynman Integrals

Feynman Diagrams are the cornerstone of calculations in particle physics (collisions involving from the proton to the Higgs boson), for example at the CERN. As an introduction for people not working in the area, see "Why Feynman Diagrams are so important". In connection, Maple 2020 presented a full rewriting of the FeynmanDiagrams command including a myriad of new capabilities.

In Maple 2021, in addition, we implemented:


New options in the FeynmanDiagrams command, to handle the typical situation where one wants to study scattering amplitudes using different gauge choices for the fields' propagators; or a generic form of a propagator, useful to perform the computation with models that require a non-standard form for them; or request that the propagators used are displayed on the screen above the returned result; or computing the amplitudes without external legs normalization factors.


A new FeynmanIntegral module to evaluate the Feynman integrals that appear in the output of the FeynmanDiagrams command, including package's commands for the basic steps involved, that is: to Parametrize or to Evaluate in one go, with different options, all the Feynman integrals found in an expression typically returned by FeynmanDiagrams.

Examples - new FeynmanDiagrams options

restart; withPhysics:

New: you can set a vector and and a mixed spacetime-spinor field (i.e. 3/2 spinor). In this example, indicate also that Aμ is massless

Setupcoordinates=X,spinorindices=lowercaselatin,anticommutativeprefix=Q,op=A,Q, massless = A,tensors=Qμ,a, Aμ

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

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

Systems of spacetime coordinates are:X=x1,x2,x3,x4




Now write down a minimal interaction Lagrangian, similar but different from QED, for testing purposes


Compute the amplitude for a process where there are 1 incoming and 1 outgoing particles of the same Q kind; this is the self-energy diagram:




In this result, there are two things that are new in FeynmanDiagrams:

a) it can now handle 3/2 spinor fields, with 1 spacetime and 1 spinor indices;

b) it is now setting the gauge for the massless field Aμ in a way that can be changed.


To see all that, we implemented a new userinfo message, so that one can see, exactly, the form of the propagator being used. Set the corresponding infolevel as follows and run the computation again (skip producing the diagram's drawing)

infolevelFeynmanDiagrams  3:


Propagator used: ΔAλp__2,Aτp__2=−Igλ,τp__22+Iε

Propagator used: ΔQκ,eP__1+p__2,Q1σ,fP__1p__2=Igκ,σP__1κ+p__2κP__1σ+p__2σm__Q2P__1υ+p__2υγυυe,f+m__Qδe,f+P__1κ+p__2κδe,g3m__Q+γκe,g3P__1υ+p__2υγυυg,hm__Qδg,hP__1σ+p__2σδf,hm__Q+γσh,fP__1+p__22m__Q2+Iε



In the user-information presented above in black, we see the form used for the propagator ΔQκ,eP__1+p__2,Q1σ,fP__1p__2 of the 3/2 spin Qμ,a field, and ΔAλp__2,Aτp__2 for the Aμ field including the gauge used for it. For that, FeynmanDiagrams is now using a gauge term of the form 1ξAp__2λp__2τp__22+Iε where ξA is set to 1, 0,  or to ξA itself,  respectively for the Feynman, Landau unitary and arbitrary gauges. By default the Feynman and unitary gauges are respectively used for massless and massive fields. For example, to run the same computation using the Landau gauge, you can use the new propagatorgauge option:

FeynmanDiagramsL,incomingparticles=Q,outgoing=Q,numberofloops=1, gauge=Landau

* Partial match of 'gauge' against keyword 'propagatorgauge'

Propagator used: ΔAλp__2,Aτp__2=Igλ,τ+p__2λp__2τp__22+Iεp__22+Iε

Propagator used: ΔQκ,eP__1+p__2,Q1σ,fP__1p__2=Igκ,σP__1κ+p__2κP__1σ+p__2σP__1+p__22+IεP__1υ+p__2υγυυe,f+m__Qδe,f+P__1κ+p__2κδe,g3m__Q+γκe,g3P__1υ+p__2υγυυg,hm__Qδg,hP__1σ+p__2σδf,hm__Q+γσh,fP__1+p__22m__Q2+Iε



In the user-information presented above you see the different form used for the propagator ΔAλp__2,Aτp__2.

The arbitrary value of propagatorgauge option makes the value of ξA remain unset, so that you can set the gauge afterwards, possibly differently for each field, depending on convenience

FeynmanDiagramsL,incomingparticles=Q,outgoing=Q,numberofloops=1, gauge=arbitrary

* Partial match of 'gauge' against keyword 'propagatorgauge'

Propagator used: ΔAλp__2,Aτp__2=Igλ,τ+1ξAp__2λp__2τp__22+Iεp__22+Iε

Propagator used: ΔQκ,eP__1+p__2,Q1σ,fP__1p__2=Igκ,σ1ξQP__1κ+p__2κP__1σ+p__2σP__1+p__22ξQm__Q2+IεP__1υ+p__2υγυυe,f+m__Qδe,f+P__1κ+p__2κδe,g3m__Q+γκe,g3P__1υ+p__2υγυυg,hm__Qδg,hP__1σ+p__2σδf,hm__Q+γσh,fP__1+p__22m__Q2+Iε



Note in the result above the occurrence of gauge fixing terms ξA and ξQ for each of the fields. These are implemented as FeynmanDiagrams:-xifield where field is any of A or Q. For example, you can now substitute each of them according to convenience, e.g. set the Feynman gauge for the massless field Aμ and the Landau gauge for the Qμ,a field

subsFeynmanDiagrams:-xiA=1, FeynmanDiagrams:-xiQ=0, 




An extra level of flexibility is given by the new option usepropagators which, when set to false, makes FeynmanDiagrams return the abstract form ΔQκ,eP__1+p__2,Q1σ,fP__1p__2 instead of any specific form for the propagator

FeynmanDiagramsL,incomingparticles=Q,outgoing=Q,numberofloops=1, usepropagators = false



In this result, ΔAλp__2,Aτp__2is implemented as a new FeynmanDiagrams:-Propagator function; there are two occurrences




Finally, the convention is to add a normalization factor for each external leg (incoming or outgoing particle). That external normalization depends on the spin of the field [3]. For example, in the result (7) above, that is the origin of the factor 8π3 in the denominator. In some contexts, however, it is usual or convenient to compute without these normalization factors. For that purpose you can use the new option, externalnormalization = false 

FeynmanDiagramsL,incomingparticles=Q,outgoing=Q,numberofloops=1, usepropagators = false,externalnormalization = false



Examples - new FeynmanIntegral module



Systems of spacetime coordinates are:X=x1,x2,x3,x4




Let L be the interaction Lagrangian




A process with one incoming and one outgoing particle a 1-loop




Load the package




Parametrize the Feynman integral (12) using Feynman parameters




The Evaluate command is used to evaluate Feynman integrals. In the following input, we request for the momentum integration to not be performed, receiving, basically, the result above but with the integrations over the Feynman parameters swapped with the one over momentum




By default, however, Evaluate will perform the momentum integration ⅆp__2 4 but in in D2ϵ dimensions, so that its divergences get expressed as poles of Gamma functions, and also the Feynman parameters integration, returning a result in terms of the dimensional parameter ϵ 




To see how this integral can be evaluated step by step until arriving at this result, see the help page Evaluate. The dimensional parameter is represented by FeynmanIntegral:-varepsilon and, because the FeynmanIntegral package is loaded, you can refer to it directly as varepsilon. To expand the dimensional parameter, keeping terms up to Oϵ, use




The same integral can be computed using alpha parameters

Evaluate,parameters = alpha

* Partial match of 'parameters' against keyword 'kindofparameters'



The Parametrize also work using the α-parameters

Parametrize,kindofparameters = alpha





[1] Smirnov, V.A., Feynman Integral Calculus. Springer, 2006.


[2] Weinzierl, S., The Art of Computing Loop Integrals,


[3] Weinberg, S., The Quantum Theory Of Fields. Cambridge University Press, 2005.


[4] Bogoliubov, N.N., and Shirkov, D.V. Quantum Fields. Benjamin Cummings, 1982.

Simplification of products of Dirac matrices

The simplification of products of Dirac matrices got stronger in Maple 2021 in several ways. As an example, set σμ,ν as a quantum operator (noncommutative) tensor proportional to the commutator of Dirac matrices


Setupop = sigma, tensors=sigmaμ,ν

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




Enter the definition of σμ,νμ,ν

Defineσμ,νμ,ν=I γμμγννγννγμμ2

Defined objects with tensor properties



Consider proving the following value for the commutator σμ,νμ,ν,σα,βα,β

Commutatorσμ,νμ,ν,σα,βα,β = 2 Igν,αν,ασμ,βμ,βgμ,αμ,ασν,βν,β+gμ,βμ,βσν,αν,αgν,βν,βσμ,αμ,α



Insert σ's definition in this expression







Expand the commutator and all the products




Proving that, in this expression, the left-hand side is equal to the right-hand side involves the simplification of sums of products of four (on the left-hand side) and of two (on the right-hand side) Dirac matrices taking into account the algebra rules they satisfy




In Maple 2021, this simplification can be performed in one go by taking the left-hand side minus the right-hand side and sending that to the simplifier




This simplification can now also be performed in steps. Take the commutator on the left-hand side of (22)










Although this intermediate result (30) involves products of four Dirac matrices, their combination is such that the result can be expressed in terms of products of only two of matrices




This result is different from the expanded form of the right-hand side of (22)




The Simplifier, however, can not only prove that (31) - (32) is equal to zero but can also depart from (32) and arrive at (31)




That is so because, in Maple 2021, a new normal form for the ordering in products of noncommutative operators got implemented. The computation above also indicates that there are two different kinds of simplifications at work here: one that maps a sum or products of four Dirac matrices into simpler products of also four matrices, and another one that maps onto a sum of products of two Dirac matrices. To see that, consider again the expanded form (30) of the commutator σμ,νμ,ν,σα,βα,β



The default approach maps the sum of products of four Dirac matrices into products of two Dirac matrices using the algebra rules they satisfy




One can also use those algebra rules to only sort the products with some preferred ordering as pivot (new option in Simplify), resulting in products of also four matrices




This result is not just an expansion of (34),




but the result of sorting first all the products in (34), using the algebra rules %AntiCommutatorDgammaμ,Dgammaν=2gμ,ν and only then expand







Proving identities is a key - sometimes, as in this case related to Dirac matrices - non-trivial operation. Another way of verifying identities like (22) is to compute all the components of the tensorial equation,

Expand@lhs  rhs  



each of which is, in turn, a 4 x 4 matrix. If the identity is true, for each value of each of the four spacetime free indices α,β,μ,ν, we expect that, performing all the matricial operations, we get for result a matrix 4 x 4 matrix of zeros. That computation can be performed with TensorArray using its option performmatrixoperations

TensorArray, performmatrixoperations, output = setofequations



So the identity is true. Note that 44=256 resulting matrices. This computation for each value of the four spacetime indices can be displayed so compactly because of using the option output = setofequations, and repeated elements in a set are automatically removed. Thus, the 256 matrices of zeros, each of which is equal to 0, appear as only one.

As a more challenging computation, less of a black box, one can express everything in (40) in terms of Dirac matrices




For each of the four values of each if the four indices α,β,μ,ν, use now the underlying Dirac matrices




and compute all of the 4 x 4 x 4 x 4 matrices that result from multiplying the four and two Dirac matrices in each term of (42) (that is what TensorArray did, internally, to compute the result (41))

TensorArray, performmatrixoperations, output = setofequations



Manipulation and simplification of expressions involving non-commutative tensor operators

Significant improvements under the hood happened regarding of simplification in the presence of non-commutative tensor operators. The simplifications need to take into account commutator rules, symmetries under permutation of indices of tensorial subexpressions, and use Einstein's sum rule for repeated indices. Related to that, Maple 2021 includes relevant enhancements in the Simplify, SubstituteTensor and SortProducts commands.

With these developments in place, it is now possible, for example, to systematically derive, step-by-step, the SO(4) symmetry of the hydrogen atom and its spectrum entering only the main definition formulas, followed by only simplification commands, and without using previous knowledge of the result. A presentation of this work is now in the arXiv and is submitted for publication in the journal Computer Physics Communications as a novel way of tackling these kinds of problems using computers.

In brief, deriving the SO(4) symmetry of the hydrogen atom is about deriving the following four commutator rules between its Hamiltonian H, the angular momentum tensor Lm and the Runge-Lenz tensor Zn,












2  m__eH εm,n,oLo

where for hermiticity purpose Lm is defined in quantum mechanics as the symmetrized form

Z=12 m__e L×pp×L+κ rr

Since H commutes with both L and Z, defining


these commutation rules can be rewritten as










This set constitutes the Lie algebra of the SO(4) group. As an illustration of the computational capabilities in Maple 2021, in what follows we derive the first two of these commutators, H,Ln=H,Zn=0, departing from basic principles and followed by applying only a few simplification commands to equation labels.

Setting the problem

Formulating the problem requires loading the Physics package, and we set the imaginary unit to be represented by a lowercase Latin i letter instead of the default uppercase I.

restart; withPhysics:interfaceimaginaryunit = i:

The context for this problem is Cartesian coordinates and a 3D Euclidean space where all of ,κ,m__e are real objects. We chose lowercase letters to represent tensor indices and the use of automatic simplification (i.e., automatically simplify the size of everything being displayed)

Setupcoordinates = cartesian, realobjects=ℏ,κ,m__e,automaticsimplification=true,dimension = 3, metric=Euclidean,spacetimeindices = lowercaselatin, quiet



Next, we set the quantum Hermitian operators (not Z, we derive that property for it further below) and related commutators:


the dimensionless potential  V = 1r is assumed to commute with position, not with momentum - the commutation rule with pk is derived further below;


the commutator rules between position Xn on the one hand, and linear pk and angular momentum Lk on the other hand, are the departure point, entered using the inert form of the Commutator command. Tensors are indexed using the standard Maple notation for indexation, [].

Setupquantumoperators=Z,hermitianoperators = V,H,L,X,p,algebrarules=     %Commutatorpk,pl=0,     %CommutatorXk,pl=ℏg_k,l,     %CommutatorLj, Lk = LeviCivitaj, k, nLn,