A Generalized Representation of the Electromagnetic Fields In A Layered Earth