Some useful mathematical functions