"Quantum electrodynamics"

clear

-- This script does a few of the exercises from Feynman's book "Quantum Electrodynamics."

-- Define the spacetime metric (for multiplying spacetime vectors).

metric = ((-1, 0, 0, 0),
          ( 0,-1, 0, 0),
          ( 0, 0,-1, 0),
          ( 0, 0, 0, 1))

-- Define I, the identity matrix.

I = ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1))

-- Define the gamma matrices.

gammax = (( 0, 0, 0, 1),
          ( 0, 0, 1, 0),
          ( 0,-1, 0, 0),
          (-1, 0, 0, 0))

gammay = (( 0, 0, 0,-i),
          ( 0, 0, i, 0),
          ( 0, i, 0, 0),
          (-i, 0, 0, 0))

gammaz = (( 0, 0, 1, 0),
          ( 0, 0, 0,-1),
          (-1, 0, 0, 0),
          ( 0, 1, 0, 0))

gammat = (( 1, 0, 0, 0),
          ( 0, 1, 0, 0),
          ( 0, 0,-1, 0),
          ( 0, 0, 0,-1))

-- Define the gamma vector.
--
-- The gamma vector has gamma matrices for its components. We express it here
-- as a rank 3 tensor. We set up the tensor so that the vector component index
-- is the last (rightmost) index. With this configuration we can left-multiply
-- with a Feynman slash matrix using the dot function.
--
-- For example, in component notation, this is how we want to multiply with a
-- Feynman slash matrix:
--
--     aslash[a,b] gamma[b,c,d]
--
-- (summation over the repeated index b)
--
-- The summation over b is exactly what the dot function does so we can do the
-- above multiply with dot(aslash,gamma).
--
-- In the following outer products, placing the basis vector operands on the
-- right-hand side results in the desired index ordering.

gamma = outer(gammax,(1,0,0,0)) +
        outer(gammay,(0,1,0,0)) +
        outer(gammaz,(0,0,1,0)) +
        outer(gammat,(0,0,0,1))

-- DOT is for multiplying gamma vectors. This is a special multiply because we
-- have to dot the individual vector components (the gamma matrices) then we
-- have to sum over all the results. In component notation, this is how we want
-- to do the multiply:
--
--     T[a,c] = A[a,b,d] * B[b,c,d]
--
-- To do this, we start with an outer product which results in the following
-- rank 6 tensor:
--
--     T[a,b,d,b,c,d]
--
-- Next we sum over b (indices 2 and 4) to get the following:
--
--     T[a,d,c,d]
--
-- Then we sum over d (indices 2 and 4 again) to get
--
--     T[a,c]
--
-- One final note, dot(B,metric) applies the spacetime metric to the rightmost
-- index of B, the vector index.

DOT(A,B) = contract(contract(outer(A,dot(B,metric)),2,4),2,4)

-- Define arbitrary spacetime vectors a, b and c.

a = (ax,ay,az,at)
b = (bx,by,bz,bt)
c = (cx,cy,cz,ct)

-- Define generic Feynman slash matrices.
-- Note: The order of dot operands here is different from the book. This is
-- because we defined gamma to have its vector index on the right. Therefore
-- we have to right-multiply with the spacetime vector so that dot contracts
-- over the correct indices. In component notation we have
--
--     aslash[u,v] = gamma[u,v,w] * a[w]
--
-- where summation is over the repeated index w.

aslash = dot(gamma,metric,a)
bslash = dot(gamma,metric,b)
cslash = dot(gamma,metric,c)

-- The Feynman slash matrices are 4x4 matrices. For example, aslash looks like
-- this:
--
--     at           0           -az       -ax + i ay
--
--     0            at       -ax - i ay       az
--
--     az       ax - i ay       -at           0
--
-- ax + i ay       -az           0           -at

-- Now we are ready to try the exercises. We want to show that each of the
-- following identities is true.

--------------------------------------------------------------------------------
--
--     aslash = at gammat - ax gammax - ay gammay - az gammaz
--
--------------------------------------------------------------------------------

A = aslash

B = at gammat - ax gammax - ay gammay - az gammaz

check(A = B) -- if A = B then continue, else stop

--------------------------------------------------------------------------------
--
--     aslash bslash = -bslash aslash + 2 a b
--
--------------------------------------------------------------------------------

A = dot(aslash,bslash)

B = -dot(bslash,aslash) + 2 dot(a,metric,b) I

check(A = B)

--------------------------------------------------------------------------------
--
--     gamma gamma = 4
--
--------------------------------------------------------------------------------

A = DOT(gamma,gamma)

B = 4 I

check(A = B)

--------------------------------------------------------------------------------
--
--     gamma aslash gamma = -2 aslash
--
--------------------------------------------------------------------------------

A = DOT(gamma,dot(aslash,gamma))

B = -2 aslash

check(A = B)

--------------------------------------------------------------------------------
--
--     gamma aslash bslash gamma = 4 a b
--
--------------------------------------------------------------------------------

A = DOT(gamma,dot(aslash,bslash,gamma))

B = 4 dot(a,metric,b) I

check(A = B)

--------------------------------------------------------------------------------
--
--     gamma aslash bslash cslash gamma = -2 cslash bslash aslash
--
--------------------------------------------------------------------------------

A = DOT(gamma,dot(aslash,bslash,cslash,gamma))

B = -2 dot(cslash,bslash,aslash)

check(A = B)

--------------------------------------------------------------------------------
--
--     If we get here then everything worked.
--
--------------------------------------------------------------------------------
