Implementations of various math functions.