# Verify solution: Is this gradient, correct?

For a function $$f(X)=\operatorname{tr}(X^TAX)+\|\operatorname{diag}(X^TX)-\alpha I\|_2,$$ where all entries are real and $\alpha$ is a real scalar, while $A$ is a p.s.d matrix and $X$ is a real rectangular matrix- I tried to compute the gradient w.r.t $X$.

Is my final solution correct?

Final solution:

$$\nabla f(X)=2AX + 4\operatorname{diag}(X^TX)[\operatorname{diag}(X^TX)-\alpha I]$$

-
The first term looks good, but the second is not. For one thing, where did the 4 come from? Furthermore, the derivative should be undefined when the norm is zero. No way that second term is correct. – Michael Grant Apr 15 '13 at 22:35
@MichaelGrant Can you put forth the derivative for the second term? – halms Apr 15 '13 at 22:59