Derivation of energy gradient function for Rayleigh–Taylor instability