Special relativity: Lorentz transformations, time dilation, twins, E = mc² and magnetism
Special relativity from the two postulates: light clock, Lorentz transformations proved, simultaneity, length contraction, invariant interval and Minkowski diagram, twin paradox, E = mc², magnetism as a relativistic effect, muons, GPS and accelerators.
https://www.electronics-engineering.com/en/special-relativity-lorentz-transformations-time-dilation-twins-e-mc2/

Maxwell’s equations predict that light travels at
m/s, without saying relative to what. For the mechanics of Galileo and Newton this is impossible: a velocity changes depending on whether it is measured from a train or from the platform. In 1905 Einstein resolved the conflict by siding with Maxwell and changing the way time and space are measured. The result is special relativity: time runs more slowly for moving clocks, lengths shrink in the direction of motion, two events simultaneous for one observer are not for another, and mass and energy are the same thing. This lesson derives everything from the two postulates, with proofs, the Minkowski diagram, the twin paradox, relativistic dynamics and
, shows that the magnetic field is a relativistic effect of the electric field, and ends with the cases in which relativity is actually measured: cosmic-ray muons, GPS, particle accelerators.
The idea in simple words
Imagine you are on a very fast train and switch on a torch: the light moves away from you at
. Someone standing at the station sees the same light, and for them too it travels at
, not at
plus the speed of the train. Experiments say that this is exactly how it is. If two observers measure the same speed for light even though they move relative to each other, then they must measure times and distances differently: speed is space divided by time, and if the ratio stays the same, it is space and time that change. Every strange effect of relativity comes from here. At everyday speeds the differences are tiny (parts per billion), which is why we do not notice them; close to the speed of light they become enormous.
The problem: Galileo versus Maxwell
For Galileo, if a frame S′ moves with velocity
along
relative to S, coordinates transform as:
![]()
and velocities add:
. Newton’s laws do not change form (they are invariant) under this transformation. Maxwell’s equations do: the wave equation
, rewritten with Galileo’s coordinates, takes a different form, and light would have speed
in only one privileged frame, that of the “ether”. The Michelson and Morley experiment (1887) looked for the motion of the Earth through the ether by comparing the speed of light in two perpendicular directions, with enough sensitivity to measure the Earth’s orbital speed (30 km/s): it found nothing.
The two postulates
- Principle of relativity. The laws of physics, all of them (mechanics and electromagnetism), have the same form in all inertial frames.
- Constancy of the speed of light. Light in vacuum has speed
in every inertial frame, whatever the motion of the source.
The second postulate, in the light of the first, simply says that Maxwell’s equations hold in all inertial frames. Everything else follows.
Time dilation

