Add some math functions.

More test cases were added as well.