Light refraction in a medium results from energy exchange between the medium and the magnetic field of the light. Formulas of refractive index, that is, the ratio of light speed in vacuum to light speed in the medium, were derived with the inductor model of electron cloud and the law of energy conservation. Refractive indices of several media were calculated using the formulas derived, and the calculated results are in agreement with the results measured. The anisotropy and the nonlinearity of the refractive index are explained with the theory described in this work.