Optimized calculation of phi inverse.