Help with the derivative of squared Frobenius norm of a scalar

302 Views Asked by At

I've seen and calculated that the derivative of the squared frobenius norm is

$\frac{\partial||AX-B||_F^2}{\partial X}=2A^T(AX-B)$ when X is a matrix.

Is this also the case when X is not a matrix, but a scalar (ex: A.x, each element of A is multiplied with x)? I would think that the trace can't be eliminated in this case and normal matrix derivation rules can't be applied because x isn't a matrix, or do they apply here as well? For example:

$||Ax-B||_F^2 = Tr((Ax-B)^T(Ax-B))= Tr(xA^TAx-B^TAx - xA^TB + B^TB)$

$\frac{\partial||Ax-B||_F^2}{\partial x} = \frac{\partial (x^2Tr(A^TA))}{\partial x} - \frac{\partial (xTr(B^TA))}{\partial x} - \frac{\partial (xTr(A^TB))}{\partial x} = 2xTr(A^TA)-Tr(B^TA)-Tr(A^TB)$

Is this correct?