The complexity of computing maximal word functions