The ideal gas equation in the form PV=*n*RT is an excellent tool for understanding the relationship between the pressure, volume, amount, and temperature of an ideal gas in a defined environment where we are able to control for constant volume.
However, the ideal gas equation, in its most common form, is not useful when we seek to to examine the behavior of gases of undetermined volume, such as the gases in the clouds that surround the stars in our solar system or the atmospheric gases that support life on our planet .
For the purposes of studying gases with volumes that are difficult to quantify, we can make use of calculations employing the physical property of density, defined as the mass of the gas per unit volume, to derive a form of the ideal gas equation that has broader applications.

n = # moles of gas = mass of gas (m)/molecular weight (M)

We know the ideal gas equation in the form

and that:

If we substitute *m*/*M* for *n*:

and simplify, we arrive at:

If we simplify further, we get:

This derivation of the ideal gas equation allows us to characterize the relationship between the pressure, density, and temperature of the gas sample *independent of* the volume the gas occupies.
It allows us to determine the density of a gas sample given its pressure and temperature or to determine the molar mass of a gas sample given its density.