Nonlinear control algorithms for electric machines