Professional Documents
Culture Documents
The Matrix Cookbook
The Matrix Cookbook
[ http://matrixcookbook.com ]
Kaare Brandt Petersen
Michael Syskind Pedersen
Version: November 15, 2012
Introduction
What is this? These pages are a collection of facts (identities, approximations, inequalities, relations, ...) about matrices and matters relating to them.
It is collected in this form for the convenience of anyone who wants a quick
desktop reference .
Disclaimer: The identities, approximations and relations presented here were
obviously not invented but collected, borrowed and copied from a large amount
of sources. These sources include similar but shorter notes found on the internet
and appendices in books - see the references for a full list.
Errors: Very likely there are errors, typos, and mistakes for which we apologize and would be grateful to receive corrections at [email protected].
Its ongoing: The project of keeping a large repository of relations involving
matrices is naturally ongoing and the version will be apparent from the date in
the header.
Suggestions: Your suggestion for additional content or elaboration of some
topics is most welcome [email protected].
Keywords: Matrix algebra, matrix relations, matrix identities, derivative of
determinant, derivative of inverse matrix, dierentiate a matrix.
Acknowledgements: We would like to thank the following for contributions
and suggestions: Bill Baxter, Brian Templeton, Christian Rishj, Christian
Schr
oppel, Dan Boley, Douglas L. Theobald, Esben Hoegh-Rasmussen, Evripidis
Karseras, Georg Martius, Glynne Casteel, Jan Larsen, Jun Bin Gao, J
urgen
Struckmeier, Kamil Dedecius, Karim T. Abou-Moustafa, Korbinian Strimmer,
Lars Christiansen, Lars Kai Hansen, Leland Wilkinson, Liguo He, Loic Thibaut,
Markus Froeb, Michael Hubatka, Miguel Barao, Ole Winther, Pavel Sakov,
Stephan Hattinger, Troels Pedersen, Vasile Sima, Vincent Rabaud, Zhaoshui
He. We would also like thank The Oticon Foundation for funding our PhD
studies.
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 2
CONTENTS
CONTENTS
Contents
1 Basics
1.1 Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Determinant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 The Special Case 2x2 . . . . . . . . . . . . . . . . . . . . . . . . .
2 Derivatives
2.1 Derivatives
2.2 Derivatives
2.3 Derivatives
2.4 Derivatives
2.5 Derivatives
2.6 Derivatives
2.7 Derivatives
2.8 Derivatives
of
of
of
of
of
of
of
of
a Determinant . . . . . . . . . . . .
an Inverse . . . . . . . . . . . . . . .
Eigenvalues . . . . . . . . . . . . . .
Matrices, Vectors and Scalar Forms
Traces . . . . . . . . . . . . . . . . .
vector norms . . . . . . . . . . . . .
matrix norms . . . . . . . . . . . . .
Structured Matrices . . . . . . . . .
3 Inverses
3.1 Basic . . . . . . . . . . .
3.2 Exact Relations . . . . .
3.3 Implication on Inverses .
3.4 Approximations . . . . .
3.5 Generalized Inverse . . .
3.6 Pseudo Inverse . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
6
6
6
7
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
8
8
9
10
10
12
14
14
14
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
17
17
18
20
20
21
21
4 Complex Matrices
24
4.1 Complex Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2 Higher order and non-linear derivatives . . . . . . . . . . . . . . . 26
4.3 Inverse of complex sum . . . . . . . . . . . . . . . . . . . . . . . 27
5 Solutions and Decompositions
5.1 Solutions to linear equations .
5.2 Eigenvalues and Eigenvectors
5.3 Singular Value Decomposition
5.4 Triangular Decomposition . .
5.5 LU decomposition . . . . . .
5.6 LDM decomposition . . . . .
5.7 LDL decompositions . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
28
28
30
31
32
32
33
33
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
37
37
37
37
37
37
37
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 3
CONTENTS
7.7
7.8
7.9
CONTENTS
Students t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wishart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wishart, Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . .
8 Gaussians
8.1 Basics . . . . . . . .
8.2 Moments . . . . . .
8.3 Miscellaneous . . . .
8.4 Mixture of Gaussians
37
38
39
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
40
40
42
44
44
9 Special Matrices
9.1 Block matrices . . . . . . . . . . . . . . . .
9.2 Discrete Fourier Transform Matrix, The . .
9.3 Hermitian Matrices and skew-Hermitian . .
9.4 Idempotent Matrices . . . . . . . . . . . . .
9.5 Orthogonal matrices . . . . . . . . . . . . .
9.6 Positive Definite and Semi-definite Matrices
9.7 Singleentry Matrix, The . . . . . . . . . . .
9.8 Symmetric, Skew-symmetric/Antisymmetric
9.9 Toeplitz Matrices . . . . . . . . . . . . . . .
9.10 Transition matrices . . . . . . . . . . . . . .
9.11 Units, Permutation and Shift . . . . . . . .
9.12 Vandermonde Matrices . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
46
46
47
48
49
49
50
52
54
54
55
56
57
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
58
58
59
61
61
62
62
63
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
Functions
. . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
A One-dimensional Results
64
A.1 Gaussian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
A.2 One Dimensional Mixture of Gaussians . . . . . . . . . . . . . . . 65
B Proofs and Details
66
B.1 Misc Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 4
CONTENTS
CONTENTS
Matrix
Matrix indexed for some purpose
Matrix indexed for some purpose
Matrix indexed for some purpose
Matrix indexed for some purpose or
The n.th power of a square matrix
The inverse matrix of the matrix A
The pseudo inverse matrix of the matrix A (see Sec. 3.6)
The square root of a matrix (if unique), not elementwise
The (i, j).th entry of the matrix A
The (i, j).th entry of the matrix A
The ij-submatrix, i.e. A with i.th row and j.th column deleted
Vector (column-vector)
Vector indexed for some purpose
The i.th element of the vector a
Scalar
Real part of a scalar
Real part of a vector
Real part of a matrix
Imaginary part of a scalar
Imaginary part of a vector
Imaginary part of a matrix
det(A)
Tr(A)
diag(A)
eig(A)
vec(A)
sup
||A||
AT
A T
A
AH
Determinant of A
Trace of the matrix A
Diagonal matrix of the matrix A, i.e. (diag(A))ij = ij Aij
Eigenvalues of the matrix A
The vector-version of the matrix A (see Sec. 10.2.2)
Supremum of a set
Matrix norm (subscript if any denotes what norm)
Transposed matrix
The inverse of the transposed and vice versa, A T = (A 1 )T = (AT )
Complex conjugated matrix
Transposed and complex conjugated matrix (Hermitian)
A B
AB
0
I
Jij
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 5
Basics
(AB)
(ABC...)
(A )
...C
1 T
(A
A +B
(AB)T
BT A T
(3)
(4)
(5)
...C B A
(A )
(A + B)H
=
=
(A )
AH + BH
(AB)H
BH A H
(ABC...)
(2)
(1)
1
(ABC...)
1.2
(A + B)
1.1
BASICS
(6)
1 H
(7)
(8)
(9)
...C B A
(10)
Trace
Tr(A)
Tr(A)
Aii
(11)
Tr(A)
Pi
Tr(A )
(13)
Tr(AB)
Tr(BA)
(14)
Tr(A + B)
Tr(A) + Tr(B)
(15)
i i,
T
= eig(A)
(12)
Tr(ABC)
Tr(BCA) = Tr(CAB)
(16)
aT a
Tr(aaT )
(17)
Determinant
Let A be an n n matrix.
det(A)
det(cA)
det(AT )
det(A)
det(AB)
i i
= eig(A)
cn det(A),
(18)
if A 2 Rnn
(19)
(20)
det(A) det(B)
(21)
1/ det(A)
(22)
det(An )
det(A)n
(23)
det(A
det(I + uv )
1+u v
(24)
(25)
For n = 2:
For n = 3:
1
det(I + A) = 1 + det(A) + Tr(A) + Tr(A)2
2
1
Tr(A2 )
2
(26)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 6
1.3
BASICS
For n = 4:
det(I + A)
1 + det(A) + Tr(A) +
+Tr(A)2
1
+ Tr(A)3
6
1
2
1
Tr(A2 )
2
1
1
Tr(A)Tr(A2 ) + Tr(A3 )
2
3
(27)
1.3
1 2
" Tr(A2 )
2
(28)
A11
A21
A12
A22
A12 A21
(29)
(30)
Eigenvalues
2
p
Tr(A) + Tr(A)2
=
2
1+
Eigenvectors
v1 /
4 det(A)
2
2
= Tr(A)
1
=
det(A)
=
1 2
A12
A11
1
Inverse
A
Tr(A) + det(A) = 0
v2 /
A22
A21
Tr(A)
Tr(A)2
2
4 det(A)
= det(A)
A12
A11
2
A12
A11
(31)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 7
DERIVATIVES
Derivatives
@x
@xi
=
@y i
@y
@Xkl
=
@Xij
ik lj
@x
@yi
@x
@y
=
i
(32)
@x
@y
=
ij
@xi
@yj
The following rules are general and very useful when deriving the dierential of
an expression ([19]):
@A
@(X)
@(X + Y)
@(Tr(X))
@(XY)
@(X Y)
@(X Y)
@(X 1 )
@(det(X))
@(det(X))
@(ln(det(X)))
@XT
@XH
2.1
2.1.1
=
=
=
=
=
=
=
=
=
=
=
=
=
0
@X
@X + @Y
Tr(@X)
(@X)Y + X(@Y)
(@X) Y + X (@Y)
(@X) Y + X (@Y)
X 1 (@X)X 1
Tr(adj(X)@X)
det(X)Tr(X 1 @X)
Tr(X 1 @X)
(@X)T
(@X)H
(A is a constant)
(33)
(34)
(35)
(36)
(37)
(38)
(39)
(40)
(41)
(42)
(43)
(44)
(45)
Derivatives of a Determinant
General form
@ det(Y)
@x
X @ det(X)
Xjk
@Xik
=
=
det(Y)Tr Y
ij
(46)
@x
det(X)
@ 2 det(Y)
@x2
1 @Y
"
(47)
"
det(Y) Tr Y
@Y
1 @ @x
@x
@Y
+Tr Y 1
Tr Y
@x
1 @Y
Tr Y
Y
@x
#
1 @Y
@x
1 @Y
@x
(48)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 8
2.2
Derivatives of an Inverse
2.1.2
DERIVATIVES
Linear forms
@ det(X)
@X
X @ det(X)
Xjk
@Xik
=
=
det(X)(X
ij
1 T
(49)
det(X)
(50)
@ det(AXB)
@X
2.1.3
det(AXB)(X
1 T
) = det(AXB)(XT )
(51)
Square forms
(52)
(53)
+ AT X(XT AT X)
(54)
2.2
2(X+ )T
(55)
2XT
(56)
1 T
) = (XT )
(X
k det(Xk )X
(57)
(58)
Derivatives of an Inverse
1 @Y
@x
(59)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 9
2.3
Derivatives of Eigenvalues
DERIVATIVES
(X
)ki (X
)jl
(60)
@aT X 1 b
=
X T abT X T
(61)
@X
@ det(X 1 )
=
det(X 1 )(X 1 )T
(62)
@X
@Tr(AX 1 B)
=
(X 1 BAX 1 )T
(63)
@X
@Tr((X + A) 1 )
=
((X + A) 1 (X + A) 1 )T
(64)
@X
From [32] we have the following result: Let A be an n n invertible square
matrix, W be the inverse of A, and J(A) is an n n -variate and dierentiable
function with respect to A, then the partial dierentials of J with respect to A
and W satisfy
@J
@J
= A T
A T
@A
@W
2.3
Derivatives of Eigenvalues
@ X
@
eig(X) =
Tr(X) = I
(65)
@X
@X
@ Y
@
eig(X) =
det(X) = det(X)X T
(66)
@X
@X
If A is real and symmetric, i and vi are distinct eigenvalues and eigenvectors
of A (see (276)) with viT vi = 1, then [33]
@
@vi
2.4
2.4.1
=
=
viT @(A)vi
( iI
(67)
A) @(A)vi
(68)
@aT x
@x
abT
(70)
baT
(71)
@aT XT a
@X
Jij
(69)
aaT
(72)
(73)
im (A)nj
(Jmn A)ij
(74)
in (A)mj
(Jnm A)ij
(75)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 10
2.4
2.4.2
DERIVATIVES
Second Order
@ X
Xkl Xmn
@Xij
@bT XT Xc
@X
@(Bx + b)T C(Dx + d)
@x
@(XT BX)kl
@Xij
@(XT BX)
@Xij
Xkl
(76)
X(bcT + cbT )
(77)
BT C(Dx + d) + DT CT (Bx + b)
(78)
klmn
kl
=
=
lj (X
B)ki +
kj (BX)il
XT BJij + Jji BX
(79)
(Jij )kl =
ik jl
(80)
See Sec 9.7 for useful properties of the Single-entry matrix Jij
@xT Bx
@x
@bT XT DXc
@X
@
(Xb + c)T D(Xb + c)
@X
(B + BT )x
(81)
DT XbcT + DXcbT
(82)
(D + DT )(Xb + c)bT
(83)
2AT W(x
=
=
2W(x
=
=
s)
2W(x
2W(x
As)
(84)
(85)
s)
(86)
As)
(87)
As)sT
2W(x
(88)
xH b)2
@x
2b(a
xH b)
(89)
1 r
)kl
(90)
n
X1
@ T n
a X b=
(Xr )T abT (Xn
@X
r=0
1 r T
(91)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 11
2.5
Derivatives of Traces
@ T n T n
a (X ) X b
@X
n
X1 h
Xn
1 r
DERIVATIVES
abT (Xn )T Xr
r=0
1 r T
(92)
T
T
@ T
@s
@r
s Ar =
Ar +
AT s
(93)
@x
@x
@x
@ (Ax)T (Ax)
@x (Bx)T (Bx)
=
=
2.4.4
@ xT AT Ax
@x xT BT Bx
AT Ax
xT AT AxBT Bx
2 T
2
x BBx
(xT BT Bx)2
(94)
(95)
Using the above we have for the gradient and the Hessian
f
@f
rx f =
@x
@2f
@x@xT
2.5
xT Ax + bT x
(96)
(A + AT )x + b
(97)
A + AT
(98)
Derivatives of Traces
First Order
@
Tr(X)
@X
@
Tr(XA)
@X
@
Tr(AXB)
@X
@
Tr(AXT B)
@X
@
Tr(XT A)
@X
@
Tr(AXT )
@X
@
Tr(A X)
@X
(99)
AT
(100)
A T BT
(101)
BA
(102)
(103)
(104)
Tr(A)I
(105)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 12
2.5
Derivatives of Traces
2.5.2
DERIVATIVES
Second Order
@
Tr(X2 )
@X
@
Tr(X2 B)
@X
@
Tr(XT BX)
@X
@
Tr(BXXT )
@X
@
Tr(XXT B)
@X
@
Tr(XBXT )
@X
@
Tr(BXT X)
@X
@
Tr(XT XB)
@X
@
Tr(AXBX)
@X
@
Tr(XT X)
@X
@
Tr(BT XT CXB)
@X
@
Tr XT BXC
@X
@
Tr(AXBXT C)
@X
h
i
@
Tr (AXB + C)(AXB + C)T
@X
@
Tr(X X)
@X
2XT
(106)
(XB + BX)T
(107)
BX + BT X
(108)
BX + BT X
(109)
BX + BT X
(110)
XBT + XB
(111)
XBT + XB
(112)
XBT + XB
(113)
AT XT BT + BT XT AT
(114)
@
Tr(XXT )
@X
(115)
CT XBBT + CXBBT
(116)
BXC + BT XCT
(117)
AT CT XBT + CAXB
(118)
(119)
@
Tr(X)Tr(X) = 2Tr(X)I(120)
@X
k(Xk
2X
See [7].
2.5.3
Higher Order
@
Tr(Xk )
@X
@
Tr(AXk )
@X
T T
T
@
@X Tr B X CXX CXB
k
X1
1 T
(Xr AXk
(121)
r 1 T
(122)
r=0
CXXT CXBBT
+CT XBBT XT CT X
+CXBBT XT CX
+CT XXT CT XBBT
(123)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 13
2.6
Other
@
Tr(AX 1 B) = (X 1 BAX 1 )T =
@X
Assume B and C to be symmetric, then
DERIVATIVES
2.5.4
h
@
Tr (XT CX)
@X
@
Tr (XT CX)
@X
h
@
Tr (A + XT CX)
@X
(XT BX)
(XT BX)
A T BT X
(CX(XT CX)
2CX(XT CX)
(124)
+2BX(XT CX)
2CX(A + XT CX)
XT BX(A + XT CX)
1
2.6
2.6.1
cos(X)T
Two-norm
a||2 =
x a
||x a||2
@ x a
I
=
@x kx ak2
kx ak2
(x
a)(x a)T
kx ak32
@||x||22
@||xT x||2
=
= 2x
@x
@x
2.7
(128)
(129)
(130)
(131)
Frobenius norm
@
@
||X||2F =
Tr(XXH ) = 2X
(132)
@X
@X
See (248). Note that this is also a special case of the result in equation 119.
2.8
(127)
See [7].
(125)
(126)
+2BX(A + XT CX)
@Tr(sin(X))
@X
Assume that the matrix A has some structure, i.e. symmetric, toeplitz, etc.
In that case the derivatives of the previous section does not apply in general.
Instead, consider the following general rule for dierentiating a scalar function
f (A)
"
#
T
X @f @Akl
df
@f
@A
=
= Tr
(133)
dAij
@Akl @Aij
@A
@Aij
kl
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 14
2.8
DERIVATIVES
(134)
If A has no special structure we have simply Sij = Jij , that is, the structure
matrix is simply the single-entry matrix. Many structures have a representation
in singleentry matrices, see Sec. 9.7.6 for more examples of structure matrices.
2.8.1
(135)
Then the Chain Rule can then be written the following way:
M
@g(U)
@g(U) X X @g(U) @ukl
=
=
@X
@xij
@ukl @xij
(136)
k=1 l=1
(137)
Symmetric
df
@f
@f
=
+
dA
@A
@A
diag
@f
@A
(138)
A + AT
det(X)(2X
(X
2X
I)
(X
I))
(139)
(140)
(141)
Diagonal
A I
(142)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 15
2.8
2.8.4
DERIVATIVES
Toeplitz
Like symmetric matrices and diagonal matrices also Toeplitz matrices has a
special structure which should be taken into account when the derivative with
respect to a matrix with Toeplitz structure.
@Tr(AT)
@T
@Tr(TA)
2 @T
6
6
6
6
6
4
(143)
Tr(A)
Tr([AT ]n1 )
Tr([AT ]1n ))
Tr(A)
Tr([[AT ]1n ]n
.
.
1)
.
.
.
.
.
.
.
.
.
.
1,2 )
.
.
.
.
.
.
1)
.
.
.
An1
.
.
.
Tr([[AT ]1n ]n
.
.
Tr([AT ]1n ))
1,2 )
Tr([AT ]n1 )
Tr(A)
(A)
7
7
7
7
7
5
As it can be seen, the derivative (A) also has a Toeplitz structure. Each value
in the diagonal is the sum of all the diagonal valued in A, the values in the
diagonals next to the main diagonal equal the sum of the diagonal next to the
main diagonal in AT . This result is only valid for the unconstrained Toeplitz
matrix. If the Toeplitz matrix also is symmetric, the same derivative yields
@Tr(AT)
@Tr(TA)
=
= (A) + (A)T
@T
@T
(A) I
(144)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 16
3
3.1
3.1.1
INVERSES
Inverses
Basic
Definition
The inverse A
AA
=A
A = I,
(145)
cof(A, 1, n)
6
7
6
7
6
7
..
..
cof(A) = 6
7
.
cof(A,
i,
j)
.
6
7
4
5
cof(A, n, 1)
cof(A, n, n)
(146)
(147)
(148)
Determinant
=
=
n
X
j=1
n
X
(149)
(150)
j=1
3.1.4
Construction
1
adj(A)
det(A)
(151)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 17
3.2
Exact Relations
3.1.5
INVERSES
Condition number
The condition number of a matrix c(A) is the ratio between the largest and the
smallest singular value of a matrix (see Section 5.3 on singular values),
d+
d
c(A) =
(152)
The condition number can be used to measure how singular a matrix is. If the
condition number is large, it indicates that the matrix is nearly singular. The
condition number can also be estimated from the matrix norms. Here
c(A) = kAk kA
k,
(153)
where k k is a norm such as e.g the 1-norm, the 2-norm, the 1-norm or the
Frobenius norm (see Sec 10.4p
for more on matrix norms).
The 2-norm of A equals (max(eig(AH A))) [12, p.57]. For a symmetric
matrix, this reduces to ||A||2 = max(|eig(A)|) [12, p.394]. If the matrix is
symmetric and positive definite, ||A||2 = max(eig(A)). The condition number
based on the 2-norm thus reduces to
kAk2 kA
3.2
3.2.1
k2 = max(eig(A)) max(eig(A
)) =
max(eig(A))
.
min(eig(A))
(154)
Exact Relations
Basic
(AB)
3.2.2
=B
(155)
The Woodbury identity comes in many variants. The latter of the two can be
found in [12]
(A + CBCT )
(A + UBV)
=
=
C(B
U(B
+ CT A
+ VA
C)
U)
CT A
VA
(156)
(157)
+ BT R
B)
BT R
= PBT (BPBT + R)
(158)
(159)
=A
B(I + CA
B)
CA
Sherman-Morrison
(A + bcT )
=A
A 1 bcT A 1
1 + cT A 1 b
(160)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 18
3.2
Exact Relations
3.2.5
INVERSES
(I + A
T
+B
A(A + I)
1
A(A + B)
+B
(I + AB)
A(I + BA)
(I + AB)
=
=
B(A + B)
(A + B)B
A(I + BA)
B)
B = B(A + B)
1
B
A
B(I + B A
A(A + B)
(161)
T
3.2.6
(A + BB )
(A
(162)
1
(163)
(164)
(165)
(166)
(167)
(X
=
T
T
v XA
vT v vT XAXT v
3.2.7
1
vT v vT XAXT v
(168)
1 + d T A+ c
+
A c
(A+ )T d
w
m
=
=
(I
(I
(169)
(170)
(171)
AA )c
+
A A) d
(172)
(173)
the solution is given as six dierent cases, depending on the entities ||w||,
||m||, and . Please note, that for any (column) vector v it holds that v+ =
vT
vT (vT v) 1 = ||v||
2 . The solution is:
Case 1 of 6: If ||w|| =
6 0 and ||m|| =
6 0. Then
G
=
=
=
=
(174)
(175)
= 0. Then
vv+ A+ (m+ )T nT
1
1
vvT A+
mnT
2
||v||
||m||2
(176)
(177)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 19
3.3
Implication on Inverses
mv A
6= 0. Then
||v||2 ||m||2 + | |2
||v||2
Case 4 of 6: If ||w|| =
6 0 and ||m|| = 0 and
G
A+ nwT
6= 0. Then
||n||2 ||w||2 + | |2
(A ) v + n
(178)
||w||2
A+ n + v
(179)
(180)
||n||2
w+n
(181)
= 0. Then
=
=
3.3
+ T
= 0. Then
||m||2
A+ nn+ vw+
1
1
A+ nnT
vwT
||n||2
||w||2
=
=
G=
m+v
INVERSES
(182)
(183)
Implication on Inverses
If
(A + B)
=A
+B
then
AB
A = BA
(184)
See [25].
3.3.1
A PosDef identity
+ BT R
B)
BT R
= PBT (BPBT + R)
(185)
See [30].
3.4
Approximations
The following identity is known as the Neuman series of a matrix, which holds
when | i | < 1 for all eigenvalues i
(I
A)
1
X
An
(186)
( 1)n An
(187)
n=0
which is equivalent to
1
(I + A)
1
X
n=0
i,
A)
(I + A)
(I
I + A + A2
(188)
(189)
A+A
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 20
3.5
Generalized Inverse
INVERSES
The following approximation is from [22] and holds when A large and symmetric
A
If
A(I + A)
A
=I
(190)
(Q +
M)
=Q
MQ
(191)
Proof:
2
(Q +
1
Q+
((I +
Q
(I +
(192)
Q)
(193)
)Q)
(194)
MQ
MQ
M)
MQ
(195)
3.5
3.5.1
(I
MQ
(I +
+(
MQ
MQ
1 2
...)
(196)
Q
(197)
Definition
The matrix A
3.6.1
MQ
Generalized Inverse
3.6
is not unique.
Pseudo Inverse
Definition
AA+ A = A
II
A+ AA+ = A+
III
AA+ symmetric
IV
A+ A symmetric
The matrix A+ is unique and does always exist. Note that in case of complex matrices, the symmetric condition is substituted by a condition of being
Hermitian.
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 21
3.6
Pseudo Inverse
3.6.2
INVERSES
Properties
(AT )+
(A+ )T
(200)
+ H
(201)
H +
(A )
(199)
(A )
(A )
(202)
(A+ A)AH
AH
(203)
6=
(A )
+
(A A)A
(204)
(cA)
(1/c)A
A+
T
(A A)
T +
(AA )
A+
A
H
(A A)
H +
(AA )
f (AA )
(A A) A
(206)
AT (AAT )+
(207)
T +
A (A )
T +
(A ) A
H
(208)
(209)
(A A) A
(210)
AH (AAH )+
(211)
H +
A (A )
H +
(A ) A
(212)
(213)
(A AB) (ABB )
f (0)I
A+ [f (AAH )
(AB)
f (AH A)
(205)
T
f (0)I
A[f (A A)
+ +
(214)
f (0)I]A
(215)
(216)
f (0)I]A
where A 2 Cnm .
Assume A to have full rank, then
(AA+ )(AA+ )
AA+
(A A)(A A)
A A
Tr(AA+ )
rank(AA+ )
Tr(A A)
(217)
(218)
+
(See [26])
(219)
(See [26])
(220)
rank(A A)
A B
(221)
(222)
Construction
Square
Broad
Tall
rank(A) = n
rank(A) = n
rank(A) = m
)
)
)
A+ = A 1
A+ = AT (AAT ) 1
A+ = (AT A) 1 AT
The so-called broad version is also known as right inverse and the tall version as the left inverse.
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 22
3.6
Pseudo Inverse
INVERSES
Assume A does not have full rank, i.e. A is n m and rank(A) = r <
min(n, m). The pseudo inverse A+ can be constructed from the singular value
decomposition A = UDVT , by
A+ = Vr Dr 1 UTr
(223)
where Ur , Dr , and Vr are the matrices with the degenerated rows and columns
deleted. A dierent way is this: There do always exist two matrices C n r
and D r m of rank r, such that A = CD. Using these matrices it holds that
A+ = DT (DDT )
(CT C)
CT
(224)
See [3].
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 23
COMPLEX MATRICES
Complex Matrices
<r
<p
=p
<q
=
=r
=p <p
=q
4.1
(225)
Complex Derivatives
df (z)
=
dz
or in a more compact form:
@f (z)
@f (z)
=i
.
@=z
@<z
(226)
(227)
(228)
@f (z)
.
@=z
(229)
df (z)
1 @f (z)
@f (z)
=
+i
.
dz
2 @<z
@=z
(230)
=
=
df (z)
dz
@f (z)
@f (z)
+i
.
@<z
@=z
(232)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 24
4.1
Complex Derivatives
COMPLEX MATRICES
=
=
df (Z)
dZ
@f (Z)
@f (Z)
+i
.
@<Z
@=Z
(233)
The chain rule is a little more complicated when the function of a complex
u = f (x) is non-analytic. For a non-analytic function, the following chain rule
can be applied ([7])
@g(u)
@x
=
=
@g @u
@g @u
+
@u @x @u @x
@g @u @g @u
+
@u @x
@u
@x
(234)
Notice, if the function is analytic, the second term reduces to zero, and the function is reduced to the normal well-known chain rule. For the matrix derivative
of a scalar function g(U), the chain rule can be written the following way:
T
T
Tr(( @g(U)
Tr(( @g(U)
@g(U)
@U ) @U)
@U ) @U )
=
+
.
@X
@X
@X
4.1.2
(235)
If the derivatives involve complex numbers, the conjugate transpose is often involved. The most useful way to show complex derivative is to show the derivative
with respect to the real and the imaginary part separately. An easy example is:
@Tr(X )
@Tr(XH )
=
@<X
@<X
@Tr(X )
@Tr(XH )
i
=i
@=X
@=X
(236)
(237)
Since the two results have the same sign, the conjugate complex derivative (230)
should be used.
@Tr(X)
@Tr(XT )
=
@<X
@<X
@Tr(X)
@Tr(XT )
i
=i
@=X
@=X
=
=
(238)
I
(239)
Here, the two results have dierent signs, and the generalized complex derivative
(229) should be used. Hereby, it can be seen that (100) holds even if X is a
complex number.
@Tr(AXH )
@<X
@Tr(AXH )
i
@=X
(240)
(241)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 25
4.2
COMPLEX MATRICES
AT
(242)
AT
(243)
@Tr(XXH )
@Tr(XH X)
=
@<X
@<X
H
@Tr(XX )
@Tr(XH X)
i
=i
@=X
@=X
2<X
(244)
i2=X
(245)
By inserting (244) and (245) in (229) and (230), it can be seen that
@Tr(XXH )
= X
@X
@Tr(XXH )
=X
@X
(246)
(247)
Since the function Tr(XXH ) is a real function of the complex matrix X, the
complex gradient matrix (233) is given by
rTr(XXH ) = 2
4.1.3
@Tr(XXH )
= 2X
@X
(248)
=
=
1 @ det(XH AX)
@ det(XH AX)
i
2
@<X
@=X
T
det(XH AX) (XH AX) 1 XH A
(249)
=
=
4.2
1 @ det(XH AX)
@ det(XH AX)
+i
2
@<X
@=X
det(XH AX)AX(XH AX) 1
(250)
=
=
@ xH AH Ax
@x xH BH Bx
AH Ax
xH AH AxBH Bx
2 H
2
x BBx
(xH BH Bx)2
(251)
(252)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 26
4.3
4.3
COMPLEX MATRICES
Given real matrices A, B find the inverse of the complex sum A + iB. Form
the auxiliary matrices
E
A + tB
(253)
(254)
=
=
(1
(1
tA,
exists. Then
1
it)(E + iF)
(255)
1
it)((E + FE
(1
it)(E + FE
(E + FE
F)
((I
(E + FE
F)
(I
i(E + FE
F)
F)
F)
1
1
(I
tFE
tFE
F)
FE
i(tI + FE
))
i(E + FE
iFE
1
1
)(256)
(257)
(258)
(tI + FE
(259)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 27
5
5.1
5.1.1
Assume we have data (xn , yn ) for n = 1, ..., N and are seeking the parameters
a, b 2 R such that yi
= axi + b. With a least squares error function, the optimal
values for a, b can be expressed using the notation
x = (x1 , ..., xN )T
y = (y1 , ..., yN )T
and
as
5.1.2
Rxx = xT x
Rx1 = xT 1 R11 = 1T 1
Ryx = yT x
Ry1 = yT 1
a
b
Rxx
Rx1
Rx1
R11
Rx,y
Ry1
(260)
(261)
Solution
Unique solution x
Many solutions x
No solutions x
Standard Square
x=A
(262)
Degenerated Square
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 28
5.1
5.1.5
Cramers rule
The equation
Ax = b,
(263)
where A is square has exactly one solution x if the ith element in x can be
found as
det B
xi =
,
(264)
det A
where B equals A, but the ith column in A has been substituted by b.
5.1.6
Over-determined Rectangular
x = (AT A)
AT b = A+ b
(265)
Under-determined Rectangular
xmin = AT (AAT )
(267)
The equation have many solutions x. But xmin is the solution which minimizes
||Ax b||2 and also the solution with the smallest norm ||x||2 . The same holds
for a matrix version: Assume A is n m, X is m n and B is n n, then
)
AX = B
Xmin = A+ B
(268)
The equation have many solutions X. But Xmin is the solution which minimizes
||AX B||2 and also the solution with the smallest norm ||X||2 . See [3].
Similar but dierent: Assume A is square n n and the matrices B0 , B1
are n N , where N > n, then if B0 has maximal rank
AB0 = B1
(269)
where Amin denotes the matrix which is optimal in a least square sense. An
interpretation is that A is the linear approximation which maps the columns
vectors of B0 into the columns vectors of B1 .
5.1.8
5.1.9
8x
A=0
(270)
If A is symmetric, then
xT Ax = 0,
8x
A=0
(271)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 29
5.2
5.1.10
vec(X)
(I A + BT I)
(272)
1
vec(C)
(273)
Sec 10.2.1 and 10.2.2 for details on the Kronecker product and the vec operator.
5.1.11
Encapsulating Sum
P
n An XBn
vec(X)
C
P
(274)
T
n Bn
An
vec(C)
(275)
See Sec 10.2.1 and 10.2.2 for details on the Kronecker product and the vec
operator.
5.2
5.2.1
Avi =
5.2.2
i vi
(276)
Decompositions
(277)
For defective matrices A, which is matrices which has fewer distinct eigenvalues
than dimensions, the following decomposition called Jordan canonical form,
holds
AV = VJ
(278)
where J is a block diagonal matrix with the blocks Ji = i I + N. The matrices
Ji have dimensionality as the number of identical eigenvalues equal to i , and N
is square matrix of same size with 1 on the super diagonal and zero elsewhere.
It also holds that for all matrices A there exists matrices V and R such that
AV = VR
where R is upper triangular with the eigenvalues
5.2.3
(279)
i
on its diagonal.
General Properties
eig(BA)
rank(A) = r
At most r non-zero
(280)
i
(281)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 30
5.3
5.2.4
Symmetric
R
P
p
i i
Tr(A )
eig(I + cA)
eig(A
cI)
1
eig(A
(i.e. V is orthogonal)
(282)
(i.e.
(283)
1+c
is real)
(284)
(285)
(286)
(287)
(288)
Characteristic polynomial
=
=
det(A
n
I)
g1
n 1
(289)
+ g2
n 2
... + ( 1) gn
(290)
Note that the coefficients gj for j = 1, ..., n are the n invariants under rotation
of A. Thus, gj is the sum of the determinants of all the sub-matrices of A taken
j rows and columns at a time. That is, g1 is the trace of A, and g2 is the sum
of the determinants of the n(n 1)/2 sub-matrices that can be formed from A
by deleting all but two rows and columns, and so on see [17].
5.3
A = UDVT ,
where
5.3.1
U
D
V
=
=
=
(291)
eigenvectors of AAT
p
diag(eig(AAT ))
eigenvectors of AT A
nn
nm
mm
(292)
T
A = V
D
V
,
(293)
UT
(294)
where D is diagonal with the square root of the eigenvalues of AAT , V is the
eigenvectors of AAT and UT is the eigenvectors of AT A.
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 31
5.4
Triangular Decomposition
5.3.3
D 0
U
A = V V
,
0 D
UT
(295)
Rectangular decomposition I
Assume A is n m, V is n n, D is n n, UT is n m
A
D
UT
= V
,
(296)
where D is diagonal with the square root of the eigenvalues of AAT , V is the
eigenvectors of AAT and UT is the eigenvectors of AT A.
5.3.5
Rectangular decomposition II
Assume A is n m, V is n m, D is m m, UT is m m
2
32
4
54
A
V
D
UT
=
5.3.6
3
5
(297)
Assume A is n m, V is n n, D is n m, UT is m m
2
3
4
5,
A
D
UT
= V
(298)
where D is diagonal with the square root of the eigenvalues of AAT , V is the
eigenvectors of AAT and UT is the eigenvectors of AT A.
5.4
Triangular Decomposition
5.5
LU decomposition
(299)
Cholesky-decomposition
(300)
5.6
5.6
LDM decomposition
LDM decomposition
(301)
where L, M are unique unit lower triangular matrices and D is a unique diagonal
matrix.
5.7
LDL decompositions
The LDL decomposition are special cases of the LDM decomposition. Assume
A is a non-singular symmetric definite square matrix, then
A = LDLT = LT DL
(302)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 33
6.1
Definition of Moments
Mean
(303)
Covariance
hxi i)(xj
hxj i)i
(304)
or alternatively as
M = h(x
6.1.3
m)(x
m)T i
(305)
Third moments
mijk = h(xi
as
hxi i)(xj
hxj i)(xk
hxk i)i
h
i
(3) (3)
M3 = m::1 m::2 ...m(3)
::n
(306)
(307)
where : denotes all elements within the given index. M3 can alternatively be
expressed as
M3 = h(x m)(x m)T (x m)T i
(308)
6.1.4
Fourth moments
mijkl = h(xi
hxi i)(xj
hxj i)(xk
hxk i)(xl
hxl i)i
(309)
as
h
i
(4)
(4)
(4)
(4)
(4)
(4)
(4)
(4)
M4 = m::11 m::21 ...m::n1 |m::12 m::22 ...m::n2 |...|m::1n m::2n ...m(4)
::nn
(310)
or alternatively as
M4 = h(x
m)(x
m)T (x
m)T (x
m)T i
(311)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 34
6.2
6.2
6.2.1
Linear Forms
Var[Ax]
Cov[Ax, By]
AE[X]B + C
AVar[x]A
(312)
(313)
ACov[x, y]B
(314)
6.2.2
E[Ax + b]
Am + b
(315)
E[Ax]
Am
(316)
E[x + b]
m+b
(317)
Quadratic Forms
Tr(A) + cT Ac
222 Tr(A2 ) + 42 cT A2 c + 43 cT Aa + (4
Var[x Ax]
(318)
322 )aT a (319)
E[xx ]
E[xaT x]
=
=
M + mm
(M + mmT )a
E[xT axT ]
aT (M + mmT )
E[(Ax)(Ax) ]
E[(x + a)(x + a) ]
(320)
(321)
(322)
A(M + mm )A
(323)
T
(324)
M + (m + a)(m + a)
(325)
E[xT x]
Tr(M) + mT m
Tr(AM) + mT Am
E[x Ax]
T
E[(Ax) (Ax)]
T
E[(x + a) (x + a)]
=
=
(327)
(328)
T
Tr(M) + (m + a) (m + a)
(329)
(330)
See [7].
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 35
6.3
6.2.3
Cubic Forms
Adiag(BT C)v3
+Tr(BMCT )(Am + a)
+AMCT (Bm + b)
+(AMBT + (Am + a)(Bm + b)T )(Cm + c)
T
E[xx x]
Adiag(AT A)v3
+[2AMAT + (Ax + a)(Ax + a)T ](Am + a)
+Tr(AMAT )(Am + a)
6.3
h(y
h(y
h(y
hyi
wT m
(331)
w M2 w
(332)
hyi)3 i
w T M3 w w
(333)
hyi) i
4
hyi) i
w M4 w w w
(334)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 36
MULTIVARIATE DISTRIBUTIONS
Multivariate Distributions
7.1
Cauchy
P/2
( 1+P
2 )
(1/2) 1 + (t
det()
1
)T
1/2
(t
(1+P )/2
(335)
where is the location, is positive definite, and denotes the gamma function. The Cauchy distribution is a special case of the Student-t distribution.
7.2
Dirichlet
P
P
p p Y 1
p(x|) = QP
xp p
(
)
p
p
p
7.3
Normal
7.4
Normal-Inverse Gamma
7.5
Gaussian
See sec. 8.
7.6
Multinomial
If the vector n contains counts, i.e. (n)i 2 0, 1, 2, ..., then the discrete multinomial disitrbution for n is given by
d
P (n|a, n) =
7.7
d
X
Y
n!
a ni ,
n1 ! . . . nd ! i i
Students t
ni = n
(336)
ai = 1.
P/2
( +P
2 )
(/2) 1 +
det()
1 (t
)T
1/2
1
(t
(+P )/2
(337)
7.8
Wishart
7.7.1
MULTIVARIATE DISTRIBUTIONS
Mean
E(t) = ,
7.7.2
(338)
Variance
cov(t) =
7.7.3
>1
>2
(339)
Mode
The notion mode meaning the position of the most probable value
mode(t) =
7.7.4
(340)
N P/2
P
Y
p=1
[( + P p + 1)/2]
[( p + 1)/2]
det 1 + (T M) 1 (T
M)T
(+P )/2
(341)
7.8
Wishart
2mP/2 P (P
1)/4
1
QP
p
[ 12 (m + 1
1
exp
Tr( 1 M)
2
7.8.1
p)]
1)/2
(342)
Mean
E(M) = m
(343)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 38
7.9
Wishart, Inverse
7.9
MULTIVARIATE DISTRIBUTIONS
Wishart, Inverse
The (normal) Inverse Wishart distribution for M 2 RP P , M is positive definite, where m can be regarded as a degree of freedom parameter [11]
p(M|, m)
2mP/2 P (P
1)/4
1
QP
[ 12 (m + 1
det()m/2 det(M) (m
1
exp
Tr(M 1 )
2
7.9.1
p)]
1)/2
(344)
Mean
E(M) =
1
P
(345)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 39
8
8.1
8.1.1
GAUSSIANS
Gaussians
Basics
Density and normalization
1
(x
2
Z
1
exp
(x m)T 1 (x m) dx
2
Z
1 T
exp
x 1 x + mT 1 x dx
2
Z
1 T
exp
x Ax + cT x dx
2
m)T
(x
m)
(346)
=
=
=
p
det(2)
p
1
det(2) exp mT 1 m
2
p
1
1
det(2A ) exp cT A T c
2
Z
p
1
exp
Tr(XT AX) + Tr(CT X) dX = det(2A
2
1)
exp
1
Tr(CT A
2
C)
=
=
p(x) 1 (x
p(x) 1 (x
m)
m)(x
(347)
m)T
a
Tc
c
b
(348)
Marginal Distribution
Assume x Nx (, ) where
xa
a
x=
=
xb
b
(349)
then
8.1.3
p(xa )
p(xb )
Nxa (a , a )
(350)
Nxb (b , b )
(351)
Conditional Distribution
Assume x Nx (, ) where
xa
a
x=
=
xb
b
a
Tc
c
b
(352)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 40
8.1
Basics
GAUSSIANS
then
n
a = a + c b 1 (xb
a = a c 1 T
c
b
n
T
1
b = b + c a (xa
b = b T 1 c
c
a
a)
p(xa |xb ) = Nxa (
a ,
b)
p(xb |xa ) = Nxb (
b ,
b )
(353)
a )
(354)
Note, that the covariance matrices are the Schur complement of the block matrix, see 9.1.5 for details.
8.1.4
Linear combination
(355)
8.1.5
1)
Nx [A
m, (AT
A)
(356)
1
Nx [A
| det(A)|
m, (AT
A)
(357)
If A is symmetric, then
1 T
x Ax + bT x
2
1
Tr(XT AX) + Tr(BT X)
2
8.1.7
1
(x A 1 b)T A(x A
2
1
Tr[(X A 1 B)T A(X
2
1
b) + bT A 1 b
2
1
1
A B)] + Tr(BT A
2
=
c 1
mc
m1 )T 1 1 (x
m1 )
(358)
m2 )T 2 1 (x
m2 )
(359)
mc )T c 1 (x
mc ) + C
(360)
1 1 + 2 1
1
(361)
1
(1 + 2 ) (1 m1 + 2 m2 )
1 T
(m 1 + mT2 2 1 )(1 1 + 2 1 )
2 1 1
1 T
m1 1 1 m1 + mT2 2 1 m2
2
(362)
1
(1 1 m1 + 2 1 m2 )(363)
(364)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 41
B)
8.2
Moments
GAUSSIANS
=
c 1
Mc
=
=
8.1.8
M1 )T 1 1 (X
M1 ))
(365)
M2 )T 2 1 (X
M2 ))
(366)
Mc )T c 1 (X
Mc )] + C
(367)
1 1 + 2 1
(1 1 + 2 1 ) 1 (1 1 M1 + 2 1 M2 )
1 h
Tr (1 1 M1 + 2 1 M2 )T (1 1 + 2 1 )
2
1
Tr(MT1 1 1 M1 + MT2 2 1 M2 )
2
(368)
(369)
i
1
(1 1 M1 + 2 1 M2 )
(370)
mc
Nm1 (m2 , (1 + 2 ))
1
1
p
exp
(m1
2
det(2(1 + 2 ))
(1 1 + 2 1 )
(1 1 + 2 1 )
cc
=
=
m2 )T (1 + 2 )
(371)
(m1
m2 )
(1 1 m1 + 2 1 m2 )
8.2
8.2.1
Moments
Mean and covariance of linear forms
(372)
E(x)E(xT ) = E(xxT )
mmT
(373)
=
=
=
AE[x]
AVar[x]A
(374)
T
ACov[x, y]B
(375)
T
(376)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 42
8.2
Moments
8.2.2
GAUSSIANS
E[x Ax]
T
Var(x Ax)
=
=
=
+ mmT
(377)
T
Tr(A) + m Am
(378)
Tr[A(A + A )] + ...
+mT (A + AT )(A + AT )m
E[(x
If =
0 T
m ) A(x
m )]
(m
m0 )T A(m
(379)
(380)
Assume x N (0,
Tr(A2 ) + 4
mT A 2 m
(381)
8.2.3
m0 ) + Tr(A)
Tr(AB)
(382)
Cubic forms
8.2.4
mmT )
(383)
2( + mmT )2 + mT m(
mmT )
+Tr()( + mmT )
T
E[xx Axx ]
E[xT xxT x]
Tr[A(B + BT )] + mT (A + AT )(B + BT )m
+(Tr(A) + mT Am)(Tr(B) + mT Bm)
8.3
Miscellaneous
GAUSSIANS
Tr[A(CT D + DT C)BT ]
+[(Am + a)T B + (Bm + b)T A][CT (Dm + d) + DT (Cm + c)]
+[Tr(ABT ) + (Am + a)T (Bm + b)][Tr(CDT ) + (Cm + c)T (Dm + d)]
See [7].
8.2.5
Moments
E[x]
k m k
(384)
Cov(x)
XX
8.3
8.3.1
k k0 (k + mk mTk
mk mTk0 )
(385)
k0
Miscellaneous
Whitening
1/2
(x
m) N (0, I)
(386)
(387)
Note that 1/2 means the matrix which fulfils 1/2 1/2 = , and that it exists
and is unique since is positive definite.
8.3.2
2
n
8.3.3
Entropy
m)T
(x
m)
2
n
(388)
8.4
8.4.1
(389)
Mixture of Gaussians
Density
K
X
k p
exp
det(2k )
k=1
1
(x
2
mk )T k 1 (x
mk )
(390)
8.4
Mixture of Gaussians
Derivatives
P
Defining p(s) = k k Ns (k , k ) one get
GAUSSIANS
8.4.2
@ ln p(s)
@j
=
=
@ ln p(s)
@j
=
=
@ ln p(s)
@j
=
=
j Ns (j , j )
@
P
ln[j Ns (j , j )]
N
(
,
)
@
k
s
k
j
k
k
j Ns (j , j ) 1
P
k k Ns (k , k ) j
j Ns (j , j )
@
P
ln[j Ns (j , j )]
N
(
,
)
@
k
k
j
k k s
j Ns (j , j ) 1
P
j (s j )
k k Ns (k , k )
j Ns (j , j )
@
P
ln[j Ns (j , j )]
N
(
,
)
@
k
j
k
k k s
j Ns (j , j ) 1
P
j 1 + j 1 (s j )(s
k k Ns (k , k ) 2
(391)
(392)
(393)
(394)
(395)
1
j )T j (396)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 45
9
9.1
SPECIAL MATRICES
Special Matrices
Block matrices
Multiplication
A11 A12
B11 B12
A11 B11 + A12 B21 A11 B12 + A12 B22
=
A21 A22
B21 B22
A21 B11 + A22 B21 A21 B12 + A22 B22
9.1.2
The Determinant
C2
as
det
9.1.3
A11
A21
A12
A22
A11
(397)
A22
(398)
The Inverse
C2
as
=
9.1.4
A11
A21
A12
A22
A11
(399)
A22
(400)
C1 1
C2 1 A21 A111
A221
A111 A12 C2 1
C2 1
C1 1 A12 A221
+ A221 A21 C1 1 A12 A221
Block diagonal
det
A11
0
A11
0
0
A22
0
A22
det(A11 ) det(A22 )
(A11 )
0
0
(A22 )
(401)
(402)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 46
9.2
9.1.5
SPECIAL MATRICES
Schur complement
A11
A21
A12
A22
The Schur complement of block A11 of the matrix above is the matrix (denoted
C2 in the text above)
A22 A21 A111 A12
The Schur complement of block A22 of the matrix above is the matrix (denoted
C1 in the text above)
A11 A12 A221 A21
Using the Schur complement, one can rewrite the inverse of a block matrix
A11
A21
A12
A22
I
A221 A21
0
I
(A11
0
A221
I
0
A12 A221
I
The Schur complement is useful when solving linear systems of the form
A11 A12
x1
b1
=
A21 A22
x2
b2
which has the following equation for x1
(A11
A12 A221 b2
When the appropriate inverses exists, this can be solved for x1 which can then
be inserted in the equation for x2 to solve for x2 .
9.2
N
X1
x(n)WNkn .
(404)
n=0
N 1
1 X
X(k)WN kn .
N
(405)
k=0
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 47
9.3
SPECIAL MATRICES
x = WN1 X.
(407)
If WN = e
j2
N
WN1
WN WN
WN
1
W
N N
NI
WH
N
(410)
WNm
(411)
(408)
(409)
, then [23]
m+N/2
WN
9.3
1]
(412)
,
,
xH Ax 2 R,
eig(A) 2 R
8x 2 Cn1
(413)
(414)
Note that
A = B + iC
where B, C are hermitian, then
B=
9.3.1
A + AH
,
2
C=
AH
2i
Skew-Hermitian
A=
, iA is skew-hermitian
H
, x Ay =
x A y,
) eig(A) = i ,
2R
(415)
8x, y
(416)
(417)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 48
9.4
Idempotent Matrices
9.4
SPECIAL MATRICES
Idempotent Matrices
A matrix A is idempotent if
AA = A
Idempotent matrices A and B, have the following properties
An
I
I
forn = 1, 2, 3, ...
(418)
is idempotent
(419)
is idempotent
(420)
is idempotent
(421)
rank(A)
) AB
is idempotent
(422)
Tr(A)
(423)
A)
(424)
A)A
(425)
(426)
f (sI + tA)
(I
A(I
(I
9.4.1
A,
AH
If AB = BA
Note that A
A)f (s) + Af (s + t)
(427)
Nilpotent
A matrix A is nilpotent if
A2 = 0
A nilpotent matrix has the following property:
f (sI + tA)
9.4.2
(428)
Unipotent
A matrix A is unipotent if
AA = I
A unipotent matrix has the following property:
f (sI + tA)
9.5
[(I + A)f (s + t) + (I
A)f (s
t)]/2
(429)
Orthogonal matrices
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 49
9.6
SPECIAL MATRICES
QT
Q Q
det(Q)
9.5.1
Ortho-Sym
(430)
QT+
(431)
=
=
9.5.2
1 + ( 1)k
1 + ( 1)k+1
I+
Q+
2
2
1 + cos(k)
1 cos(k)
I+
Q+
2
2
(432)
(433)
Ortho-Skew
(434)
Q
(435)
=
=
9.5.3
ik + ( i)k
ik ( i)k
I i
Q
2
2
cos(k )I + sin(k )Q
2
2
(436)
(437)
Decomposition
9.6
9.6.1
8x 6= 0
(439)
8x
(440)
0,
9.6
9.6.2
SPECIAL MATRICES
Eigenvalues
, eig( A+A
)>0
2
H
, eig( A+A
) 0
2
(441)
Trace
)
)
Tr(A) > 0
Tr(A) 0
Inverse
(442)
Diagonal
Decomposition I
Decomposition II
AX = 0
Rank of product
Outer Product
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 51
9.7
9.6.12
Small pertubations
SPECIAL MATRICES
Hadamard inequality
Assume that P = AAT and Q = BBT are semi positive definite matrices, it
then holds that
P Q = RRT
where the columns of R are constructed as follows: ri+(j 1)NA = ai bj , for
i = 1, 2, ..., NA and j = 1, 2, ..., NB . The result is unpublished, but reported by
Pavel Sakov and Craig Bishop.
9.7
9.7.1
The single-entry matrix Jij 2 Rnn is defined as the matrix which is zero
everywhere except in the entry (i, j) in which it is 1. In a 4 4 example one
might have
2
3
0 0 0 0
6 0 0 1 0 7
7
J23 = 6
(443)
4 0 0 0 0 5
0 0 0 0
The single-entry matrix is very useful when working with derivatives of expressions involving matrices.
9.7.2
AJij = 0 0 . . . Ai
...
(444)
i.e. an n p matrix of zeros with the i.th column of A in place of the j.th
column. Assume A to be n m and Jij to be p n
2
3
0
6 .. 7
6 . 7
6
7
6 0 7
6
7
7
Jij A = 6
(445)
6 Aj 7
6 0 7
6
7
6 . 7
4 .. 5
0
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 52
9.7
SPECIAL MATRICES
i.e. an p m matrix of zeros with the j.th row of A in the placed of the i.th
row.
9.7.3
=
=
(AJij B)kl
T
ij
ij
(A J B )kl
(A J B)kl
ij
(AJ B )kl
(446)
(447)
(448)
(449)
If i = j
Jij Jij = Jij
Jij Jij = 0
(450)
(AT BT )ij
(451)
Tr(AJji B)
Tr(AJij Jij B)
=
=
(BA)ij
diag(AT BT )ij
(452)
(453)
xT AJij Bx
(454)
ij ij
(455)
x AJ J Bx
9.7.6
Structure Matrices
(456)
Sij = Jij
(457)
If A is symmetric then
Sij = Jij + Jji
Jij Jij
(458)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 53
9.8
Symmetric, Skew-symmetric/Antisymmetric
9.8
9.8.1
SPECIAL MATRICES
Symmetric, Skew-symmetric/Antisymmetric
Symmetric
(459)
Symmetric matrices have many important properties, e.g. that their eigenvalues
are real and eigenvectors orthogonal.
9.8.2
Skew-symmetric/Antisymmetric
The antisymmetric matrix is also known as the skew symmetric matrix. It has
the following property from which it is defined
A=
AT
(460)
Hereby, it can be seen that the antisymmetric matrices always have a zero
diagonal. The n n antisymmetric matrices also have the following properties.
det(AT )
(461)
det(A)
det( A) = 0,
(462)
if n is odd
Decomposition
9.9
A + AT
A AT
+
= A+ + A
2
2
(464)
Toeplitz Matrices
A Toeplitz matrix is persymmetric. If a matrix is persymmetric (or orthosymmetric), it means that the matrix is symmetric about its northeast-southwest
diagonal (anti-diagonal) [12]. Persymmetric matrices is a larger class of matrices, since a persymmetric matrix not necessarily has a Toeplitz structure. There
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 54
9.10
Transition matrices
SPECIAL MATRICES
are some special cases of Toeplitz matrices. The symmetric Toeplitz matrix is
given by:
2
3
t0
t1 tn 1
6
.. 7
..
..
6 t1
.
.
. 7
7
T=6
(466)
6 .
7
..
..
5
4 ..
.
.
t1
tn 1 t1
t0
The circular Toeplitz matrix:
2
t0
6
6 tn 1
TC = 6
6 .
4 ..
t1
t1
..
.
..
..
.
..
.
tn
..
.
..
.
0
tn
..
.
t1
t0
tn
..
.
t1
t0
..
.
..
.
t 1
3
7
7
7
7
5
7
7
7,
7
5
3
0
.. 7
. 7
7
7
0 5
t0
(467)
(468)
(469)
The Toeplitz matrix has some computational advantages. The addition of two
Toeplitz matrices can be done with O(n) flops, multiplication of two Toeplitz
matrices can be done in O(n ln n) flops. Toeplitz equation systems can be solved
in O(n2 ) flops. The inverse of a positive definite Toeplitz matrix can be found
in O(n2 ) flops too. The inverse of a Toeplitz matrix is persymmetric. The
product of two lower triangular Toeplitz matrices is a Toeplitz matrix. More
information on Toeplitz matrices and circulant matrices can be found in [13, 7].
9.10
Transition matrices
The transition matrix usually describes the probability of moving from state i
to j in one step and is closely related to markov processes. Transition matrices
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 55
9.11
SPECIAL MATRICES
Prob[i ! j in 2 steps]
Prob[i ! j in k steps]
(P)ij
(470)
(P2 )ij
(471)
(472)
(P )ij
n
) P =P
=
(473)
is called invariant
9.11
(474)
P
i =
9.11.1
Unit vector
Let ei 2 Rn1 be the ith unit vector, i.e. the vector which is zero in all entries
except the ith at which it is 1.
9.11.2
9.11.3
eTi A
(475)
j.th column of A
Aej
(476)
Permutations
matrix, e.g.
3
0
0 5 = e2
1
e1
e3
3
eT2
= 4 eT1 5
eT3
PPT = I
and that
AP =
Ae2
Ae1
Ae3
(478)
2
3
eT2 A
PA = 4 eT1 A 5
eT3 A
(477)
(479)
That is, the first is a matrix which has columns of A but in permuted sequence
and the second is a matrix which has the rows of A but in the permuted sequence.
9.11.4
0
0
0
1
3
0
0 7
7
0 5
0
(480)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 56
9.12
Vandermonde Matrices
SPECIAL MATRICES
i.e. a matrix of zeros with one on the sub-diagonal, (L)ij = i,j+1 . With some
signal xt for t = 1, ..., N , the n.th power of the lag operator shifts the indices,
i.e.
n 0
for t = 1, .., n
(Ln x)t =
(481)
xt n for t = n + 1, ..., N
A related but slightly dierent matrix is the recurrent shifted operator defined
on a 4x4 example by
2
3
0 0 0 1
6
7
=6 1 0 0 0 7
L
(482)
4 0 1 0 0 5
0 0 1 0
ij = i,j+1 +
i.e. a matrix defined by (L)
eect
n x)t = xt0 , t0 = [(t
(L
i,1 j,dim(L) .
n)
mod N ] + 1
(483)
9.12
T
=L
(484)
Vandermonde Matrices
v1n
v2n
..
.
vnn
7
7
7.
5
(485)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 57
10
10
10.1
10.1.1
10.1.2
I)(X
I)
= I + X + X2 + ... + Xn
(487)
Consider some scalar function f (x) which takes the vector x as an argument.
This we can Taylor expand around x0
f (x)
= f (x0 ) + g(x0 )T (x
where
g(x0 ) =
10.1.3
@f (x)
@x
1
x0 ) + (x
2
x0 )T H(x0 )(x
H(x0 ) =
x0
@ 2 f (x)
@x@xT
x0 )
(488)
x0
As for analytical functions in one dimension, one can define a matrix function
for square matrices X by an infinite series
f (X) =
1
X
c n Xn
(489)
n=0
P
assuming the limit exists and is finite. If the coefficients cn fulfils n cn xn < 1,
then one can prove that the above series exists and is finite, see [1]. Thus for
any analytical function f (x) there exists a corresponding matrix function f (x)
constructed by the Taylor expansion. Using this one can prove the following
results:
1) A matrix A is a zero of its own characteristic polynomium [1]:
X
p( ) = det(I
A) =
cn n
)
p(A) = 0
(490)
n
f (A) = Uf (B)U
(491)
if
|A| < 1
(492)
(493)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 58
10.2
10.1.5
10
In analogy to the ordinary scalar exponential function, one can define exponential and logarithmic matrix functions:
eA
etA
ln(I + A)
1
X
1 n
1
A = I + A + A2 + ...
n!
2
n=0
1
X
1
( 1)n An = I
n!
n=0
1
A + A2
2
(494)
...
(495)
1
X
1
1
(tA)n = I + tA + t2 A2 + ...
n!
2
n=0
1
X
( 1)n
n
n=1
An = A
1 2 1 3
A + A
2
3
(496)
...
(497)
(e )
d tA
e
dt
d
Tr(etA )
dt
det(eA )
10.1.6
10.2
10.2.1
eA+B
if
AB = BA
(498)
(499)
AetA = etA A,
Tr(AetA )
(501)
eTr(A)
(502)
t2R
(500)
Trigonometric Functions
sin(A)
cos(A)
1
X
( 1)n A2n+1
=A
(2n + 1)!
n=0
1
X
( 1)n A2n
=I
(2n)!
n=0
1 3
1
A + A5
3!
5!
1 2
1
A + A4
2!
4!
...
...
(503)
(504)
Am2 B ...
Amn B
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 59
10.2
10
A (B C)
A B 6=
(A A B B)
(A B)
(A B)(C D)
(A B)
=
=
=
=
AB+AC
(506)
(A B) C
(508)
BA
in general
(507)
A B (A B)
(509)
AC BD
(511)
A B
1
(510)
(512)
rank(A B)
rank(A)rank(B)
(514)
Tr(A B)
(515)
det(A B)
Tr(A)Tr(B) = Tr(A B )
det(A)rank(B) det(B)rank(A)
{eig(B A)}
(517)
(A B)
{eig(A B)}
{eig(A B)}
eig(A B)
A B
(513)
if A, B are square
(516)
{eig(A)eig(B)T }
(518)
eig(A) eig(B)
(519)
Where { i } denotes the set of values i , that is, the values in no particular
order or structure, and A denotes the diagonal matrix with the eigenvalues of
A.
10.2.2
The vec-operator applied on a matrix A stacks the columns into a vector, i.e.
for a 2 2 matrix
2
3
A11
6 A21 7
A11 A12
7
A=
vec(A) = 6
4 A12 5
A21 A22
A22
Properties of the vec-operator include (see [19])
vec(AXB)
T
Tr(A B)
vec(A + B)
vec(A)
aT XBXT c
(BT A)vec(X)
T
(520)
vec(A) vec(B)
(521)
vec(A) + vec(B)
(522)
vec(A)
(523)
(524)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 60
10.3
Vector Norms
10.3
10.3.1
10
Vector Norms
Examples
||x||1
||x||22
||x||p
||x||1
X
i
H
|xi |
x x
"
X
i
(525)
|xi |p
(526)
#1/p
(527)
max |xi |
(528)
10.4
10.4.1
Matrix Norms
Definitions
||A + B||
||cA||
10.4.2
(529)
0,A=0
(530)
|c|||A||,
||A|| + ||B||
c2R
(531)
(532)
||x|| = 1}
(533)
where || || on the left side is the induced matrix norm, while || || on the right
side denotes the vector norm. For induced norms it holds that
||I||
||Ax||
||AB||
10.4.3
1
||A|| ||x||,
||A|| ||B||,
for all A, x
for all A, B
(534)
(535)
(536)
Examples
||A||1
||A||2
||A||p
=
=
||A||1
||A||F
X
max
|Aij |
j
i
q
max eig(AH A)
( max ||Ax||p )1/p
||x||p =1
X
max
|Aij |
i
j
sX
q
|Aij |2 = Tr(AAH )
(537)
(538)
(539)
(540)
(Frobenius)
(541)
ij
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 61
10.5
Rank
10
||A||max
||A||KF
=
=
max |Aij |
(542)
ij
||sing(A)||1
(Ky Fan)
(543)
Inequalities
||A||max
||A||1
||A||1
||A||2
||A||F
||A||KF
m
pn
mn
p
p mn
mnd
||A||1
1
||A||1
1
m
pn
n
p
pn
nd
p
m
p
pm
md
||A||2
p1
pm
n
||A||F
p1
pm
n
1
d
d
||A||KF
p1
pm
n
1
1
m ||A||1
(544)
10.4.5
Condition Number
p
The 2-norm of A equals (max(eig(AT A))) [12, p.57]. For a symmetric, positive definite matrix, this reduces to max(eig(A)) The condition number based
on the 2-norm thus reduces to
kAk2 kA
10.5
10.5.1
k2 = max(eig(A)) max(eig(A
)) =
max(eig(A))
.
min(eig(A))
(545)
Rank
Sylvesters Inequality
If A is m n and B is n r, then
rank(A) + rank(B)
10.6
(546)
1
p(A
det(A)
x)
(547)
(548)
See [9].
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 62
10.7
Miscellaneous
10.7
10
Miscellaneous
(549)
It holds that
A is positive definite
(550)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 63
A
A.1
A.1.1
One-dimensional Results
Gaussian
Density
p(x) = p
A.1.2
A.1.3
1
2
Normalization
Z
(s )2
e 2 2 ds
Z
2
e (ax +bx+c) dx
Z
2
ec2 x +c1 x+c0 dx
exp
(551)
2 2
r
2
b
4ac
exp
a
4a
2
r
c1 4c2 c0
exp
c2
4c2
=
=
=
p(x)
(x
(x
(552)
(553)
(554)
(555)
(556)
1 (x )2
p(x)
2
1 (x )2
1
2
=
=
(557)
(558)
1 c1
2 c2
b=
c 2 x2 + c 1 x + c 0 =
=
c1
2c2
b)2 + w
a(x
or
A.1.5
)2
(x
Derivatives
@p(x)
@
@ ln p(x)
@
@p(x)
@
@ ln p(x)
@
A.1.4
ONE-DIMENSIONAL RESULTS
1
2c2
w=
1 c21
+ c0
4 c2
(x
)2 + d
d = c0
c21
4c2
Moments
1
(s )2
p(x) = p
exp
2 2
2 2
or
p(x) = C exp(c2 x2 + c1 x)
(559)
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 64
A.2
hxi
hx2 i
c1
2c2
=
+ 2
hx3 i
+ 3
hx4 i
4 + 62
+3
2
c1
1
2c2 + h 2c2
i
c21
c1
3
2
(2c )
2c2
2 4
2
c1
c1
+
6
2c2
2c2
h(x
h(x
h(x
)i
) i
)3 i
)4 i
=
2
=
=
=
=
0h
1
2c2
1
2c2
1
2c2
+3
1
2c2
i2
c1
exp(c2 x2 + c1 x)xn dx = Zhxn i =
exp
hxn i
(560)
c2
4c2
From the un-centralized moments one can derive other entities like
hx2 i
hx3 i
hx4 i
A.2
A.2.1
hxi2
hx2 ihxi
hx2 i2
=
=
+ 42
1
2c2
2c1
(2c2 )2
2
(2c2 )2
c2
4 2c12
K
X
k
A.2.2
=
=
Moments
k
2
2
k
exp
1 (s
2
k ) 2
2
k
(561)
X
k
k hxn ik
(562)
where hik denotes average with respect to the k.th component. We can calculate
the first four moments from the densities
X
1
1 (x k )2
p(x) =
k p
exp
(563)
2
2
2 k2
k
k
X
p(x) =
k Ck exp ck2 x2 + ck1 x
(564)
k
as
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 65
hxi
hx2 i
hx i
hx4 i
P
P
P
P
k k
k k (
2
k
k k (3
=
+ 2k )
2
k k
4
2
k k (k + 6k
=
3k )
2
k
+3
4
k)
P
P
P
P
k k
k k
k k
ck1
2ck2
2ck2
ck1
2
(2ck2 )
1
2ck2
hx2 i
hx3 i
=
=
hx4 i
0
P
0
P
=
k k
k 3
2
k
=
=
4
k
0
P
0
P
k 3
1
2ck2
1
2ck2
ck1
2ck2
3
2
c2k1
2ck2
ck1
2ck2
ii
c2
6 2ck1
+3
k2
i2
From the un-centralized moments one can derive other entities like
2
P
2
0
hx2 i hxi2
=
k k 0
k,k0 k k k + k
P
2
3
2
2
0
hx3 i hx2 ihxi =
(
+
)
0 k k 0 3 k k + k
k
k
k
k,k
4
P
2 2
4
0
hx4 i hx2 i2
=
( k2 + 2k )( k20 + 2k0 )
k,k0 k k k + 6k k + 3 k
A.2.3
Derivatives
P
Defining p(s) = k k Ns (k , k2 ) we get for a parameter j of the j.th component
j Ns (j , j2 ) @ ln(j Ns (j , j2 ))
@ ln p(s)
=P
(565)
2
@j
@j
k k Ns (k , k )
that is,
@ ln p(s)
@j
@ ln p(s)
@j
@ ln p(s)
@ j
j Ns (j , j2 ) 1
P
2
k k Ns (k , k ) j
j Ns (j , j2 ) (s
P
2
k k Ns (k , k )
j Ns (j , j2 ) 1
P
2
k k Ns (k , k ) j
(566)
j )
(567)
2
j
"
(s
j ) 2
2
j
(568)
Note thatP
k must be constrained to be proper ratios. Defining the ratios by
j = erj / k erk , we obtain
@ ln p(s) X @ ln p(s) @l
@l
=
where
= l ( lj j )
(569)
@rj
@l @rj
@rj
l
B
B.1
B.1.1
The following proof is work of Florian Roemer. Note the the vectors and matrices below can be complex and the notation XH is used for transpose and
conjugated, while XT is only transpose of the complex matrix.
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 66
B.1
Misc Proofs
=
=
=
1
X
n=0
1
X
cn (AB)n A
cn A(BA)n
n=0
1
X
cn (BA)n
n=0
=
B.1.3
Af (BA)
Proof of Equation 91
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 67
B.1
Misc Proofs
@(Xn )kl
@Xij
@
@Xij
=
=
u1 ,...,un
1 ,l
+Xk,u1
1 ,l
u1 ,i u2 ,j ...Xun
1 ,l
..
.
+Xk,u1 Xu1 ,u2 ...
=
n
X1
un
1 r
1 ,i
l,j
)jl
r=0
n
X1
(Xr Jij Xn
1 r
)kl
r=0
Using the properties of the single entry matrix found in Sec. 9.7.4, the result
follows easily.
B.1.4
@ det(XH AX)
@(XH AX)]
@(XH )AX]
XH @(AX)]
@(XH )]
XH A@(X)]
XH A)T
Through the calculations, (100) and (240) were used. In addition, by use of
(241), the derivative is found with respect to the imaginary part of X
Tr[AX(XH AX) 1 @(XH )]
@ det(XH AX)
i
= i det(XH AX)
@=X
@=X
Tr[(XH AX) 1 XH A@(X)]
+
@=X
H
= det(X AX) AX(XH AX) 1 ((XH AX) 1 XH A)T
Hence, derivative yields
@ det(XH AX)
@X
=
=
1 @ det(XH AX)
@ det(XH AX)
i
2
@<X
@=X
T
H
H
1 H
det(X AX) (X AX) X A
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 68
B.1
Misc Proofs
=
=
1 @ det(XH AX)
@ det(XH AX)
+i
2
@<X
@=X
H
H
det(X AX)AX(X AX) 1
Notice, for real X, A, the sum of (249) and (250) is reduced to (54).
Similar calculations yield
@ det(XAXH )
@X
=
=
1 @ det(XAXH )
@ det(XAXH )
i
2
@<X
@=X
T
H
H
H
det(XAX ) AX (XAX ) 1
(570)
1 @ det(XAXH )
@ det(XAXH )
+i
2
@<X
@=X
det(XAXH )(XAXH ) 1 XA
(571)
and
@ det(XAXH )
@X
=
=
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 69
REFERENCES
REFERENCES
References
[1] Karl Gustav Andersson and Lars-Christer Boiers. Ordinaera dierentialekvationer. Studenterlitteratur, 1992.
[2] J
orn Anem
uller, Terrence J. Sejnowski, and Scott Makeig. Complex independent component analysis of frequency-domain electroencephalographic
data. Neural Networks, 16(9):13111323, November 2003.
[3] S. Barnet. Matrices. Methods and Applications. Oxford Applied Mathematics and Computin Science Series. Clarendon Press, 1990.
[4] Christopher Bishop. Neural Networks for Pattern Recognition. Oxford
University Press, 1995.
[5] Robert J. Boik. Lecture notes: Statistics 550. Online, April 22 2002. Notes.
[6] D. H. Brandwood. A complex gradient operator and its application in
adaptive array theory. IEE Proceedings, 130(1):1116, February 1983. PTS.
F and H.
[7] M. Brookes. Matrix Reference Manual, 2004. Website May 20, 2004.
[8] Contradsen K., En introduktion til statistik, IMM lecture notes, 1984.
[9] Mads Dyrholm. Some matrix results, 2004. Website August 23, 2004.
[10] Nielsen F. A., Formula, Neuro Research Unit and Technical university of
Denmark, 2002.
[11] Gelman A. B., J. S. Carlin, H. S. Stern, D. B. Rubin, Bayesian Data
Analysis, Chapman and Hall / CRC, 1995.
[12] Gene H. Golub and Charles F. van Loan. Matrix Computations. The Johns
Hopkins University Press, Baltimore, 3rd edition, 1996.
[13] Robert M. Gray. Toeplitz and circulant matrices: A review. Technical
report, Information Systems Laboratory, Department of Electrical Engineering,Stanford University, Stanford, California 94305, August 2002.
[14] Simon Haykin. Adaptive Filter Theory. Prentice Hall, Upper Saddle River,
NJ, 4th edition, 2002.
[15] Roger A. Horn and Charles R. Johnson. Matrix Analysis. Cambridge
University Press, 1985.
[16] Mardia K. V., J.T. Kent and J.M. Bibby, Multivariate Analysis, Academic
Press Ltd., 1979.
[17] Mathpages on Eigenvalue Problems and Matrix Invariants,
http://www.mathpages.com/home/kmath128.htm
[18] Carl D. Meyer. Generalized inversion of modified matrices. SIAM Journal
of Applied Mathematics, 24(3):315323, May 1973.
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 70
REFERENCES
REFERENCES
[19] Thomas P. Minka. Old and new matrix algebra useful for statistics, December 2000. Notes.
[20] Daniele Mortari OrthoSkew and OrthoSym Matrix Trigonometry John
Lee Junkins Astrodynamics Symposium, AAS 03265, May 2003. Texas
A&M University, College Station, TX
[21] L. Parra and C. Spence. Convolutive blind separation of non-stationary
sources. In IEEE Transactions Speech and Audio Processing, pages 320
327, May 2000.
[22] Kaare Brandt Petersen, Jiucang Hao, and Te-Won Lee. Generative and
filtering approaches for overcomplete representations. Neural Information
Processing - Letters and Reviews, vol. 8(1), 2005.
[23] John G. Proakis and Dimitris G. Manolakis. Digital Signal Processing.
Prentice-Hall, 1996.
[24] Laurent Schwartz. Cours dAnalyse, volume II. Hermann, Paris, 1967. As
referenced in [14].
[25] Shayle R. Searle. Matrix Algebra Useful for Statistics. John Wiley and
Sons, 1982.
[26] G. Seber and A. Lee. Linear Regression Analysis. John Wiley and Sons,
2002.
[27] S. M. Selby. Standard Mathematical Tables. CRC Press, 1974.
[28] Inna Stainvas. Matrix algebra in dierential calculus. Neural Computing
Research Group, Information Engeneering, Aston University, UK, August
2002. Notes.
[29] P. P. Vaidyanathan. Multirate Systems and Filter Banks. Prentice Hall,
1993.
[30] Max Welling. The Kalman Filter. Lecture Note.
[31] Wikipedia on minors: Minor (linear algebra),
http://en.wikipedia.org/wiki/Minor_(linear_algebra)
[32] Zhaoshui He, Shengli Xie, et al, Convolutive blind source separation in
frequency domain based on sparse representation, IEEE Transactions on
Audio, Speech and Language Processing, vol.15(5):1551-1563, July 2007.
[33] Karim T. Abou-Moustafa On Derivatives of Eigenvalues and Eigenvectors
of the Generalized Eigenvalue Problem. McGill Technical Report, October
2010.
[34] Mohammad Emtiyaz Khan Updating Inverse of a Matrix When a Column
is Added/Removed. Emt CS,UBC February 27, 2008
Petersen & Pedersen, The Matrix Cookbook, Version: November 15, 2012, Page 71
Index
Anti-symmetric, 54
Block matrix, 46
Orthogonal, 49
Chain rule, 15
Cholesky-decomposition, 32
Co-kurtosis, 34
Co-skewness, 34
Condition number, 62
Cramers Rule, 29
Taylor expansion, 58
Toeplitz matrix, 54
Transition matrix, 55
Trigonometric functions, 59
Gaussian, conditional, 40
Gaussian, entropy, 44
Gaussian, linear combination, 41
Gaussian, marginal, 40
Gaussian, product of densities, 42
Generalized inverse, 21
Unipotent, 49
Vandermonde matrix, 57
Vec operator, 59, 60
Wishart distribution, 38
Woodbury identity, 18
Hadamard inequality, 52
Hermitian, 48
Idempotent, 49
Kronecker product, 59
LDL decomposition, 33
LDM-decomposition, 33
Linear regression, 28
LU decomposition, 32
Lyapunov Equation, 30
Moore-Penrose inverse, 21
Multinomial distribution, 37
Nilpotent, 49
Norm of a matrix, 61
Norm of a vector, 61
72