Maxwell–Boltzmann gas · the 2nd law
Why does a gas of structureless colliding balls always arrange its speeds into the same fixed shape — and why never the reverse?

▶ Run the simulationSee the measured result
Units: dimensionless (⟨v⟩/v_rms = √π/2 for the 2-D Maxwell–Boltzmann speed law; 3-D gives √(8/3π) = 0.9213 — the ratio counts dimensions)
How the lab tests it
Start N equal-mass hard disks all at the SAME speed v₀ (random directions — a delta spike, the lowest-entropy speed distribution at this energy) and let them collide elastically in a box (energy conserved to machine precision). Watch the speed histogram against the parameter-free 2-D Maxwell–Boltzmann curve f(v)=(v/s²)e^(−v²/2s²) (s² = ½⟨v²⟩, fixed by the energy), and track Boltzmann's H(t)=∫ f ln f d²v over time.
What it checks
the speed distribution relaxing onto Maxwell–Boltzmann (total-variation distance → 0, ⟨v⟩ → s√(π/2)) with no fitted parameter; and the H-theorem — H falling monotonically to a floor and only fluctuating after (entropy's arrow), while total kinetic energy stays flat
Maxwell–Boltzmann speed calculator: v_rms, mean, most probable — and the ratio that counts dimensions
A gas at one temperature does not have one speed — it has a distribution of them, and Maxwell's 1860 argument fixes its shape with no fitted parameter at all. Every velocity COMPONENT is an independent Gaussian of width s = √(RT/M), so the speed — the length of that vector — picks up a v^(d−1) Jacobian from velocity space, and the three numbers people actually want fall out as s times a pure number: the most probable speed s√(d−1), the mean s√2·Γ((d+1)/2)/Γ(d/2), and the root-mean-square s√d, which in three dimensions are the familiar √(2RT/M), √(8RT/πM) and √(3RT/M). This page computes all of them, and the arithmetic is worth a sentence, because it is the reason every figure here prints in full rather than to a bounded number of digits: there is NO transcendental function anywhere in it. The gamma ratio that the mean speed needs is not evaluated, it is ASSEMBLED — stepped up from Γ(½) = √π by the recursion Γ(x+1) = xΓ(x), a chain of rationals over one correctly rounded square root — so the whole page runs on +, −, ×, ÷ and Math.sqrt, which IEEE-754 requires correctly rounded and which therefore return the same doubles in every browser. That is also why the page refuses a fractional dimension rather than reaching for a real gamma function. The dimension is the interesting dial, and it is not decoration. ⟨v⟩/v_rms is a ratio of two moments of the same distribution, so the temperature cancels, the molar mass cancels, the gas constant cancels, and what is left is a pure number that knows only how many directions a velocity has: √π/2 for a two-dimensional gas, √(8/3π) for a three-dimensional one. Neither is typed here — both are assembled by that recursion and then checked against their direct spellings, which they reproduce bit for bit. Run the dial backwards and it becomes a measurement: hand the page a measured ratio and it names the dimension the gas lives in, which is exactly what the simulation above does. That simulation is a two-dimensional gas of hard disks started at the LEAST thermal state possible — every disk at the same speed, a delta spike whose ratio is exactly 1 — and collisions alone carry it onto √π/2. Its screen reads 0.886679 ± 0.000059, which is not √π/2 and is not supposed to be: a finite gas conserves its energy exactly, so its velocities are confined to an energy sphere and a single particle's marginal is a Beta distribution rather than a Gaussian, reading high by about +√π/(16N). This page recomputes that term at the module's own N rather than quoting it, subtracts it, and reports what is left in units of the screen's own error bar — and it tests the same 1/N law against the lab's deliberately tiny 16-disk gas, where the effect is twenty times larger, scoring it two defensible ways and saying plainly that the measurement cannot separate them. Graham's law is here too, because it is the same distribution seen sideways: two gases in one box share a temperature rather than a speed, so their speeds go inversely as the square root of their masses, and the page proves that the dimension and the temperature really do cancel by recomputing the ratio with each of them moved rather than by asserting it. Three things this page will NOT do. It will not compute a mean free path or a collision rate — λ = kT/(f·πσ²·P) and ν = ⟨v⟩/λ belong to another page on this site, which owns that chain and treats ⟨v⟩ as an ingredient of it, whereas here ⟨v⟩ is the answer. It will not compute Boltzmann's H or its floor −ln(2πs²)−1, because a logarithm would put an implementation-approximated function into a page whose every digit currently survives it; the H-theorem is the simulation's result and the finding's, not this calculator's. And it will not correct the screen: the offset that module prints is the finite-N term, and the right response to it is to compute the term, not to edit the number.
s = √(RT/M) = √(kT/m) · v_mp = s√(d−1), ⟨v⟩ = s√2·Γ((d+1)/2)/Γ(d/2), v_rms = s√d · d = 3: √(2RT/M), √(8RT/πM), √(3RT/M) · ⟨v⟩/v_rms = √(2/d)·Γ((d+1)/2)/Γ(d/2) — √π/2 in 2-D, √(8/3π) in 3-D · Graham: v₁/v₂ = √(M₂/M₁) · finite gas: excess ≈ +√π/(16N)