A light clock is made of two mirrors a distance
apart between which a light pulse bounces; each round trip is a “tick”.
Theorem. A clock moving with velocity
ticks more slowly, relative to clocks at rest, by the Lorentz factor:
![Rendered by QuickLaTeX.com \[ \Delta t = \gamma\,\Delta\tau,\qquad \gamma = \frac{1}{\sqrt{1 - v^2/c^2}} \ge 1 \]](https://www.electronics-engineering.com/wp-content/ql-cache/quicklatex.com-3fde3dd3e0c214794903c89fd38e0bd2_l3.png)
where
is the interval measured by the clock itself (the proper time).
Proof. In the clock’s frame light covers
at speed
:
. For someone who sees the clock moving, during half a tick
the mirrors advance by
and the light travels along the hypotenuse (figure); by the second postulate it still does so at speed
, so the hypotenuse is
long. The distance
between the mirrors is perpendicular to the motion and does not change (if it did, an observer could tell which of the two is moving, against the first postulate). By Pythagoras
, hence
. ∎
Every clock, not just the light clock, must slow down in the same way: otherwise by comparing a light clock with a mechanical one on the train one would discover one is moving, violating the first postulate. It is time itself that slows down, and with it every physical, chemical and biological process.

The Lorentz transformations
Theorem. If S′ moves with velocity
along
relative to S and the origins coincide at
, the two postulates require
![]()
Proof. Space and time are homogeneous (no point and no instant is privileged), so the transformation is linear. The origin of S′ (
) moves as
, so
for some constant
. By the principle of relativity S moves with velocity
relative to S′, and by the isotropy of space with the same constant:
. A flash of light leaving the origin at
has, by the second postulate,
in S and
in S′. Substituting:
and
. Multiplying them together,
, that is,
. Finally, from the second relation
, and since
, one obtains
. ∎
For
,
and
: Galileo’s transformations are recovered. Newton’s mechanics is the low-speed limit of relativity, and this is why it works so well in everyday life.
Three consequences
The relativity of simultaneity. For two events separated by
and
,
. If they are simultaneous in S (
) but at different places, in S′ they are not:
. Two lightning bolts striking the two ends of a train at the same instant for someone at the station strike the front of the train first for someone on board. There is no universal “now”.
Length contraction. A rod at rest in S′ has proper length
. In S the length is measured by marking the two ends at the same instant (
):
, hence
![]()
Moving objects are shorter in the direction of motion. Perpendicular dimensions do not change.
Velocity addition. An object with velocity
in S has in S′, differentiating the transformations (
,
):
![]()
Two velocities of 0.5
do not give
but 0.8
; two of 0.9
give 0.9945
. If
, then
: the speed of light is the same for everyone, as the postulate requires. No combination of velocities below
can exceed it.
Spacetime and the invariant interval
Time and space, taken separately, change from one observer to another. There is, however, a combination that does not change.
Theorem. The interval between two events,
, is the same in all inertial frames.
Proof. With
, the transformations give
and
. Then
. The
and
coordinates do not change. ∎
It is the analogue of distance in Euclid’s geometry, which does not change when the axes are rotated; here, however, there is a minus sign, and the geometry of spacetime (that of Minkowski) differs from Euclidean geometry. The sign of the interval divides pairs of events into three classes that all observers recognise in the same way:
(timelike): a signal slower than light can go from one to the other; the time order is the same for everyone, and one can be the cause of the other;
(lightlike): only light connects them;
(spacelike): no signal connects them, and different observers can see them in a different order. This is why the reversal of order (the relativity of simultaneity) never violates causality.

In the Minkowski diagram (figure) every event is a point, the motion of a body a line (its world line), and light goes at 45 degrees. The axes of a moving frame are the lines
(that is,
) and
(that is,
): they tilt towards the light diagonal, the more so the closer
gets to
. Lines parallel to the
axis are the events simultaneous for the moving observer.
The twin paradox
A twin leaves for a star 4 light years away at 0.8
and comes straight back. On Earth
years pass. For the traveller, with
,
years pass: on return the traveller is four years younger.
The paradox: for the traveller it is the Earth that moves, so it should be the twin at home who ages less. But there is no symmetry: the twin on Earth always stays in the same inertial frame, the traveller does not (reversing course, and at that moment changing reference frame, and with it the idea of which Earth instant is “now”).
Theorem. The proper time measured along a world line is
, and between two events it is greatest along the inertial world line (the straight line).
Proof. On a short stretch, over which the velocity is roughly constant, the moving clock measures
; adding up the stretches gives the integral. In the inertial frame in which the two events occur at the same place, the inertial world line has
and the integrand equals 1, the largest possible value; every other line connecting the same two events has
on some stretch and therefore a smaller integral. Since
is the interval, the result does not depend on the chosen frame. ∎
In spacetime the straight line is the longest line, not the shortest: this is the minus sign of Minkowski geometry. The experiment has actually been done: in 1971 Hafele and Keating flew atomic clocks around the world on airliners and measured, relative to those left on the ground, differences of tens to hundreds of nanoseconds in agreement with the theory (combining this effect with that of gravity, from general relativity).

Relativistic dynamics
With the Lorentz transformations the momentum
is no longer conserved in all inertial frames. The right quantities, which are conserved in collisions for any observer, are
![]()
where
is the mass (the same for all observers). The energy of a body at rest is not zero but
, and the kinetic energy is what is added by setting it in motion:
![]()
Theorem.
, and for
the kinetic energy tends to
.
Proof.
. For small velocities
, so
. ∎
The relation
also holds for light: the photon has zero mass, so
, and it carries momentum (this is radiation pressure). Since
and
grow without limit as
, a body with mass never reaches the speed of light: it would take infinite energy.
Mass and energy.
says that mass is a form of energy. A helium-4 nucleus weighs less than the two protons and two neutrons that make it up: the mass defect is 0.0304 u, that is, 28.3 MeV, 0.75 % of the mass. It is the energy released when the nucleus forms, what makes the Sun shine. The same happens in chemical reactions, but the mass difference is a billion times smaller and no balance can see it.
Fast electrons and protons. In the cathode-ray tube of an old television the electrons are accelerated by 25 kV:
and
(Newton’s formula would give 0.313
, a 4 % error). With 1 MV,
and
, whereas Newton would give 1.98
, which is impossible. The protons of the LHC, at 6.8 TeV, have
and travel only 2.85 m/s slower than light. Particle accelerators are designed with relativistic dynamics, and confirm it every day.
Magnetism is relativity
A surprising consequence, and very close to the Physics 2 syllabus: the magnetic field is the electric field seen from another reference frame.
Theorem. The magnetic force
between a current-carrying wire and a charge moving parallel to the wire is the electric force that the charge feels, in its own reference frame, because of length contraction.
Proof. In the wire’s frame (S) the positive ions are at rest with linear density
and the electrons move with velocity
with density
: the wire is neutral and the current is
. A charge
moves with the same velocity
at a distance
. In the charge’s frame (S′) the electrons are at rest: in S they were contracted, so their proper density is
. The ions, instead, move with velocity
and are contracted: density
. The wire in S′ therefore has a net charge
, and the charge feels the electric field
, that is, the force
. A force perpendicular to the motion, brought back to frame S, is divided by
(the transverse impulse is the same in both frames, and the time in S is
times longer):
. With
and
:
, exactly the magnetic Lorentz force with the field of the wire given by Ampère’s law. ∎
The electrons in a wire move at fractions of a millimetre per second, and
is of the order of
; the magnetic force is measurable all the same because the charges involved are huge (in one metre of 1 mm² copper wire there are about 14 000 coulombs of conduction electrons). Maxwell’s equations were already relativistic: this is why Einstein titled his 1905 paper “On the electrodynamics of moving bodies”.
Relativity is measured
Cosmic-ray muons. Cosmic rays produce muons at an altitude of about 15 km, with speeds of about 0.995
. The muon lives on average 2.197 µs. Without relativity it would travel on average
µs = 655 m, and a fraction
would reach the ground. With time dilation (
) the mean lifetime in the Earth’s frame is ten times longer, the mean path 6.6 km, and 10 % reach the ground: this is what is measured. For the muon, instead, it is the layer of atmosphere that is contracted tenfold: the two descriptions give the same result.
GPS. GPS satellites orbit 26 560 km from the centre of the Earth with a speed of 3.874 km/s. According to special relativity their clocks slow down by 7.2 µs per day; according to general relativity (they are higher up in the gravitational field) they speed up by 45.7 µs per day. The total is +38.5 µs per day. Since GPS measures distances by the time of flight of the signals, an error of 38.5 µs corresponds to 11.5 km: without correction, the position would drift by more than ten kilometres per day. The satellite clocks are set on the ground to a slightly lower frequency, precisely to compensate.
The relativistic Doppler effect. A source approaching with velocity
emits waves of proper frequency
. In the observer’s frame its period is dilated to
, but during one period the source advances by
, and the wavefronts arrive separated by
. Therefore
![Rendered by QuickLaTeX.com \[ f = f_0\sqrt{\frac{1 + \beta}{1 - \beta}} \]](https://www.electronics-engineering.com/wp-content/ql-cache/quicklatex.com-2c3ed66433f55b2c5cb1e6fd98d15999_l3.png)
(with
negative if the source recedes). Even for a source moving sideways there is an effect,
, which classical physics does not predict: it is pure time dilation. The relativistic Doppler effect is the redshift of distant galaxies and a necessary correction in communications with space probes.
Summary
- Postulates: the laws of physics are the same in all inertial frames, and light has speed
for everyone. - They lead to the Lorentz transformations
,
, with
; for
Galileo is recovered. - Consequences: time dilation
, length contraction
, relativity of simultaneity, velocities that combine without ever exceeding
. - The interval
is invariant; proper time is greatest along the inertial world line (twins: 10 years against 6).
,
,
: mass is energy.- Magnetism is electricity seen from another reference frame; muons, GPS and accelerators confirm the theory every day.
The code
import math
import numpy as np
c = 299_792_458.0
gamma = lambda v: 1 / math.sqrt(1 - (v / c) ** 2)
# Lorentz factor for some speeds
for b in (0.01, 0.1, 0.5, 0.8, 0.9, 0.99, 0.995, 0.999):
print(f"v = {b:5.3f} c: gamma = {gamma(b * c):.4f}")
# Lorentz transformation as a matrix and check of the invariance of the interval
def boost(v):
g, b = gamma(v), v / c
return np.array([[g, -g * b], [-g * b, g]]) # acts on (ct, x)
rng = np.random.default_rng(0)
ev = rng.normal(size=(2, 5)) * 1e3 # five events (ct, x) in metres
for v in (0.3 * c, 0.9 * c):
ev2 = boost(v) @ ev
s2 = ev[0] ** 2 - ev[1] ** 2
s2b = ev2[0] ** 2 - ev2[1] ** 2
print(f"boost {v / c:.1f} c: largest relative difference in the interval {np.max(np.abs(s2b - s2) / np.abs(s2)):.1e}")
print(f"two boosts of 0.5 c = one boost of 0.8 c: {np.allclose(boost(0.5 * c) @ boost(0.5 * c), boost(0.8 * c))}")
# velocity addition
add = lambda u, v: (u + v) / (1 + u * v / c ** 2)
print(f"0.5 c + 0.5 c = {add(0.5 * c, 0.5 * c) / c:.3f} c; 0.9 c + 0.9 c = {add(0.9 * c, 0.9 * c) / c:.4f} c; c + 0.5 c = {add(c, 0.5 * c) / c:.3f} c")
# atmospheric muons: produced at 15 km, v = 0.995 c, mean lifetime 2.197 microseconds
tau, v, h = 2.197e-6, 0.995 * c, 15e3
print(f"muons: without relativity they travel on average {v * tau:.0f} m, with time dilation {gamma(v) * v * tau:.0f} m")
print(f" fraction reaching the ground: {math.exp(-h / (v * tau)):.1e} (Galileo) against {math.exp(-h / (gamma(v) * v * tau)):.3f} (Einstein)")
# twins: journey to a star 4 light years away at 0.8 c
v = 0.8 # units: years and light years, c = 1
T = 2 * 4 / v
print(f"twins: {T:.1f} years pass on Earth, {T / (1 / math.sqrt(1 - v ** 2)):.1f} years for the traveller")
# GPS: orbit of radius 26 560 km
GM, RE, r = 3.986004e14, 6.371e6, 26.56e6
vs = math.sqrt(GM / r)
day = 86400
sr = -vs ** 2 / (2 * c ** 2) * day
gr = GM * (1 / RE - 1 / r) / c ** 2 * day
print(f"GPS: v = {vs / 1e3:.3f} km/s; special relativity {1e6 * sr:+.1f} us/day, general {1e6 * gr:+.1f} us/day, total {1e6 * (sr + gr):+.1f} us/day = {(sr + gr) * c / 1e3:.1f} km of error per day")
# energy: accelerated electron, LHC proton, mass defect of helium 4
me, mp, u = 0.51099895, 938.27209, 931.49410 # MeV
for K in (0.025, 1.0):
g = 1 + K / me
print(f"electron with {1e3 * K:.0f} keV: gamma {g:.3f}, v = {math.sqrt(1 - 1 / g ** 2):.3f} c (Newton would give {math.sqrt(2 * K / me):.3f} c)")
g = 6.8e6 / mp
print(f"LHC proton at 6.8 TeV: gamma {g:.0f}, c - v = {c / (2 * g ** 2):.2f} m/s")
mHe, mH, mn = 4.002602, 1.007825, 1.008665 # atomic masses in u
dm = 2 * mH + 2 * mn - mHe
print(f"helium 4: mass defect {dm:.6f} u = {dm * u:.2f} MeV, that is {100 * dm / (2 * mH + 2 * mn):.2f} % of the mass")The program prints the values of
(1.1547 at 0.5
, 1.6667 at 0.8
, 10.01 at 0.995
), checks that the interval stays the same after a Lorentz transformation (up to rounding errors of
) and that two transformations at 0.5
are equivalent to a single one at 0.8
, and computes velocity addition, the muons (655 m against 6562 m, fraction at the ground
against 0.102), the twins (10 and 6 years), GPS (+38.5 µs per day, 11.5 km), the 25 keV and 1 MeV electrons, the LHC proton and the mass defect of helium.
The videos
To see the same topics explained at the blackboard, this series of videos by Lorenzo Galante, in Italian, follows the same path:






Ciao, sono l'autore di «Relatività ristretta: trasformazioni di Lorentz, dilatazione dei tempi, gemelli, E = mc² e magnetismo». Domande, dubbi, segnalazioni di errori o richieste di approfondimento sono benvenuti: scriveteli qui sotto e vi rispondo io. Potete anche votare la pagina con le stelle all'inizio dell'articolo.Hi, I am the author of “Special relativity: Lorentz transformations, time dilation, twins, E = mc² and magnetism”. Questions, doubts, error reports and requests for more detail are all welcome: write them below and I will answer. You can also rate the page with the stars at the top of the article.