How do you find the gradient of $f(x)=(a^T x)(b^T x)$ where $a$, $b$, and $x$ are $n$-dimensional vectors?
So, far I tried by taking a derivative with chain rule: $$ D(f(x)) = D[(a^Tx)(b^Tx)] = (a^Tx)D(b^Tx) + (b^Tx)D((a^Tx)^T)$$ which leads me to: $$ (a^Tx)b^T + (b^Tx)(a^Tx)^T$$ but I'm not sure how to proceed.
Some facts and notations before we start deriving the gradient:
Towards this end, we rewrite your function \begin{align} f(x) &= a^T x b^T x\\ &= (a^Tx)^T b^Tx \\ &= a^Tx : b^T x \end{align}
Now, we can obtain the differential first, and then the gradient of $\frac{\partial f(x)}{\partial x}$. \begin{align} df(x) &= \left( a^T dx: b^T x \right) + \left( a^T x: b^T dx \right) \\ &= \left( b^T x : a^T dx \right) + \left( a^T x: b^T dx \right) \\ &= \left( ab^T x : dx \right) + \left( ba^T x: dx \right) \\ \end{align}
Thus, the gradient is \begin{align} \frac{\partial f(x)}{\partial x} = a b^T x + ba^T x. \end{align}