  A complete analytical solution to the optimal reversal of a macrospin with
easy-axis anisotropy is presented. Optimal control path minimizing the energy
cost of the reversal is identified and used to derive time-dependent direction
and amplitude of the optimal switching field. The minimum energy cost of the
reversal scales inversely with the switching time for fast switching, follows
an exponential asymptotics for slow switching and reaches the lower limit
proportional to the energy barrier between the target states and to the damping
parameter at infinitely long switching time. For a given switching time, the
energy cost is never smaller than that for a free macrospin. This limitation
can be bypassed by adding a hard anisotropy axis which activates the internal
torque in the desired switching direction, thereby significantly reducing the
energy cost. Comparison between the calculated optimal control path and minimum
energy path reveals that optimal control does not translate to the minimization
of the energy barrier, but signifies effective use of the system's internal
dynamics to aid the desired magnetic transition.
