What is the gradient $\nabla_x$ / hessian $\nabla_x^2$ of $\frac{(Ax)^{\top}y}{||Ax||}$ where $A \in \mathbb{R}^{m \, \times \, n}$, $x \in \mathbb{R}^n$ and $y \in \mathbb{R}^m$?
I don't really know how to approach this problem because I don't know how to deal with quotients in matrix calculus.
For convenience, let's define some variables $$\eqalign{ b &= Ax &\implies &db = A\,dx \cr 1 &= \alpha\beta &\implies &d\alpha = -\alpha^2d\beta \cr \beta^2 &= b^Tb &\implies &\beta\,d\beta = b^Tdb=b^TA\,dx \cr &\, &\, &d\beta = \alpha\,b^Tdb=\alpha\,b^TA\,dx = z^TA\,dx \cr z &= \alpha b &\implies &dz =\alpha\,db-b\alpha^3(b^Tdb)=\alpha(I-zz^T)A\,dx \cr \cr}$$ Write the function in terms of these variables and find its differential and gradient $$\eqalign{ f &= y^Tz \cr\cr df &= y^Tdz \cr &= y^T\alpha(I-zz^T)A\,dx \cr &= \alpha(y^T-fz^T)A\,dx \cr \cr g^T=\frac{\partial f}{\partial x^T} &= \alpha(y-fz)^TA \cr\cr }$$ Now find the differential and gradient of the gradient $$\eqalign{ dg^T &= d\alpha(y-fz)^TA -df\,\alpha z^TA -\alpha f\,dz^TA \cr &= -\alpha\,d\beta\,g^T -\alpha(dx^Tg)z^TA -\alpha^2f\,dx^TA^T(I-zz^T)A \cr &= -\alpha\,dx^T\Big(A^Tzg^T +gz^TA +\alpha f(A^TA-A^Tzz^TA)\Big) \cr\cr H = \frac{\partial g^T}{\partial x} &= -\alpha\Big(A^Tzg^T +gz^TA +\alpha f(A^TA-A^Tzz^TA)\Big) \cr \cr}$$ This can be made nicer by introducing yet more variables $$\eqalign{ M &= \alpha A,\,\,\,\,\,\, p = M^Tz \cr }$$ yielding $$\eqalign{ g &= M^Ty-fp \cr H &= fpp^T - pg^T - gp^T - fM^TM \cr }$$