Does anyone know of any formula for converting a light frequency to an RGB value?
You're talking about converting from wave length to an RGB value.
Look here, will probably answer your question. Thy have an utility for doing this with the source code as well as some explanation.
Here's a detailed explanation of the entire conversion process: http://www.fourmilab.ch/documents/specrend/. Source code included!
I guess I might as well follow up my comment with a formal answer. The best option is to use the HSV colour space - though the hue represents the wavelength it is not a one-to-one comparison.
I did a linear fit of known hue values and frequencies (dropping out red and violet because they extend so far in frequency values that they skew things a bit) and I got a rough conversion equation.
It goes like
frequency (in THz)=474+(3/4)(Hue Angle (in degrees))
I've tried to look around and see if anyone has come up with this equation, but I haven't found anything as of May 2010.
-David Elm