Monday, 12 January 2009

sed Magic: Removing Lines

Problem: Remove lines from a file f2 if they contain a word in file f1.

for word in `cat f1`; do
sed -i "/$word/d" f2;
sed is a stream editor, the -i option performs the editing in-place (i.e. in the original file).

This came up in the office today and I thought the solution was rather neat (if equally straightforward). Alternatives in most scripting languages (except maybe Perl?) are longer and/or uglier.

Monday, 5 January 2009

The Road To Quantum Field Theory

Dedicated readers will know that I've been presenting topics from theoretical physics with the goal of leading from Lagrangian mechanics all the way to quantum field theories. There were a few posts I made on special relativity and relativistic quantum mechanics before the 'QFT Series' of posts really began, and a number of other posts interspersed with those in the series. The most recent post introduced a mathematical notation useful in special relativity and relativistic quantum mechanics, notably four-vectors, tensors, etc.

Near the beginning I presented a list of topics I was going to cover. At this stage, I think it is appropriate to present a list of topics I've already covered, with links to the posts covering them, then to briefly outline the steps which still remain.

Pre-Series posts on Special Relativity, Quantum Mechanics and Particle Physics

The 'Road to QFT' Series

Out-of-Series Posts

  • Relativistic Electrodynamics (Covariant Formulation of Maxwell's Equations)
  • Relativistic Quantum Mechanics: From Schrödinger to Klein-Gordon
  • Relativistic Quantum Mechanics II: The Dirac Equation and Spin
  • Symmetries and the Gauge Principle
  • Quantum Electrodynamics (QED)
  • Aside on Quantum Chromodynamics (QCD)
  • SU(2) and Electroweak Unification
  • Aside on Superconductivity (maybe...)
  • Spontaneous Symmetry Breaking and the Higgs Mechanism
You may notice that the imminent parts of the roadmap are becoming more clearly defined, while the still-distant final topics are broad and loosely defined. For example, there's likely to be more than one post on QED, but until I get there I don't know how many posts it will take!

Saturday, 3 January 2009

The Mathematics of Special Relativity

As promised, here is a post outlining the mathematical objects used in special relativity (SR). I'm not going to present fully formal definitions, and I'll almost certainly miss out some things I'll later rely on to explain more advanced concepts, but I'll get to those when the time comes. As for the formal definitions, find a good text on special relativity.

Contravariant Four-Vectors
A contravariant four-vector is a four-component object which transforms according to the rule
x^{\prime\mu}=L^\mu_\nu x^\nu

where L is the Lorentz transformation (LT) matrix.

For a transformation from a frame S to a frame S' moving with respect to S with velocity v in the positive x direction, define
\beta &= \frac{v}{c}\\ \gamma &= \frac{1}{\sqrt{1-\beta^2}}\\ L &= \left(\begin{array}{cccc}\gamma&-\gamma\beta&0&0\\ -\gamma\beta&\gamma&0&0\\0&0&1&0\\0&0&0&1\end{array}\right)\end{align*}

For example, the space-time four-vector
x^\mu = \left(\begin{array}{c}ct\\x\\y\\z\end{array}\right)
transforms as
x^{\prime\mu} = \left(\begin{array}{c}\gamma ct-\gamma\beta x\\-\gamma\beta ct+\gamma x\\y\\z\end{array}\right)

= \left(\begin{array}{c}c\gamma\left(t-\frac{vx}{c^2}\right)\\\gamma\left(x-vt\right)\\y\\z\end{array}\right)

i.e. the usual form of the SR Lorentz transforms.

Contravariant four-vectors are represented with a greek-letter index in the superscript position. In particle physics and quantum field theory it is conventional for time to be the zeroth component, as in all of my posts. In some areas of relativistic quantum mechanics, one will see time as the fourth component. This alters the definition of the LT matrix and the metric tensor, but of course the physics remains the same. I will always use time as the zeroth component in these posts.

Covariant Four-Vectors and Rank-Two Tensors
In addition to contravariant four-vectors, there are mathematical objects called covariant four-vectors (sometimes also called one-forms). It is possible to convert between covariant and contravariant vectors using an object known as a metric tensor.

Covariant vectors are written with a single greek-letter index in the subscript position. Covariant and contravariant vectors are both rank-one tensors; objects where the rank is defined by the number of indices (equivalently the number of times one must apply the Lorentz transforms).

A metric tensor defines the structure of the space-time in which we are working. For special relativity, we use Minkowski space, and the metric tensor is defined as g:
g = \left(\begin{array}{cccc}1&0&0&0\\0&-1&0&0\\0&0&-1&0\\0&0&0&-1\end{array}\right)

g is a rank-two tensor representing the structure of space-time. In general relativity (GR) different metric tensors can be used for different space-time geometries.

The metric tensor allows us to convert contravariant vectors into covariant vectors, and vice versa:
x_\mu &= g_{\mu\nu}x^\nu\\
x^\mu &= g^{\mu\nu}x_\nu\end{align*}

Note that in these cases,
has both indices either raised or lowered, whereas in the Lorentz transforms, L has one raised index and one lowered index. The positions of the indices determine the result (covariant or contravariant) and whether the result is physically meaningful. The Einstein summation convention states that one should sum over repeated indices where one is raised and the other is lowered.

In Minkowski space, the conversion between co- and contra-variant vectors is simple:
x^\mu = \left(\begin{array}{c}ct\\x\\y\\z\end{array}\right)

x_\mu = \left(\begin{array}{cccc}ct&-x&-y&-z\end{array}\right)

Note that this leads to the useful property that the contraction of a covariant and a contravariant four-vector is a Lorentz-invariant scalar quantity. For example, using the space-time four-vector:
x^\mu x_\mu = x^\mu g_{\mu\nu}x^\nu = c^2 t^2 - x^2 - y^2 - z^2

which should be recognisable as the Lorentz-invariant space-time interval of special relativity.

This property holds for all four-vectors and in all inertial reference frames.

Special Relativity is sometimes formulated in terms of rapidity
rather than velocity v.

\mathrm{tanh}\,\theta = \beta
\Rightarrow \mathrm{cosh}\,\theta = \gamma = \frac{1}{\sqrt{1-\beta^2}}

The Lorentz transformation matrix is then written (often called
rather than L):
\Lambda =\left(\begin{array}{cccc}\mathrm{cosh}\,\theta&-\mathrm{sinh}\,\theta&0&0\\-\mathrm{sinh}\,\theta&\mathrm{cosh}\,\theta&0&0\\0&0&1&0\\0&0&0&1\end{array}\right)

for the equivalent of
L = \left(\begin{array}{cccc}\gamma&-\gamma\beta&0&0\\-\gamma\beta&\gamma&0&0\\0&0&1&0\\0&0&0&1\end{array}\right)

The usefulness of this approach lies in the fact that while velocities in SR do not add linearly, i.e.
v_{12} \neq v_1 + v_2

Rapidities do add linearly:
\theta_{12} = \theta_1 + \theta_2

Useful Objects
I'm going to list a few of the vectors and tensors which appear often in particle physics, so that when I need to use them in future posts, they won't look completely new. I won't explain much about them here.

Energy-Momentum four-vector
p^\mu = \left(\begin{array}{c}\frac{E}{c}\\p_x\\p_y\\p_z\end{array}\right) = \left(\begin{array}{c}\frac{E}{c}\\\mathbf{p}\end{array}\right)

j^\mu = \left(\begin{array}{c}\rho\\\mathbf{j}\end{array}\right)

(Electromagnetic) Four-Potential
A^\mu = \left(\begin{array}{c}\frac{\phi}{c}\\\mathbf{A}\end{array}\right)

where A is the vector potential of electromagnetism.

Covariant Derivative
\partial_\mu = \left(\begin{array}{c}\frac{1}{c}\frac{\partial}{\partial t}\\ \nabla\end{array}\right)

Faraday Tensor
F^{\mu\nu} = \partial^\mu A^\nu - \partial^\nu A^\mu

F = \left(\begin{array}{cccc}0&-\frac{E_1}{c}&-\frac{E_2}{c}&-\frac{E_3}{c}\\

Note that
F^{\mu\nu}F_{\mu\nu} = 2\left(B^2 - \frac{E^2}{c^2}\right)
is Lorentz invariant!