http://www.mathworks.com/matlabcentral/newsreader/view_thread/276860
MATLAB Central Newsreader  matrix derivative
Feed for thread: matrix derivative
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Fri, 19 Mar 2010 10:04:06 +0000
matrix derivative
http://www.mathworks.com/matlabcentral/newsreader/view_thread/276860#727747
leo nidas
<br>
I am confused with something rather simple which is embarrassing..<br>
<br>
Let G=A(Yμ). <br>
<br>
G is p by 1 matrix depending on β=[β0 β1 β(p1)]'. (β is p by 1)<br>
Α is p by n matrix depending on β<br>
μ is n by 1 matrix depending on β<br>
Υ is n by 1 matrix independent of β<br>
<br>
I thought the derivative of G with respect to β (let dG) would be <br>
<br>
dG=(dA)*(Yμ)Α*dμ.<br>
<br>
which is obviously wrong because the dG should be a p by p matrix.<br>
<br>
Α*dμ is p by p (which is encouraging!)<br>
but (Yμ) is n by 1 and the dimensions would not agree.<br>
<br>
I checked the following:<br>
<br>
<a href="http://en.wikipedia.org/wiki/Matrix_calculus">http://en.wikipedia.org/wiki/Matrix_calculus</a><br>
<br>
but did't get it..<br>
<br>
I checked my calculus book of Ross and Finley and doesn't have anything.<br>
I checked my algebra book of Gilbert Strang and doesn't have anything.<br>
I searched the net with no luck<br>
and I decided to make an example in matlab, so just see how can I get the derivative of a matrix with respect to a vector I typed<br>
<br>
>> syms b0 b1 real<br>
>> b=[b0 b1]';<br>
>> A=[b0*b1 b0*b1];<br>
>> diff(A,'b')<br>
<br>
ans =<br>
<br>
[ 0, 0]<br>
<br>
which is not what I want. diff just fount=d the difference of the elements right? I would like the 2 by 2 derivative matrix of A with respect to b.<br>
<br>
My final goal is to get right the derivative of G=A(Yμ) right. <br>
<br>
Thanx in advance for any answers.

Fri, 19 Mar 2010 11:14:04 +0000
Re: matrix derivative
http://www.mathworks.com/matlabcentral/newsreader/view_thread/276860#727768
Sadik
Hi Leo,<br>
<br>
Please take a look at the following:<br>
<br>
<a href="http://books.google.com/books?id=PDjIV0iWa2cC&pg=PA152&lpg=PA152&dq=%22derivative+of+a+matrix+with+respect+to+a+vector%22&source=bl&ots=kh6gIGOXy1&sig=qZEjAv7Yq9ac61p1aPxt2TTeUc&hl=en&ei=A1ujS_yBAdKztgeRz5ydCg&sa=X&oi=book_result&ct=result&resnum=4&ved=0CBYQ6AEwAw#v=onepage&q=%22derivative%20of%20a%20matrix%20with%20respect%20to%20a%20vector%22&f=false">http://books.google.com/books?id=PDjIV0iWa2cC&pg=PA152&lpg=PA152&dq=%22derivative+of+a+matrix+with+respect+to+a+vector%22&source=bl&ots=kh6gIGOXy1&sig=qZEjAv7Yq9ac61p1aPxt2TTeUc&hl=en&ei=A1ujS_yBAdKztgeRz5ydCg&sa=X&oi=book_result&ct=result&resnum=4&ved=0CBYQ6AEwAw#v=onepage&q=%22derivative%20of%20a%20matrix%20with%20respect%20to%20a%20vector%22&f=false</a><br>
<br>
It basically says that it will be a threedimensional matrix. Each 2D "page" of this 3D matrix will be the derivative of the matrix with respect to an element of the vector. So, if you have an nxn matrix A and an mx1 vector x, the result of the derivative of A with respect to x, dA/dx, would be an nxnxm matrix where <br>
<br>
dA/dx(:,:,1) is dA/dx1<br>
dA/dx(:,:,2) is dA/dx2<br>
<br>
and so on.<br>
<br>
Best.