  We analytically determine the optimal microwave field that allows for the
magnetization reversal of a nanomagnet modeled as a macrospin. This is done by
minimizing the total injected energy. The results are in good agreement with
the fields obtained numerically using the optimal control theory. For typical
values of the damping parameter, a weak microwave field is sufficient to induce
switching through a resonant process. The optimal field is orthogonal to the
magnetization direction at any time and modulated both in amplitude and
frequency. The dependence of the pulse shape on the applied field and damping
parameter is interpreted. The total injected energy is found to be
proportionnal to the energy barrier between the initial state and the saddle
point and to the damping parameter. This result may be used as a means for
probing the damping parameter in real nanoparticles.
