A Guide to Mathematica Packages for Physicists

Yi-Zhuang You, UCSD

This document provides a guide to the bundle of Mathematica packages for physicists. The bundle is available in the Github repository.

Introduction

Content

Package

PauliAlgebra: symbolic handling the algebra and representation of Pauli operators

LoopIntegrate: performing loop integration in quantum field theory (with dimension regularization)

MatsubaraSum: performing Matsubara summation analytically

DiagramEditor: an interactive editor of Feynman diagrams (no diagrammatic evaluation)

Themes: a self-made plot theme for Mathematica, called “Academic”

Toolkit: miscellaneous functions, including BZPlot for plotting band structure, tTr for tensor network contraction, ComplexMatrixPlot for complex matrix visualization, Pf for matrix Pfaffian

Stylesheet

CMU Article: Mathematica style sheet based on Computer Modern Unicode fonts (the fonts need to be installed separately to the operating system)

FrontEnd Configuration

Installation Instruction

unzip this repository in a folder,

open install.m in Mathematica,

click the Run Package button to the top right,

quit Mathematica and restart.

PauliAlgebra Package

Overview

?PauliAlgebra`*

Arithmetic

Symbolic Representation

(σ^0)=(({{1, 0}, {0, 1}})),(σ^1)=(({{0, 1}, {1, 0}})),(σ^2)=(({{0, -i}, {i, 0}})),(σ^3)=(({{1, 0}, {0, -1}})).

(σ^(a b c…))=(σ^a)⊗(σ^b)⊗(σ^c)⊗…,

Tensor Product

σ[a]⊗σ[b]⊗σ[c]

Dot Product

σ[2]·σ[3]

σ[1]·σ[1]

TableForm[Table[σ[i]·σ[j],{i,0,3},{j,0,3}],
TableHeadings->{Table[σ[i],{i,0,3}],Table[σ[j],{j,0,3}]}]

Matrix Representation

σ[1]//Represent

σ[1,2]//Represent//MatrixForm

Represent[a σ[1,1]+b σ[3,3]]

%//MatrixForm

Abstract[%]

Abstract[DiagonalMatrix[{0,0,0,1}]]

Dimension

Qubit[σ[1,2,3]]

σ0[3]

σ0[σ[1,0,0]+σ[2,0,0]]

Distributive Properties

(σ[1]+2σ[2])⊗(σ[1]-σ[2])

(σ[1]+2σ[2])·(σ[1]-σ[2])

Conjugation

Complex conjugation A→(SuperStar[A])

σConjugate[σ[0]+σ[2]+I σ[3]]

Transpose A→Aᵀ

σTranspose[σ[0]+σ[2]+I σ[3]]

Hermitian conjugate A→(SuperDagger[A])

σHermitian[σ[0]+σ[2]+I σ[3]]

Trace

σTr[σ[0,0]+σ[3,3]]

Operator Algebra

Action Space

A=(∑_([μ]))(Subscript[A, [μ]])(σ^([μ])),

(Subscript[A, [μ]])=(1/D)Tr A (σ^([μ])),

A→(Ket[A])=(∑_([μ]))(Subscript[A, [μ]])(Ket[[μ]]).

A B=(∑_([μ],[ν],[λ]))(Subscript[c, [λ]]^([μ][ν]))(Subscript[A, [μ]])(Subscript[B, [ν]])(σ^([λ])).

A→𝔸=(∑_([μ],[ν],[λ]))(Ket[[λ]])(Subscript[c, [λ]]^([μ][ν]))(Subscript[A, [μ]])(Bra[[ν]]),

MatrixForm/@ActionSpace[a σ[1,1,0]+b σ[1,0,0]+c σ[0,1,0]]

Operator Power

σPower[a σ[1,1]+b σ[1,0]+c σ[0,1],3]

σPower[a σ[0]+b σ[3],-4]

The package uses divide-and-conquer algorithm for fast computation of high integer powers

Timing[σPower[a σ[1]+b σ[3],99]]

The inverse operator (A->(A^(-1))) can also be obtained via σInverse[A].

σInverse[a σ[0]+b σ[1]+c σ[2]+d σ[3]]

Singular matrix can not be inverted.

σInverse[σ[0]+σ[3]]

The square root operator (A->(A^(1/2))) can also be obtained via σSqrt[A].

σSqrt[a σ[0]+b σ[1]]

Determinant

σDet[b σ[1,3]+c σ[2,2]]

σDet[b σ[0,0,0,0,0,0,0,0,0]+c σ[1,3,2,2,3,1,3,2,1]]

Operator Exp and Log

Operator exponential (A->(e^A))

σExp[I ϕ σ[3,2]]

Operator logarithm (A→ln A)

σLog[(σ[0,0]+I Sqrt[3] σ[1,3])/2]

Clifford Algebra and Lie Algebra

Commutators

Commutator [A,B]

Commutator[σ[1],σ[3]]

Anticommutator {A,B}

Anticommutator[σ[3,1],σ[2,2]]

Clifford Algebra

Cl[n] provides a choice of the generators of complex Clifford algebra (Subscript[𝒞ℓ, n]).

∀i,j=1,…,n:{(Subscript[γ, i]),(Subscript[γ, j])}=2(Subscript[δ, i j]).

Cl[4]

Cl[p,q] provides a choice of the generators of real Clifford algebra (Subscript[𝒞ℓ, p,q]).

∀i,j=1,…,p+q:{(Subscript[γ, i]),(Subscript[γ, j])}=2(Subscript[δ, i j]),
∀i=1,…,p:(Subscript[γ, i])ᵀ=(Subscript[γ, i]),
∀i=p+1,…,p+q:(Subscript[γ, i])ᵀ=-(Subscript[γ, i]).

Cl[2,3]

Lie Algebra

LieAlgebra[{σ[1,2],σ[3,0]}]

Operator Transformations

Basis Gates

C4[A] gives (Subscript[C, 4]) rotation generated by a Pauli operator (σ^([μ]))

(e^(((i π)/4)(σ^([μ]))))≡((1+i (σ^([μ])))/(Sqrt[2])).

C4[σ[2,3]]

Swap[σ[0,…,0,_,0,…,0,_,0,…,0]] gives the swap operator that exchange the two qubits masked by _.

Swap[σ[0,_,0,_]]

Hadamard[σ[0,…,0,_,0,…,0]] gives the Hadamard gate acting on the single qubit masked by _.

Hadamard[σ[0,0,_,0]]

Controlled[σ[…,μ,_,ν,…]] gives the control gate, which implements (σ^([…μ0ν…])) controlled by the qubit masked by _.

Controlled[σ[_,1,2]]

Transformations

OrthogonalTransform[O] represents the orthogonal transformation

A->Oᵀ A O.

UnitaryTransform[O] represents the unitary transformation

A->(SuperDagger[O]) A O.

ConjugateTransform[O] represents the conjugate transformation

A->(O^(-1))A O.

OrthogonalTransform[C4[σ[2]]][σ[3]]

UnitaryTransform[Controlled[σ[_,1]]]/@{σ[1,0],σ[3,0],σ[0,1],σ[0,3]}

AssociationMap[UnitaryTransform[Hadamard[σ[_,0]]],{σ[3,1],σ[3,2],σ[3,3],σ[1,0],σ[2,0]}]

Pauli Operator Selection

Boolean Functions

Commutation relation

CommuteQ[σ[1,2],σ[3,1]]

AnticommuteQ[σ[1],σ[3]]

Symmetry condition

SymmetricQ[σ[2]]

AntisymmetricQ[σ[2]]

Pauli Select

σSelect[AnticommuteQ/@{σ[0,2],σ[1,1]}]

σSelect[{},2]

LoopIntegrate Package

Overview

?LoopIntegrate`*

