I think this unnecessarily loses precision.  The refractive index calculation is in terms of n-1.  Then we add 1, square it and subtract 1.  It seems like it would be better to keep it as n-1, and then here do `(2*nm1 + nm1**2)`.