Utility math function.