The definition, and the thing that computes it
These are two different objects and treating them as one is where most explanations of this go wrong.
The definition is exact and is about pressure:
The approximation is what lets you evaluate eₛ. The exact temperature dependence comes from the Clausius-Clapeyron relation, which has no tidy closed form, so everyone uses an empirical fit. The standard is Magnus:
The first is physics. The second is a curve fit, accurate to a few hundredths of a percent. Saying "the relative humidity formula" usually means the pair of them together.
Worked example 1 — from a dew point
You have 23.9°C air with a 15.6°C dew point.
The dew point is defined as the temperature at which today's vapour pressure would be saturation. So eₛ evaluated at the dew point is the actual vapour pressure.
- eₛ(15.6) = 6.112 × exp(17.62 × 15.6 / (243.12 + 15.6)) = 17.7 hPa — this is e
- eₛ(23.9) = 6.112 × exp(17.62 × 23.9 / (243.12 + 23.9)) = 29.6 hPa
- RH = 100 × 17.7 / 29.6 = 60%
Worked example 2 — from absolute humidity
You have 23.9°C air carrying 12.9 g/m³.
Here you must first convert a density into a pressure, using the ideal gas law for water vapour with Rᵥ = 461.5 J/(kg·K):
- e = ρᵥ × Rᵥ × T = 0.0129 × 461.5 × 297.05 = 1,768 Pa = 17.7 hPa
- eₛ(23.9) = 29.6 hPa
- RH = 100 × 17.7 / 29.6 = 60%
Same answer by a different road, which is the useful check that you have not mixed up a unit somewhere.
Worked example 3 — from a wet bulb
If what you have is a pair of thermometers — one dry, one with a wetted wick — the psychrometric relation gives you e directly:
Then divide by eₛ(T) as before. This is how humidity was measured for most of the twentieth century and it is still the reference for calibrating other instruments — see psychrometer vs hygrometer.
The clamps that matter in practice
Two guards belong in any implementation, and both exist in the app's source and in this site's port of it:
- Clamp relative humidity away from zero before taking its logarithm. ln(0) is negative infinity and will propagate a NaN through everything downstream. The app clamps to 0.01%.
- Clamp the result to 0–100. Rounding in source data occasionally produces a dew point a hundredth of a degree above the dry bulb, which would otherwise compute to 100.0001% and look like a bug to anyone reading it.
Neither is physics. Both are the difference between a formula and a working implementation.
Accuracy, and where it actually goes wrong
The Magnus fit contributes essentially nothing to your error budget. What does:
- The humidity sensor, at ±2% for a good one and ±5% or worse for a consumer device that has drifted. See how accurate hygrometers are.
- Distance, if the reading comes from a weather service. Humidity varies sharply over short distances, so the nearest station may genuinely be describing different air.
Which is to say: if your answer is wrong, it is almost certainly not the formula.