Written on January 28, 2019
NOTE: This post is automatically translated from Farsi using GPT 5.5
Now that we have reviewed the initial topics of matrix derivatives together, we can talk about derivatives of general functions defined on matrices — such as the matrix inverse and the determinant.
Let’s start with the derivative of the matrix inverse. When the inverse of a matrix is multiplied by the matrix itself, the result is an identity matrix with the same dimensions as the original matrix. We can start from this very point:
On the other hand, we also had a relation for differentiating the product of two matrix functions:
Substituting into the first relation, we have:
And voilà!
To compute this last one, I used two relations among Kronecker products:
Of course, when the conditions are met. That is, in the first relation, both matrices and must be invertible, since if they are not, the Kronecker product will not be invertible either; and in the second relation, the matrices and must be multipliable, and likewise and . In the second case, these multiplications may not be possible, while it may still be possible to multiply the outputs of the two Kronecker products in the usual matrix sense.
The next function is the determinant function. Computing this one is somewhat more complicated than the first. To obtain the derivative of the determinant, we have to pay attention to the adjugate matrix. The relation between the determinant and the adjugate matrix is very interesting. It is enough to choose any row of the adjugate matrix and multiply it by its corresponding column in the original matrix. The result is the determinant of the original matrix. This means that whatever is (in the range from 1 to the number of columns of the original matrix):
On the other hand, the inverse of a matrix can also be computed using the adjugate matrix:
With these, we can finish the job:
Finally, we put in place of , and that’s it:
If we consider , the result becomes even nicer:
Can you say why?
The last function we address in this section is the inner product of two matrices. The inner product of two matrices is the product of their vectorized forms:
In most texts, we see this last one introduced as the inner product. The reason can be seen quite easily.
If you have paid attention, the number of rows of matrix and the columns of are equal. The reason is that this inner product is defined for such matrices. In principle, is defined on square matrices, and the output of must be square so that can be applied to it.
The derivative of the inner product of two matrices with respect to one of them is, as expected, the transpose of the vectorized form of the other:
This is the same thing we had seen in Calculus II at university for vectors:
After three posts about derivatives with respect to matrices, we have reached a point where we can solve a problem such as estimating the correlation matrix of a Gaussian distribution from samples. We will solve a couple of examples of these problems in the next post, as a fitting conclusion to the topic of differentiation with respect to matrices.