Accurate computer display of the color and RGB values of a particular wavelength of the visible spectrum is an application of both color and vision science and color display technology. The spectrum incorporates the falloff in sensitivity of vision toward the short and long wavelength limits. The appearance of the spectrum changes depending on the color space used because of the different primary colors and white point of each color space. Unless your display is fairly color accurate, note that the spectrum image may appear degraded by banding; on a color-accurate display, the gradation in the image is smooth.
The CIE 1931 chromaticity diagram is the locus of chromaticity coordinates for each visible wavelength . The chromaticity coordinates of the color space primaries are the vertices of the triangular region that determines the gamut of colors that can be represented in the color space.
For each wavelength , the chromaticity coordinates on the boundary of the color space triangular region are found as the intersection of the dominant wavelength line with the gamut boundary. (This scheme ignores that lines of constant hue are not straight.)
The gamut boundary chromaticity coordinates are converted to XYZ tristimulus values normalized to the Judd–Vos modified CIE 2-degree photopic luminosity curve, , as follows: .
The normalized XYZ tristimulus values are converted to RGB values using the color space XYZ RGB transformation matrix, the resulting RGB values are scaled so that the maximum value is 1, and finally RGB values are scaled by the color space transfer function (gamma adjustment).
For accurate appearance in a color-managed environment, the color space profile must be assigned to the resulting spectrum, for example, in Adobe Photoshop using Edit / Assign Profile. It does not appear to be possible to assign color space profiles within Mathematica.