This paper deals with the compensation of nonlinearities in dynamical systems using nonlinear polynomial autoregressive models with exogenous inputs (NARX). The compensation approach is formulated for static and dynamical contexts, as well as its adaptation to hysteretic systems. In all of these scenarios, identified NARX models are used. The core idea is to rewrite the model as an algebraic polynomial whose roots are potential compensation inputs. A procedure is put forward to choose the most adequate root, in cases where more than one is possible. Both numerical and experimental results are presented to illustrate the method. In the experimental case the method is compared to other approaches. The results show that the proposed methodology can provide compensation input signals that practically linearize the studied systems using simple and representative models with no more than five terms.