Suppose I have a vector to vector valued function of the form $$ f_1: Z \mapsto (ZZ^T)^nAZ , \mbox{ and } f_2: Z \mapsto (ZZ^T)^nA $$ where $Z \in \mathbb{R}^n$ and $A$ is an $n$ by $n$ matrix, how would I calculate the derivative of $f_1$ and $f_2$ with respect to $Z$?
I've looked up the matrix cookbook but I am having difficulty...
Hint: $ (ZZ^T)^n A Z = (Z^T Z)^{n-1} (Z^T A Z) Z $