math_func: refactoring. Linear interpolation is now a separate function