The density of air depends on its temperature, its pressure and how much water vapor is in the air.

Air Density Calculations

To begin to understand the calculation of air density, consider the ideal gas law:
(1) P*V = n*R*T
V = volume
n = number of moles
R = gas constant
T = temperature

Density is simply the number of molecules of the ideal gas in a certain volume, in this case a molar volume, which may be mathematically expressed as:
(2) D = n / V:
n = number of molecules
V = volume

Then, by combining the previous two equations, the expression for the density becomes:
(3) D = P / (R * T)
P = pressure in Pascals (multiply mb by 100 to get Pascals)
R = gas constant, (J/(kg*degK) = 287.05) for dry air
T = temperature, (degK = deg C + 273.15)

The density of a mixture of dry air molecules and water vapour molecules may be expressed as:
(4) D = (Pd / (Rd * T))+(Pv / (Rv * T))
Pd = pressure of dry air in Pascals
Pv= pressure of water vapour in Pascals
Rd = gas constant for dry air (J/(kg*degK) = 287.05)
Rv = gas constant for water vapour (J/(kg*degK) = 461.495)
T = temperature (degK = deg C + 273.15)

To determine the density of the air, it is necessary to know is the actual air pressure (also known as absolute pressure, or station pressure), the water vapour pressure, and the temperature.

Vapor Pressure

A very accurate, albeit quite odd looking, formula for determining the saturation vapour pressure is a polynomial developed by Herman Wobus
(5) Es = Eso / p ^ 8
p = (c0+T*(c1+T*(c2+T*(c3+T*(c4+T*(c5+T*(c6+T*(c7+T*(c8+T*(c9)))))))))) 
T = temperature, deg C
c0 = 0.99999683
c1 = -0.90826951*10-2
c2 = 0.78736169*10-4
c3 = -0.61117958*10-6
c4 = 0.43884187*10-8
c5 = -0.29883885*10-10
c6 = 0.21874425*10-12
c7 = -0.17892321*10-14
c8 = 0.11112018*10-16
c9 = -0.30994571*10-19

For situations where a slightly less accurate formula is acceptable, the following equation offers good results, especially at the higher ambient air temperatures where the saturation pressure becomes significant for the density altitude calculations.
(6) Es = C0 * 10 ^ ((C1 * Tc)/(C2 * Tc))
Tc = temperature, deg C
c0 = 6.1078
c1 = 7.5
c2 = 237.3

What is air pressure?

The air's pressure is the weight of the air molecules pressing down on the Earth surface below. Since the pressure depends on the amount of air above the point where you're measuring the pressure, the pressure falls at higher altitudes.