Optimization with term on distance epsilon (also filter division by zero).