Calculates various math functions.