What is the derivative of $(\mathbf{I} - \mathbf{x} \mathbf{x}^T ) \, \mathbf{x}$ with respect to $\mathbf{x}\in \mathbb{R}^n$?
I think the result should in $\mathbb{R}^{n\times n}$, but I failed when calculate the first part.
The first part $\mathbf{I} - \mathbf{xx}^{T}$ is a $n\times n$ matrix and the derivative belongs to $\mathbb{R}^{n^2\times n}$.
So, is there anything wrong with the process?
The mapping $f(x):=(I-xx^T)x$ is a mapping from $\mathbb R^n$ to $\mathbb R^n$. It can be simplified to $$ f(x) = (I-xx^T)x = x - |x|_2^2 x. $$ Its directional derivative at $x$ in direction $h$ is given by $$ f'(x;h) = h - |x|_2^2 h - 2x^Th\cdot x\\ =h - |x|_2^2 h - 2xx^Th\\ =(I-|x|_2^2 I -2xx^T)h. $$ hence the derivative is given by the matrix $$ f'(x) = I-2xx^T- |x|_2^2 I, $$