Reputation: 4354
I have two matrices A and B and a matrix C where
C=A/B
Now I want to take the derivative of C which is
(B*dA/dx - A*dB/dx)/B^2
I am not sure how the above is gonna look like. I found somewhere that it could look like
(B/B)*((dA/dx)/B) - (A/B)*(dB/dx)/B
I am confused what sort of operations can I perform. Can I do this
(B/B^2) * (dA/dx) - (A/B^2)*(dB/dx)
I tried the above two and they gave me different results. I am not sure what operations are permitted, in the case of matrices especially multiplication and division. So can anyone please clarify?
Upvotes: 0
Views: 96
Reputation: 47392
I assume that your matrices A
and B
are the same size, and both square. If this is not the case then please let me know.
In that case, A/B
is the same thing as A * inv(B)
. To differentiate this, you use the normal Leibniz rule for differentiation, being careful to keep the products in the same order (since matrix multiplication doesn't commute):
d/dx (A * inv(B)) = dA/dx * inv(B) + A * d(inv(B))/dx
If you check Wikipedia you can find that the derivative of a matrix inverse is
d(inv(B))/dx = -inv(B) * dB/dx * inv(B)
so for the derivative of the product you get
d/dx (A * inv(B)) = dA/dx * inv(B) - A * inv(B) * dB/dx * inv(B)
You can factor out the multiplication by inv(B)
on both sides, giving
d/dx (A * inv(B)) = (dA/dx - A * inv(B) * dB/dx) * inv(B)
and you might now like to write the expression using the Matlab left and right division operators, giving
d/dx (A/B) = (dA/dx - (A/B) * dB/dx) / B
which is the most concise you can make it. In general you don't expect any of A
, B
, dA/dx
or dB/dx
to commute with each other, so you can't simplify this any more. Of course, if in your application you do have some reason that some of those matrices will always commute, then further simplifications may be possible.
Upvotes: 2