Derivatives of a vector and its transpose Assuming that $f(x)=x^Tx-k^2=0$ holds for some $k$ and vector $x$, is it possible to derive that
$$
u \nabla f = uIx
$$
where $I$ is the identity matrix and $u$ is a lagrange multiplier?
If I simply derive $f$ with respect to $x$, I get
$$
u\left( Ix + x^T\right)
$$
where I use that $\frac{d}{dx}x^T=I$, but it gives me that annoying extra term $ux^T$. I don't know if I'm doing something wrong or missing a trick where you can somehow ignore the last term.
I'm a bit insecure in all of this, so any help is greatly appreciated!
 A: Please note that almost every discussion about matrix calculus hinges on the conventions you choose. The conventions I'll use here are:


*

*$x$ is a column vector

*The derivative of a scalar with respect to a column vector is a row vector and viceveresa.

*The gradient is a column vector, ie $\nabla f = \frac{\partial f}{\partial x^{T}}$.


This has various consequences:


*

*If $\frac{\partial x^{T}}{\partial x}$ is at the left of a column vector, it transposes it to a row vector.

*If $\frac{\partial x}{\partial x^{T}}$ is at the right of a row vector, it transposes it to a column vector.

*$\frac{\partial x}{\partial x} = \frac{\partial x^{T}}{\partial x^{T}} = I$


Then if we start with your expression
$$f(x) = x^{T}x - k^{2}$$
and we want to get its gradient $\nabla f$, we get
$$\nabla f(x)
= \frac{\partial f}{\partial x^{T}}(x)
= \frac{\partial (x^{T}x)}{\partial x^{T}}\\
= \frac{\partial x^{T}}{\partial x^{T}}x + x^{T}\frac{\partial x}{\partial x^{T}}
=x + x = 2x$$
From this, we immediately have
$$u\nabla f(x) = 2ux$$
so I don't know howw you arrived to

$$u\nabla f(x) = uIx = ux$$

It would be helpful if you gave context for where did you find or how you derived it.
