numerical and analytical gradient

numerical and analytical gradient for gradient search of the optimum
power allocation