Analytic And Machine Learning Methods For Controlling Nonlinearities In Particle Accelerators