Add throwing exceptions in math functions