As mentioned before, gases in diving cylinders are not only not sufficiently well approximated by the real gas equation but also the van der Waals equation, despite its prominence in thermodynamics teaching, is not doing much better.
Subsurface does better than this using a polynomial fit to table data for the compressibility of the three relevant gases. In a discussion at ScubaBoard, the question came up how to use this in gas blending. After an initial version using Mathematica, I sat down and implemented it as a perl script and hooked it up to this web page for everybody’s use and enjoyment. Here it is:
source code is on GitHub. Right now, it does only nitrox. But it computes instructions to up up partly filled cylinders with any pre-existing nitrox mix.
Let me know if you think extending it to trimix would be useful for actual use. I am not sure what the best user interface would be in that case: For nitrox, specifying the initial and target mix and pressure and two top up mixes, the blending problem generally has a solution. But with three gas components to get right, it is in general impossible with only two top up mixes. So you either have to use three (linearly independent) top up mixes or let one thing unspecified. That could be either the oxygen or helium fraction of the final mix or you have to leave open one of the gas fractions of the top up gases.
So what do you do in practice, which component do you leave unspecified?
Update: I updated the script so it can now also handle blending trimix (starting from a partially filled cylinder, you can specify three top up gases it will now calculated the intermediate pressures you have to fill up to). To blend nitrox, specify the target mix as containing no helium and leave one of the top up mixes empty.