Math function improvment