## Wikipedia

Main article: Barometric formulaIf one is to analyze the vertical pressure variation of the atmosphere of Earth, the length scale is very significant (troposphere alone being several kilometres tall; thermosphere being several hundred kilometres) and the involved fluid (air) is compressible. Gravity can still be reasonably approximated as constant, because length scales on the order of kilometres are still small in comparison to Earth's radius, which is on average about 6371 km,^{[7]} and gravity is a function of distance from Earth's core.^{[8]}

Density, on the other hand, varies more significantly with height. It follows from the ideal gas law that

- {\displaystyle \rho ={\frac {mP}{kT}},}

where

- m is average mass per air molecule,
- P is pressure at a given point,
- k is the Boltzmann constant,
- T is the temperature in kelvins.

Put more simply, air density depends on air pressure. Given that air pressure also depends on air density, it would be easy to get the impression that this was circular definition, but it is simply interdependency of different variables. This then yields a more accurate formula, of the form

- {\displaystyle P_{h}=P_{0}e^{-{\frac {mgh}{kT}}},}

where

- P
_{h}is the pressure at height h, *P*_{0}is the pressure at reference point 0 (typically referring to sea level),- m is the mass per air molecule,
- g is gravity,
- h is height from reference point 0,
- k is the Boltzmann constant,
- T is the temperature in kelvins.

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 in this simplification, the temperature is treated as constant, even though temperature also varies with height. However, the temperature variation within the lower layers of the atmosphere (troposphere, stratosphere) is only in the dozens of degrees, as opposed to their thermodynamic temperature, which is in the hundreds, so the temperature variation is reasonably small and is thus ignored.

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.)