Loop Integral and Dimensional Regularization

Loop Object

Loop[expr,{p1,…},D,x,nx]

expr - the integrand of the loop integral.

{p1,…} - a list of the integral variables, specifying the momenta to be integrated over.

D - the symbol for the spacetime dimension. Better not specify an integer dimension here, unless the integral does not need to be regularize. (One should use DimensionRegularize to properly calculate loop integrals in specific dimensions).

x - the symbol for Feynman parameter.

nx - the number of Feynman parameter.

Loop[1/(p^2+m^2),p]

Loop[Index[k+2p,μ]/((k+p)^2q^3),{p,q}]

Momentum Indexing

Index[k,μ]

Index[(k+2 p)/3,μ]

Index[{k1,k2,k3},2]

Feynman Parameterization

#->FeynmanParameterize[#]&@Loop[Index[k+q,μ]/((k+q)^2q^3),q]

FeynmanParameterize[Loop[1/((p^2+Δ1)^a1 (p^2+Δ2)^a2(p^2+Δ3)^a3),p]]

Loop Reduction

LoopReduce[Loop[1/(p^2+Δ)^a,p]]

LoopReduce[Loop[Index[p,μ]Index[p,ν]/(p^2+Δ)^a,p]]

LoopReduce[Loop[Index[p,μ]Index[p,ν]Index[p,λ]Index[p,κ]/(p^2+Δ)^a,p]]

LoopReduce[Loop[Index[p,μ]Index[p,ν]Index[p,λ]Index[p,κ]Index[p,ρ]Index[p,τ]/(p^2+Δ)^a,p]]

∫(((d^D)p)/(((2π))^D))(((Subscript[p, μ])(Subscript[p, μ]))/((((p^2)+Δ))^a))=∫(((d^D)p)/(((2π))^D))((p^2)/((((p^2)+Δ))^a)).

LoopReduce[Loop[Index[p,μ]Index[p,μ]/(p^2+Δ)^a,p]]

