My matrix calculus is entirely self-taught (and the only formal univariate calculus that I had was in high school), so I'm proud to have made it as far as I have. But I am stumped. Here is the problem: $$ y = \mathbf{a^T \Psi b}\\ \mathbf{\Psi} = \left[\begin{array}{cccc} \mathbf{B^TB} \\ & \mathbf{B^TB}\\ && \mathbf{B^TB}\\ \end{array} \right] $$ What is $ \partial y/\partial \mathbf{B}??? $
Assume $\mathbf{a}$ and $\mathbf{b}$ are $P \times 1$ such that $y$ is a scalar. $\mathbf{B}$ is $m\times m$.
Some context: I want to find the gradients for the elements of $\mathbf{B}$, rather than the actual covariance matrices that $\mathbf{B}$ comprises, because this result will be used in an unconstrained optimizer, and I want all real values to be admissible.
I know that a general $\partial y/\partial x$ where $y = \mathbf{X^TX}$ is equal to $2\mathbf{X^T}\partial{\mathbf{X}}/\partial x$. If the elements of $\mathbf{X}$ are just constants, then $\partial{\mathbf{X}}/\partial x$ is just $\mathbf{X}$ with a one somewhere, corresponding to the position of $x$ for whom the derivative is being taken.
Does this imply that the answer is simply $$ \partial y/\partial\mathbf{B} = \mathbf{a}^T\left[\begin{array}{cccc} \mathbf{2B^TI} \\ & \mathbf{2B^TI}\\ && \mathbf{2B^TI}\\ \end{array} \right]\mathbf{b} $$ Seems too easy...