catch divide by zero exceptions when calculating rho-k

following the scipy implementation,
https://github.com/scipy/scipy/blob/master/scipy/optimize/optimize.py#L8
81