code: def grad_and_hess(self):
          
          for i in xrange(self.len):
  
              di = self.diff(i)
              self.grad[i] = di
              self.hess[i, i] = self.diff(i, 2)
  
              if i < self.len - 1:
  
                  for j in xrange(i + 1, self.len):
                      dij = self.diff2(i, j)
  
                      self.hess[i, j] = dij
                      self.hess[j, i] = dij
docs: Computes self's gradient and Hessian. Used if the
          optimization method for a NormApprox doesn't
          use gradients and hessians, for instance fmin.