Necessary and sufficient conditions for functions involving the psi function to be completely monotonic