Given matrix $A \in \mathbb{R}^{k \times n}$, define scalar field $F : \mathbb{R}^{n}\ \backslash \{ 0\} \to \mathbb{R}$ by $$F(x) := \frac{|Ax|^2}{|x|^2}$$ and find $\nabla F$
I have tried to write it out by the definition of a partial derivative but end up with a mess of an equation.
You can view that as compositions/operations of functions:
Notice first that since for any $h\in\Bbb R^n$, $A(x+h) = Ax + Ah = Ax + Ah + o(h)$, the differential of $A:x\mapsto Ax$ is given by $\mathrm dA(x) = A$ and so $$ ∇A= A^T $$ In particular, $∇ x= I_n$ is the identity. Then, since $|x|^2 = x· x$, by the product rule $∇(|x|^2) = 2\,x$. By the rule for taking differentials of composition of functions you get $\nabla(|Ax|^2)=2\,A^TA\,x$. Now we are ready to compute the result. $$ \nabla\left(\frac{|Ax|^2}{|x|^2}\right) = \frac{2\,|x|^2\,A^TA\,x-2\,|Ax|^2\,x}{|x|^4} = \frac{2}{|x|^2} \,A^TA\,x - \frac{2\,|Ax|^2}{|x|^4}\,x $$