LoopReduce[Loop[p^2/(p^2+Δ)^a,p]]

FullSimplify[%-%%]

LoopReduce[Loop[1/((k+p)^2p),p]]

Dimensional Regularization

LoopReduce[Loop[1/(p^2+m^2),p,2]]

DimensionRegularize[LoopReduce[Loop[1/(p^2+m^2),p,D]],D->2]

Parameter Reduction

ParameterReduce[Loop[Indexed[x,1]^2Indexed[x,2],{},𝔇,x,2]]

Integrate[Indexed[x,1]^2Indexed[x,2]DiracDelta[Sum[Indexed[x,i],{i,2}]-1],x∈Rectangle[{0,0},{1,1}]]

ParameterReduce[DimensionRegularize[LoopReduce[Loop[Index[k+p,μ]/((k+p)^2p),p,D]],D->3]]

Function LoopIntegrate

LoopIntegrate[expr,p]
LoopIntegrate[expr,p,D]
LoopIntegrate[expr,{p1,p2,…},D]

FullSimplify@LoopIntegrate[Index[k+p,μ]/((k+p)^2p),p]

LoopIntegrate[Index[k+p,μ]/((k+p)^2p),p,3]

MatsubaraSum Package

Overview

?MatsubaraSum`*

Single Frequency Summation

Basic Summation

(1/β)(∑_z)f(z).

n∈ℤ:(Subscript[ω, n])=({{{, ({{((2π)/β)n, Bosonic,}, {((2π)/β)(n+(1/2)), Fermionic.}})}})

MatsubaraSum[1/(z-ϵ),z]

(Subscript[η, z])=({{{, ({{+1, if z∈Bosonic,}, {-1, if z∈Fermionic.}})}})

(Subscript[n, η])(ϵ)=(1/((e^(β ϵ))-η))=({{{, ({{(Subscript[n, B])(ϵ), η=+1,}, {(Subscript[n, F])(ϵ), η=-1.}})}})

MatsubaraSum[1/(z-ϵ)^2,z]

MatsubaraSum[1/(z-ϵ)^3,z]

MatsubaraSum[1/(z-ϵ)^4,z]

Specify Frequency Type

z∈Bosonic: asserts z=i (Subscript[ω, n]) to be bosonic,
z∈Fermionic: asserts z=i (Subscript[ω, n]) to be fermionic.

MatsubaraSum[1/(z-ϵ),z∈Fermionic]

MatsubaraSum[1/(z-ϵ),z∈Bosonic]

MatsubaraSum[1/(z-ϵ),z,Assumptions->z∈Fermionic]

MatsubaraSum[1/(z-ϵ),z,Assumptions->z∈Bosonic]

MatsubaraSum[1/(z1-ϵ1)/(z1-z2-ϵ2),z1∈Fermionic,Assumptions->z2∈Bosonic]

Multiple Frequency Summation

MatsubaraSum[1/(z1-ϵ1)/(z2-ϵ2),z1,z2]

MatsubaraSum[1/(z1-ϵ1)/(z2-ϵ2),z1∈Bosonic,z2∈Fermionic]

MatsubaraSum[1/(z1-ϵ1)/(z2-ϵ2)/(z1+z2-z-ϵ3),z1∈Fermionic,z2∈Fermionic,Assumptions->z∈Fermionic]

Miscellaneous

Simplify Distribution Functions

(Subscript[n, η])(-x)=-η-(Subscript[n, η])(x),
(Subscript[n, η]^((k)))(-x)=-(((-1))^k)(Subscript[n, η]^((k)))(x),
2(Subscript[n, B])(x)(Subscript[n, F])(x)=(Subscript[n, B])(x)-(Subscript[n, F])(x).

FullSimplify[1-(Subscript[n, F])[-ϵ]]

FullSimplify[(1+2(Subscript[n, B])[ϵ])(1-2(Subscript[n, F])[ϵ])]

Assuming[z1∈Bosonic&&z2∈Fermionic,(Subscript[n, (Subscript[η, z1])])[ϵ1] (Subscript[n, (Subscript[η, z2])])[ϵ2] (Subscript[η, z1]) (Subscript[η, z2])]

Assuming[z∈Fermionic,(Subscript[n, F])[z+ϵ]]

Zero Temperature Limit

Θ(ϵ)=({{{, ({{1, ϵ>0,}, {0, ϵ<0.}})}})

ZeroTemperatureLimit[(Subscript[n, F])[ϵ]]

ZeroTemperatureLimit[(Subscript[n, B])[ϵ]]

Convergence Control

(1/β)(∑_z)f(z)(e^(-δ z)).

Table[FullSimplify@MatsubaraSum[1/(z-ϵ),z∈Fermionic,ControlledPlane->cp],{cp,{Right,Left,All}}]

Table[FullSimplify@MatsubaraSum[1/(z-ϵ)^2,z∈Fermionic,ControlledPlane->cp],{cp,{Right,Left,All}}]