Setting
$f:\mathbb{R}^n\to\mathbb{R}^n$ and $\|\cdot \|$ be the usual Euclidean norm. I would like to compute the derivative with respect to $x$ of $$ \phi(x) = \frac{f(x)}{\|f(x)\|} $$
My Attempt at a Solution
$$ \nabla_x \frac{f(x)}{||f(x)||} = \frac{\nabla_x f(x)}{||f(x)||} + f(x)\nabla_x\left(f(x)^\top f(x)\right)^{-\frac{1}{2}} = \frac{\nabla_x f(x)}{||f(x)||}-\frac{1}{2}\frac{f(x)}{||f(x)||^3} 2f(x)^\top \nabla_x f(x) = \left(I - \frac{f(x)f(x)^\top}{||f(x)||^2}\right)\frac{\nabla_x f(x)}{||f(x)||} $$ However I am very unsure about this. In particular, I have a feeling that the second term would be $f(x)^\top \nabla_x f(x)$ and hence lead to $$ \nabla_x \frac{f(x)}{||f(x)||} = \frac{\nabla_x f(x)}{||f(x)||} - \frac{\nabla_x f(x)}{||f(x)||} = 0 $$ However this wouldn't make much sense cause surely the gradient is not $0$ for every function.
$ \def\p{{\partial}} \def\grad#1#2{\frac{\p #1}{\p #2}} \def\c#1{\color{red}{#1}} $Separate $f$ into two components: $\;$ its length $(\lambda)$ and direction $(\phi)$ $$\eqalign{ \lambda^2 &= \|f\|^2 &\quad\implies\quad \lambda\,d\lambda = \c{f^Tdf} \\ \phi &= \lambda^{-1} f \\ }$$ Calculate the differential of $\phi$ $$\eqalign{ d\phi &= \lambda^{-1} df - \lambda^{-2}f\,{d\lambda} \\ &= \lambda^{-1} df - \lambda^{-3}f\,{(\lambda\,d\lambda)} \\ &= \lambda^{-1}I\, df - \lambda^{-3}f\,\c{(f^Tdf)} \\ &= \lambda^{-1}\left(I - \phi\phi^T\right)df \\ }$$ Now differentiate with respect to $x$ $$\eqalign{ \grad{\phi}{x} &= \left(\frac{I - \phi\phi^T}{\lambda}\right)\grad{f}{x} \\ }$$ So your initial solution was absolutely correct. And you can prove the famous result about unit vectors being perpendicular to their gradients $$\eqalign{ \phi^T\left(\grad{\phi}{x}\right) &= \left(\frac{\phi^T-({\tt1})\phi^T}{\lambda}\right)\grad{f}{x} \\ &= \left(\frac{0}{\lambda}\right)\grad{f}{x} \\ &= 0 \\ }$$