Suppossing $M$ is a $n \times n$ matrix and z is a $n \times 1$ row, and knowing the following identity:
$$ \frac{\partial z^tM}{\partial z} = M $$
I want to solve the following:
$$ \frac{\partial z^tMz}{\partial z} = (M + M^t) z $$
Using the drivative of the product, I know that:
$$ \frac{\partial z^tMz}{\partial z} = \frac{\partial z^tM}{\partial z} \cdot z + z^tM\cdot \frac{\partial z}{\partial z} $$
Using the previous identity I get the following:
$$ M z + z^tM \cdot 1 $$
But I think that's wrong somewhere, because the dimensions of that aren't the same than the expected result.
How can I go on?