Can anyone supply me with the mathematics behind the energy gain/ loss as a photon travels through a gravitational potential difference?
Good old WP is probably a good place to go at least for starters - http://en.wikipedia.org/wiki/Gravitational_redshift
Note the alternate viewpoint in terms of differing clock rates rather than energy gain/loss in the section "Gravitational redshift versus gravitational time dilation"