At speeds near light speed, the low-speed formulas p = mv and kinetic energy ½mv² no longer describe the same physical state accurately. Special relativity packages energy and momentum into one relationship with a powerful invariant check.
{ restMass, speed, gamma, energy, momentum }, with SI units attached in the surrounding API. Compute all derived fields from one source of truth, reject speeds at or above c, and test the invariant rather than trusting separately rounded outputs.The shared factor is
\[\gamma=\frac{1}{\sqrt{1-v^2/c^2}}\]For a free particle,
\[E=\gamma mc^2,\qquad p=\gamma mv,\qquad E^2=(pc)^2+(mc^2)^2\]The final relationship is more than an equation to display. It is a test oracle: calculate E² - (p*c)² and compare it with (m*c²)². At v = 0.6c, γ = 1.25. A mass of 2 kg must produce the same invariant whether you calculate it through energy or momentum.
function lorentzFactor(speed: number) {
if (Math.abs(speed) >= SPEED_OF_LIGHT) throw new RangeError("speed must stay below light speed");
const beta = speed / SPEED_OF_LIGHT;
return 1 / Math.sqrt(1 - beta ** 2);
}
Keeping the sign on v retains momentum direction, while energy remains non-negative for positive rest mass. Do not compute γ from a rounded percentage string or use a classical momentum in the invariant check: either shortcut can create a convincing but inconsistent result.
Prediction: The Lorentz factor grows slowly at low speed and sharply as speed approaches c; no finite rest mass reaches c in this model.
Calculate γ at0, 0.6c, and 0.9c. Before evaluating, predict which change is larger. Then use the invariant relation to explain why a velocity input equal to c should be rejected rather than clamped.Relativistic energy and momentum are one coupled state calculation. Share the Lorentz factor, preserve momentum direction, enforce the speed domain, and validate the result with the energy–momentum invariant.
Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.
\[\text{observable output} = f(\text{inputs},\,\text{state})\]For Relativistic Energy and Momentum, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Relativity, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.
Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.
This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.
Treat Relativistic Energy and Momentum as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.
Compute relativistic state with four-momentum and invariant energy–momentum consistency checks.