gradient for numerator of second order correlation optimization