I'm surprised that you don't obtain a unique RGB value for a given wavelength, as your RGB functions are truncated, saturated at 1. For example, in the range 512-548 nm you have the same RGB value: a pure green 0-1-0. Also in the range 611-641 you give constant pure red 1-0-0. I guess the eye should perceive a difference along those ranges, so the results are not realistic. Correct?