A Byte of PhysicsLogo

Lorentz transformations

A Lorentz transformation tells two inertial observers how to label the same event. It does not make the event move and it does not describe a force. It only converts the event's space and time coordinates from one inertial frame to another. The surprising feature is that space and time must mix if every inertial observer is to measure the same speed of light in vacuum.

Suppose frame \(S'\) moves at constant velocity \(v\) in the positive \(x\) direction relative to frame \(S\). Let their origins coincide when both clocks read zero. This convention fixes the signs used below. An event has coordinates \((x,y,z,t)\) in \(S\) and

\((x',y',z',t')\)

in \(S'\).

Why the Galilean rule is not enough

In Newtonian mechanics, one would write

\[x'=x-vt,\qquad t'=t\]

This works extremely well when all relevant speeds are much smaller than the speed of light. It assumes that observers share one universal time. But apply it to a light pulse with \(x=ct\): the moving observer would obtain

\(x'=(c-v)t\)

and hence measure \(c-v\). That contradicts the postulate that light in vacuum has speed \(c\) in every inertial frame.

The correction cannot affect position alone. The time coordinate must also change. Define the dimensionless speed and Lorentz factor by

\[\beta=\frac{v}{c},\qquad \gamma=\frac{1}{\sqrt{1-\beta^2}}\]

For a physical inertial frame, \(|v|<c\), so \(\gamma\) is real and at least one. The Lorentz transformation is

\[x'=\gamma(x-vt),\qquad y'=y,\qquad z'=z\] \[t'=\gamma\left(t-\frac{vx}{c^2}\right)\]

The time transformation depends on position. This is not a clock defect. It expresses the relativity of simultaneity: clocks that are synchronized throughout one frame are generally not synchronized throughout another frame.

Reading each term physically

The combination \(x-vt\) is familiar from Galilean kinematics. It subtracts the distance traveled by the moving origin during time \(t\). The factor \(\gamma\) then accounts for the changed geometry of space and time.

The time equation contains \(vx/c^2\). Its units are seconds: velocity times distance divided by velocity squared. That dimensional check is useful because accidentally writing \(vx/c\) would be dimensionally wrong. Its sign also matters. With the convention chosen above, events farther in the positive \(x\) direction receive a smaller \(t'\) for the same \(t\).

The transverse coordinates do not change because this is a standard boost along the \(x\) axis. A boost in an arbitrary direction can be decomposed into components parallel and perpendicular to the velocity: only the parallel component mixes with time.

A numerical event transformation

Consider an event three light-seconds from the origin at time five seconds:

\[x=3.0c\,\mathrm{s},\qquad t=5.0\,\mathrm{s}\]

The notation \(c\,\mathrm{s}\) is a distance, not a speed: one light-second is the distance light travels in one second. Let \(v=0.60c\). Then

\[\gamma=\frac{1}{\sqrt{1-0.60^2}}=1.25\]

It is convenient to calculate the position in light-seconds. Substitution gives

\[x'=1.25(3.0c\,\mathrm{s}-0.60c\cdot5.0\,\mathrm{s})=0\] \[t'=1.25\left(5.0\,\mathrm{s}-\frac{0.60c(3.0c\,\mathrm{s})}{c^2}\right)=4.0\,\mathrm{s}\]

The event occurs at the moving frame's origin because that origin follows \(x=vt\). This gives a plain-language interpretation: the event happens exactly where the moving observer is located, four seconds after that observer's clock was set to zero.

The calculation can be written as narrow Python so every unit conversion and sign choice remains visible:

import numpy as np

# Coordinates are (time in seconds, position in light-seconds), so c=1.
beta = 0.6
gamma = 1 / np.sqrt(1 - beta**2)
event = np.array([5.0, 3.0])
boost = gamma * np.array([[1.0, -beta], [-beta, 1.0]])
transformed = boost @ event
print("Transformed (seconds, light-seconds):", transformed)

The inverse transformation

To convert from \(S'\) back to \(S\), replace \(v\) with \(-v\). The Lorentz factor is unchanged because it depends on \(v^2\):

\[x=\gamma(x'+vt'),\qquad t=\gamma\left(t'+\frac{vx'}{c^2}\right)\]

This symmetry encodes reciprocity. If \(S'\) moves at \(+v\) relative to \(S\), then \(S\) moves at \(-v\) relative to \(S'\). No inertial frame is the preferred one.

inverse = gamma * np.array([[1.0, beta], [beta, 1.0]])
recovered = inverse @ transformed
assert np.allclose(recovered, event)
print("Inverse transformation error:", recovered - event)

The spacetime interval stays invariant

Coordinates change, but the spacetime interval between two events does not. For the sign convention used here,

\[\Delta s^2=c^2\Delta t^2-\Delta x^2-\Delta y^2-\Delta z^2\]

Substituting the transformation shows that

\[c^2\Delta t'^2-\Delta x'^2=c^2\Delta t^2-\Delta x^2\]

because the cross terms cancel and \(\gamma^2(1-\beta^2)=1\). This invariant plays a role analogous to ordinary distance under a rotation. A rotation changes the coordinate components of a vector but preserves its Euclidean length. A Lorentz boost changes space and time components while preserving spacetime interval.

For the example above, the interval from the origin is

\[\Delta s^2=c^2(5.0\,\mathrm{s})^2-(3.0c\,\mathrm{s})^2=16c^2\,\mathrm{s}^2\]

In the moving frame it is

\[\Delta s'^2=c^2(4.0\,\mathrm{s})^2-0^2=16c^2\,\mathrm{s}^2\]

The equal results provide a stronger check than inspecting either transformed coordinate alone.

Events and simultaneity

For two events, subtract their coordinates before transforming:

\[\Delta x'=\gamma(\Delta x-v\Delta t),\qquad \Delta t'=\gamma\left(\Delta t-\frac{v\Delta x}{c^2}\right)\]

If the events are simultaneous in \(S\), then \(\Delta t=0\), but

\[\Delta t'=-\gamma\frac{v\Delta x}{c^2}\]

unless the events occur at the same place. Spatially separated events therefore need not be simultaneous in another frame. This does not allow a causal paradox. For timelike- or lightlike-separated events, every inertial observer agrees on their possible causal order. Only spacelike-separated events can reverse temporal order under a boost, and no signal traveling at or below \(c\) can connect them.

Velocity transformation

Differentiate the coordinate transformations, or divide a small transformed displacement by its transformed time. If an object moves with velocity

\(u_x=dx/dt\)

in \(S\), then

\[u'_x=\frac{u_x-v}{1-u_xv/c^2}\]

The denominator is the crucial relativistic correction. If \(u_x=c\), then \(u'_x=c\) for every allowed \(v\). If both speeds are much smaller than \(c\), the denominator is nearly one and the Galilean result

\(u'_x\approx u_x-v\)

returns.

The transverse components also change because time changes:

\[u'_y=\frac{u_y}{\gamma(1-u_xv/c^2)},\qquad u'_z=\frac{u_z}{\gamma(1-u_xv/c^2)}\]

Matrix form and repeated boosts

Using \(ct\) as the time coordinate gives every entry the same units. A one-dimensional boost becomes

\[\begin{pmatrix}ct'\\x'\end{pmatrix}=\begin{pmatrix}\gamma&-\gamma\beta\\-\gamma\beta&\gamma\end{pmatrix}\begin{pmatrix}ct\\x\end{pmatrix}\]

Matrix notation makes composition explicit. Two boosts along the same axis with speeds \(v_1\) and \(v_2\) combine into

\[v_{\mathrm{combined}}=\frac{v_1+v_2}{1+v_1v_2/c^2}\]

The result never exceeds \(c\) when both input speeds are below \(c\). For computation near light speed, it can be safer to use rapidity \(\eta\), defined by \(\tanh\eta=v/c\). Collinear rapidities add directly, avoiding some loss of precision in repeated velocity composition.

Reliable computational procedure

The equations are simple enough to type incorrectly. A robust implementation checks the domain, uses one sign convention, and verifies the invariant.

def lorentz_boost(time, position, speed, c=299792458.0):
    if c <= 0 or abs(speed) >= c:
        raise ValueError("The boost speed must be smaller than light speed.")
    gamma = 1 / np.sqrt(1 - (speed / c) ** 2)
    return gamma * (time - speed * position / c**2), gamma * (position - speed * time)


print(lorentz_boost(5.0, 3 * 299792458.0, 0.6 * 299792458.0))

Keep SI units internally. If positions are entered in light-seconds, either convert them to metres first or consistently represent time as \(ct\). Mixing metres with light-seconds is a common source of apparently reasonable but false results.

For \(|v|\ll c\), verify that \(\gamma\approx1\) and that the result approaches the Galilean transformation. For \(v=0\), the output must equal the input. For a light ray, the output speed must still be \(c\). These checks catch sign, unit, and denominator errors that a single example may miss.

Near \(|v|=c\), \(\gamma\) grows without bound. Floating-point subtraction can then lose important digits. This is a numerical limitation, not new physics. Scale coordinates sensibly, use rapidity for long chains of boosts, and compare invariants with combined absolute and relative tolerances.

Scope and interpretation

These formulas apply to inertial frames in flat spacetime. They assume constant relative velocity and the standard synchronization of clocks by light signals. They do not by themselves describe acceleration, rotating coordinates, gravity, or curved spacetime. An accelerating observer can often be treated with a sequence of momentarily comoving inertial frames, but a full gravitational description belongs to general relativity.

The transformation also does not say that a distant observer visually sees events at their coordinate times. Images include light-travel delay, aberration, and Doppler effects. Coordinate comparison assumes that each frame has already corrected for signal travel and has established a synchronized network of clocks and rulers. Keeping this distinction between observation and assigned coordinate prevents many apparent paradoxes.

A worked Python notebook

Transform an event at time five seconds and position three light-seconds. The question for this calculation is precise: how does transformed event time change when we change boost speed fraction, while keeping the other choices fixed? The earlier sections explain the physical relationship. Here we turn one part of that relationship into a calculation that you can run, inspect, and change in Google Colab.

The boost is along one axis and its speed magnitude is strictly smaller than light speed. Keep that sentence beside the results. A formula can return a number outside its useful range, and a plotting library will usually draw that number without asking whether the physical assumptions still hold. The selected interval is from -0.8 to 0.8 dimensionless. It gives us a specific domain to discuss instead of leaving the graph's range to a software default.

Use the notebook link above the lesson, run the setup cell, and then run the cells in order. The code below is also included there. NumPy handles the arrays of numerical values, SymPy keeps the equation symbolic, and Matplotlib draws the results. If these libraries or notebook cells are unfamiliar, start with Your first physics notebook.

State the relationship before choosing a graph

In this small example, q stands for boost speed fraction, expressed in dimensionless. The output is transformed event time, expressed in s. The equation below uses the numerical values in those units. Any fixed coefficients therefore carry the units needed to make the relation consistent. A value supplied in another unit must be converted before it enters this expression.

\[f(q) = \frac{5 - 3 q}{\sqrt{1 - q^{2}}}\]

This is a function of one changing input. It is not a statement that the physical system has only one variable. We deliberately hold the other inputs fixed so that one cause of variation is visible. Changing several inputs at once would make it harder to tell which change produced the output difference. Write down the held-fixed choices before trying a different experiment.

At 0.6 dimensionless, the expression gives 4 s. This is our reference calculation. It is a prediction of the stated example, not a new measurement. Its displayed digits help us compare implementations. They should not be read as a claim that physical inputs are known to six significant figures.

import numpy as np
import sympy as sp
import matplotlib.pyplot as plt

q = sp.Symbol("q", real=True)
expression = sp.sympify("(5-3*q)/sqrt(1-q**2)", locals={"q": q})
reference_input = 0.6
reference_output = float(expression.subs(q, reference_input))
print("Input:", reference_input, "dimensionless")
print("Predicted transformed event time:", reference_output, "s")

sp.Symbol declares a mathematical symbol. It does not assign a numerical measurement to that symbol. subs then replaces the symbol with our chosen input, and float converts the resulting symbolic number into a standard Python numerical value. Keeping these steps separate lets us inspect the equation before numerical substitution. It also prevents a later plot from becoming the only surviving record of the model.

Compare a few cases you can explain

Before drawing hundreds of points, calculate three. The lower endpoint gives 12.3333 s. The midpoint, at 0 dimensionless, gives 5 s. The upper endpoint gives 4.33333 s. Read these together with the assumptions: they describe different choices of boost speed fraction within the same example, with the other inputs held fixed.

These three values are a useful first check, but they do not establish the shape between them. Two endpoints can be equal even when the curve bends or oscillates in between. Likewise, a large change between endpoints does not tell us whether the relationship is linear. We need the equation and intermediate samples to answer those questions.

evaluate = sp.lambdify(q, expression, modules="numpy")
inputs = np.array([-0.8, 0.0, 0.8])
outputs = np.asarray(evaluate(inputs), dtype=float)
outputs = np.broadcast_to(outputs, inputs.shape)
for input_value, output_value in zip(inputs, outputs):
    print(f"{input_value:.6g} dimensionless -> {output_value:.6g} s")
assert np.all(np.isfinite(outputs))

lambdify turns the symbolic expression into a numerical function. We explicitly select NumPy as its numerical backend so it can accept an array. The same expression now has two useful forms: one for algebra and one for calculating many cases. The assertion checks that the chosen inputs produce finite outputs. It would catch an infinity or an undefined numerical result, but a finite value can still be physically inappropriate.

Make a graph that answers the question

The horizontal axis shows boost speed fraction; the vertical axis shows transformed event time. Every plotted point is a prediction of the same expression. We mark the reference case separately so that a reader can connect the earlier printed value to its place on the curve. The axis labels include units because a shape without a scale cannot tell us the size of a physical effect.

input_grid = np.linspace(-0.8, 0.8, 301)
output_grid = np.asarray(evaluate(input_grid), dtype=float)
output_grid = np.broadcast_to(output_grid, input_grid.shape)
fig, ax = plt.subplots(figsize=(7, 4))
ax.plot(input_grid, output_grid, label="Stated model")
ax.scatter([reference_input], [reference_output], label="Reference case", zorder=3)
ax.set_xlabel("Boost speed fraction (dimensionless)")
ax.set_ylabel("Transformed event time (s)")
ax.legend()
ax.grid(alpha=0.25)
fig.tight_layout()
plt.show()

Look for a sign change, a turning point, or a region where the curve becomes steep. Connect each feature to the expression rather than to the colour of the line. If the curve has a minimum or maximum, changing the input in opposite directions may have similar effects on the output near that point. If it is nearly straight over a short interval, a local linear approximation may be useful even when the complete expression is nonlinear.

Increasing the number of samples makes the line smoother and may reveal features that a coarse grid missed. It does not improve the physical inputs or enlarge the model's validity range. For quantities that can take only discrete values, use the line as a guide to the relationship and interpret only the allowed input values. A plotting function does not enforce such restrictions for you.

Measure the local sensitivity

A derivative asks a more specific question than the whole graph: how quickly does transformed event time change near the reference input? Its units are the output unit divided by the input unit. For this calculation, the derivative at 0.6 dimensionless is 0 in those ratio units. Locally, the output has no first-order change as the input increases. This statement is local; the sign or size of the slope can be different elsewhere on the curve.

\[f'(q) = \frac{q \left(5 - 3 q\right)}{\left(1 - q^{2}\right)^{\frac{3}{2}}} - \frac{3}{\sqrt{1 - q^{2}}}\]

For a small input change, multiply the derivative by that change to estimate the output change. Then compare that estimate with a fresh evaluation of the full expression. The distinction between these two calculations matters: the derivative gives a tangent approximation, while substitution evaluates the chosen expression at the new point.

slope_expression = sp.diff(expression, q)
slope_at_reference = float(slope_expression.subs(q, reference_input))
changed_input = 0.608
linear_prediction = reference_output + slope_at_reference * (
    changed_input - reference_input
)
full_prediction = float(evaluate(changed_input))
print("Symbolic derivative:", slope_expression)
print("Tangent prediction:", linear_prediction, "s")
print("Full expression:", full_prediction, "s")
print("Approximation difference:", full_prediction - linear_prediction, "s")

Here the changed input is 0.608 dimensionless. The tangent estimate is 4 s, while the full expression gives 4.00032 s. If the two values are close, it means the chosen input change is small enough for this local approximation at this point. It does not mean the entire model is linear. If the slope is zero, a quadratic or higher-order term may supply the leading change instead.

This is also the beginning of uncertainty propagation. If the input has a small stated standard uncertainty, the magnitude of the slope times that uncertainty estimates one contribution to output uncertainty. Do not automatically use the same rule for a wide interval, a discontinuity, a turning point with zero first derivative, or several correlated uncertain inputs. Those situations need more of the model than one slope.

Check the derivative with numerical differences

We can estimate the same slope from values on either side of the reference point. Subtract the lower output from the upper output and divide by twice the input step. Parentheses are essential: the entire output difference must be divided by the entire input interval. Without them, Python can execute a different mathematical expression while still producing a plausible number.

The calculation below uses three decreasing step sizes. Each estimate is compared with the symbolic derivative, so the reference is independent of the numerical difference formula. Near an endpoint, it is acceptable here to evaluate a small extension only because the displayed mathematical expression is smooth there; such a check does not assert that extrapolated values describe additional physical cases.

input_span = 1.6
for fraction in [1e-2, 1e-3, 1e-4]:
    step = input_span * fraction
    upper = float(evaluate(reference_input + step))
    lower = float(evaluate(reference_input - step))
    numerical_slope = (upper - lower) / (2 * step)
    difference = numerical_slope - slope_at_reference
    print(f"step={step:.6g}: slope={numerical_slope:.6g}, difference={difference:.6g}")

For a smooth function, reducing the step often reduces the approximation error at first. Very small steps can eventually make subtraction of nearly equal floating-point values less reliable. Therefore “smaller” is not an unlimited guarantee of “better.” Compare the observed behaviour over a useful range of steps instead of choosing the smallest number the computer can represent.

An absolute slope difference is useful when the expected slope is near zero. A relative difference would divide by a very small reference and could look enormous even when the absolute discrepancy is tiny. Away from zero, a relative difference can help compare quantities with very different scales. The tolerance should reflect the question and the numerical method, rather than a universal decimal threshold copied into every test.

Change the example and preserve the reasoning

Make one copy of the reference calculation before editing it. Choose a second value of boost speed fraction inside the stated interval, predict whether transformed event time will rise or fall, and then evaluate the expression. Place the prediction and the result in a text cell. If they disagree, identify whether the mistake was in the sign, the unit conversion, the algebra, or the assumption about how the curve behaves.

Next choose a shorter plotting interval around the reference point. Compare the local curve with its tangent approximation. Then widen the interval again. The difference shows why a useful local estimate need not describe the whole range. Keep the axis labels and numerical scale visible when comparing the plots; automatic axis limits can make two different effects appear equally large.

Finally, return to the physical limit stated at the start: The boost is along one axis and its speed magnitude is strictly smaller than light speed. Describe one change to the setup that would violate that limit. State what new input, equation, or observation would be needed before trusting an answer in the changed situation. This last step connects the Python experiment to the physics instead of treating successful execution as the only criterion for a useful result.

Before saving, restart the runtime and run all cells in order. A result that depends on an earlier, now-deleted input cell is not reproducible from the saved notebook. Keep unrounded values for later calculations, round only the reported output, and label any new data as measured, assumed, or generated. The graph and printed values should remain traceable to the same expression and the same choices of inputs.

Recover the output change by integrating the slope

There is another way to check that the expression and its derivative describe the same relationship. Add up the small output changes predicted by the slope across the chosen input interval. In the continuous limit, this integral equals the output at the upper endpoint minus the output at the lower endpoint. The result has units of s: the input unit in the integration cancels the input unit in the denominator of the slope.

This statement is about the mathematics of this particular relationship. It does not assign a new physical meaning to an arbitrary area under a graph. For example, an area under force versus distance represents work, while an area under a different pair of quantities may represent something else or have no standard name. Always carry the axis units through the calculation before naming an integral.

slope_function = sp.lambdify(q, slope_expression, modules="numpy")
endpoint_change = float(evaluate(0.8) - evaluate(-0.8))
for points in [101, 201, 401]:
    grid = np.linspace(-0.8, 0.8, points)
    slopes = np.asarray(slope_function(grid), dtype=float)
    slopes = np.broadcast_to(slopes, grid.shape)
    integrated_change = np.trapezoid(slopes, grid)
    print(
        points,
        "integrated change:",
        integrated_change,
        "endpoint change:",
        endpoint_change,
    )

The trapezoidal rule joins neighbouring slope samples with straight segments and adds their signed areas. A negative contribution remains negative; replacing every slope by its magnitude would calculate a different quantity. Increasing the sample count provides a practical refinement check. If the values do not settle toward the endpoint difference, first inspect the interval, singularities, and array ordering.

Do not conclude that two agreeing calculations prove the model is physically complete. Both use the same selected relationship, so an omitted effect would be omitted from both. Their agreement is evidence that the numerical tools implement that relationship consistently. Comparing with an independent experiment or a more appropriate physical model is a separate test.

Keep this comparison in the notebook when you change the expression. It is particularly useful after adding a coefficient, changing a sign convention, or converting an input unit. A code cell that produces a smooth graph can conceal these mistakes; a second calculation of the same output change gives you another place to notice them.

Sources


Share to: