Let scalar field $f : \mathbb{R}^n \to \mathbb{R}$ be given by $$f(x) = x^TA^TAx - \lambda( x^T x - 1)$$ where $A$ is an $n \times n$ matrix and $\lambda$ is a scalar. How to compute the gradient $\nabla f$?
I know that it would be the Jacobian matrix (or gradient), but is there a faster way to compute it rather than writing out everything in terms of components and taking partial derivatives?
The reason I ask is my classmate, when we considered this function in class, was able to compute the derivative as $A^T A x - \lambda x$ rather quickly.