Index of refraction calculation