Suppose I have $t$, an $m \times n$ matrix of constants and $w$, an $n \times 1$ column vector.
I want to differentiate $A$, the function of $w$ defined as $$ A(w) = w^Tt^Ttw. $$ I wish to use product rule on the two quantities $w^Tt^t$ and $tw$ so that $$ \frac{\partial A}{\partial w} = \frac{\partial (w^Tt^T)}{\partial w}tw + w^Tt^T\frac{\partial (wt)}{\partial w} =ttw+w^Tt^Tt $$ However the first term, $ttw$ is not dimensionally consistent. What is the issue here?
I believe the issue is that, when working with matrix calculus:
$$ \frac{\partial (My)}{\partial x} \ne \bigg(\frac{\partial M}{\partial x}\bigg)y + M\bigg(\frac{\partial y}{\partial x}\bigg)$$
If you work with differentials, however, the product rule reads:
$$d(My) = \big(dM\big)\,y + M\,\big(dy\big) $$
Thus, introducing the Frobenius inner product as:
$$ A:B = \operatorname{tr}(A^TB)$$
with the following properties derivied from the underlying trace function
$$\eqalign{A:BC &= B^TA:C\cr &= AC^T:B\cr &= A^T:(BC)^T\cr &= BC:A \cr } $$
You can work as you usually do with vectors. Your problem becomes:
$$\eqalign{ f&= w^T T^T T w\\ &= Tw : Tw\\ df &= Tdw : Tw + Tw: Tdw\\ &= Tw : Tdw + Tw : Tdw\\ &= 2(Tw) : Tdw\\ &= 2(T^TTw):dw }$$
Since
$$df = \left(\frac{\partial f}{\partial w}\right):dw$$
You can identify: $$\frac{\partial f}{\partial w}= 2(T^TTw)$$