how to calculate derivative of gamma function