<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def updateD_G(self, x):
 """ Compute Gradient for update of D See [2] for derivation of Gradient """

        self.precompute(x)
        g = zeros(len(x))
        Ai = zeros(self.A.shape[0])
        for i in range(len(g)):
            Ai = self.A[:, i]
            g[i] = (self.E * (dot(self.AD, outer(self.R[:, i], Ai)) +
                    dot(outer(Ai, self.R[i, :]), self.ADt))).sum()
        return -2 * g