fixed inc_beta and grad internal math functions