libmath_func refactoring