The optimized integ function.