add a helper function for QP cost to nonlinear prog.