Therefore, instead of pressure being a linear function of height as one might expect from the more simple formula given in the “basic formula” section, it is more accurately represented as an exponential function of height.
Note that even that is a simplification, as temperature also varies with height. However, the temperature variation within the lower layers (troposphere, stratosphere) is only in the dozens of degrees, as opposed to difference between either and absolute zero, which is in the hundreds, so it is a reasonably small difference. For smaller height differences, including those from top to bottom of even the tallest of buildings, (like the CN tower) or for mountains of comparable size, the temperature variation will easily be within the single-digits. (See also lapse rate.)
An alternative derivation, shown by the Portland State Aerospace Society,[7] is used to give height as a function of pressure instead. This may seem counter-intuitive, as pressure results from height rather than vice versa, but such a formula can be useful in finding height based on pressure difference when one knows the latter and not the former. Different formulas are presented for different kinds of approximations; for comparison with the previous formula, the first referenced from the article will be the one applying the same constant-temperature approximation; in which case:
z = (-RT/g) \ln (P/P_0)
Where
z is the elevation,
R is the gas constant,
T is temperature in kelvin,
g is gravity,
P is pressure at a given point, and
P0 is pressure at the reference point.
And for the sake of comparison to the above, another formula derived in the same article shows a more complete picture for when constant temperature isn’t assumed, and is also a formula for height as a function of pressure difference:
z = (T_0/L)((P/P_0)^{-LR/g} - 1)
Where
L is the atmospheric lapse rate, and
T0 is the temperature at the same reference point for which P=P0
Apart from that, the units are the same as those of the formula mentioned before it.
Basically, which formula is best to use depends on which variables are known, which are meant to be found, and which simplifying assumptions are valid to make.