Fixed error in objective function gradient calculation.

The norm wasn't giving the expected solution to the cost function and thus the
gradient was incorrect. The IPOPT derivative checker now passes.