I googled around and searched inside the forum but I'm still confused about a problem.
I have 2 matrix functions $f,g : \mathbb{R}^{n \times n} \times \mathbb{R}^{a \times b} \rightarrow \mathbb{R}^{n \times n}$. Starting from this, I have the following expression:
$ t(Q, X, Y) = \text{tr}(f(g(Q, X),Y))$
where $\text{tr}$ is the trace operator and $X, Y \in \mathbb{R}^{a \times b}$ and $Q \in \mathbb{R}^{n \times n}$.
How do I evaluate $\frac{\partial t(Q,X, Y)}{\partial X}$ and $\frac{\partial t(Q,X, Y)}{\partial Y}$?
I mean, I would like to know how to correctly apply the chain rule.
* Addition *
I will try to give more information about my problem. Suppose that $a = b = n$ and that $f(A,B) = AB$ and $g(A,B) = BA + AB$ (actually this is only an example of possible functions $f$ and $g$). Then I have that:
$f(g(Q,X),Y) = f(XQ + QX, Y) = XQY + QXY$
Then, using matrix calculus (hoping there are no error!), I have that:
$ \frac{\partial t(Q,X,Y)}{\partial X} = QY + YQ\\ \frac{\partial t(Q,X,Y)}{\partial Y} = XQ + QX$
I can easily compute the result if I know the form of $f$ and $g$. Notice that the derivatives I obtained are in a matrix form. But actually I need to deal with generic functions. And for this reason I need to use the chain rule. The problem is that the chain rule formulas I know are helpful to derive the derivative with respect to a certain element of the matrix $X$ (or $Y$). In this case, I'm not able to have a matrix form of the derivatives.
So, my question is... there is a chain rule formula I'm missing which let me describe these derivatives in a matrix form?
* Addition 2 *
The chain rule formulas that I know are reported here http://en.wikipedia.org/wiki/Matrix_calculus#Scalar-by-matrix_identities (see the 7th row of the table)