calculation for various functions