You are on page 1of 43

The Matrix Cookbook

Kaare Brandt Petersen


Michael Syskind Pedersen
Version: January 5, 2005
What is this? These pages are a collection of facts (identities, approxima-
tions, 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 apolo-
gize and would be grateful to receive corrections at kbp@imm.dtu.dk.
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 at kbp@imm.dtu.dk.
Acknowledgements: We would like to thank the following for discussions,
proofreading, extensive corrections and suggestions: Esben Hoegh-Rasmussen
and Vasile Sima.
Keywords: Matrix algebra, matrix relations, matrix identities, derivative of
determinant, derivative of inverse matrix, dierentiate a matrix.
1
CONTENTS CONTENTS
Contents
1 Basics 5
1.1 Trace and Determinants . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 The Special Case 2x2 . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 Derivatives 7
2.1 Derivatives of a Determinant . . . . . . . . . . . . . . . . . . . . 7
2.2 Derivatives of an Inverse . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Derivatives of Matrices, Vectors and Scalar Forms . . . . . . . . 9
2.4 Derivatives of Traces . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.5 Derivatives of Structured Matrices . . . . . . . . . . . . . . . . . 12
3 Inverses 14
3.1 Exact Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 Implication on Inverses . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 Approximations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4 Generalized Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5 Pseudo Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4 Complex Matrices 17
4.1 Complex Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 17
5 Decompositions 20
5.1 Eigenvalues and Eigenvectors . . . . . . . . . . . . . . . . . . . . 20
5.2 Singular Value Decomposition . . . . . . . . . . . . . . . . . . . . 20
5.3 Triangular Decomposition . . . . . . . . . . . . . . . . . . . . . . 21
6 General Statistics and Probability 22
6.1 Moments of any distribution . . . . . . . . . . . . . . . . . . . . . 22
6.2 Expectations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7 Gaussians 24
7.1 One Dimensional . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
7.2 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
7.3 Moments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
7.4 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.5 One Dimensional Mixture of Gaussians . . . . . . . . . . . . . . . 29
7.6 Mixture of Gaussians . . . . . . . . . . . . . . . . . . . . . . . . . 30
8 Miscellaneous 31
8.1 Functions and Series . . . . . . . . . . . . . . . . . . . . . . . . . 31
8.2 Indices, Entries and Vectors . . . . . . . . . . . . . . . . . . . . . 32
8.3 Solutions to Systems of Equations . . . . . . . . . . . . . . . . . 35
8.4 Block matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8.5 Matrix Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
8.6 Positive Denite and Semi-denite Matrices . . . . . . . . . . . . 38
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 2
CONTENTS CONTENTS
8.7 Integral Involving Dirac Delta Functions . . . . . . . . . . . . . . 39
8.8 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
A Proofs and Details 41
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 3
CONTENTS CONTENTS
Notation and Nomenclature
A Matrix
A
ij
Matrix indexed for some purpose
A
i
Matrix indexed for some purpose
A
ij
Matrix indexed for some purpose
A
n
Matrix indexed for some purpose or
The n.th power of a square matrix
A
1
The inverse matrix of the matrix A
A
+
The pseudo inverse matrix of the matrix A
A
1/2
The square root of a matrix (if unique), not elementwise
(A)
ij
The (i, j).th entry of the matrix A
A
ij
The (i, j).th entry of the matrix A
a Vector
a
i
Vector indexed for some purpose
a
i
The i.th element of the vector a
a Scalar
'z Real part of a scalar
'z Real part of a vector
'Z Real part of a matrix
z Imaginary part of a scalar
z Imaginary part of a vector
Z Imaginary part of a matrix
det(A) Determinant of A
[[A[[ Matrix norm (subscript if any denotes what norm)
A
T
Transposed matrix
A

Complex conjugated matrix


A
H
Transposed and complex conjugated matrix
A B Hadamard (elementwise) product
AB Kronecker product
0 The null matrix. Zero in all entries.
I The identity matrix
J
ij
The single-entry matrix, 1 at (i, j) and zero elsewhere
A positive denite matrix
A diagonal matrix
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 4
1 BASICS
1 Basics
(AB)
1
= B
1
A
1
(ABC...)
1
= ...C
1
B
1
A
1
(A
T
)
1
= (A
1
)
T
(A+B)
T
= A
T
+B
T
(AB)
T
= B
T
A
T
(ABC...)
T
= ...C
T
B
T
A
T
(A
H
)
1
= (A
1
)
H
(A+B)
H
= A
H
+B
H
(AB)
H
= B
H
A
H
(ABC...)
H
= ...C
H
B
H
A
H
1.1 Trace and Determinants
Tr(A) =

i
A
ii
=

i
,
i
= eig(A)
Tr(A) = Tr(A
T
)
Tr(AB) = Tr(BA)
Tr(A+B) = Tr(A) + Tr(B)
Tr(ABC) = Tr(BCA) = Tr(CAB)
det(A) =

i

i
= eig(A)
det(AB) = det(A) det(B), if A and B are invertible
det(A
1
) =
1
det(A)
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 5
1.2 The Special Case 2x2 1 BASICS
1.2 The Special Case 2x2
Consider the matrix A
A =
_
A
11
A
12
A
21
A
22
_
Determinant and trace
det(A) = A
11
A
22
A
12
A
21
Tr(A) = A
11
+A
22
Eigenvalues

2
Tr(A) + det(A) = 0

1
=
Tr(A) +
_
Tr(A)
2
4 det(A)
2

2
=
Tr(A)
_
Tr(A)
2
4 det(A)
2

1
+
2
= Tr(A)
1

2
= det(A)
Eigenvectors
v
1

_
A
12

1
A
11
_
v
2

_
A
12

2
A
11
_
Inverse
A
1
=
1
det(A)
_
A
22
A
12
A
21
A
11
_
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 6
2 DERIVATIVES
2 Derivatives
This section is covering dierentiation of a number of expressions with respect to
a matrix X. Note that it is always assumed that X has no special structure, i.e.
that the elements of X are independent (e.g. not symmetric, Toeplitz, positive
denite). See section 2.5 for dierentiation of structured matrices. The basic
assumptions can be written in a formula as
X
kl
X
ij
=
ik

lj
that is for e.g. vector forms,
_
x
y
_
i
=
x
i
y
_
x
y
_
i
=
x
y
i
_
x
y
_
ij
=
x
i
y
j
The following rules are general and very useful when deriving the dierential of
an expression ([10]):
A = 0 (A is a constant) (1)
(X) = X (2)
(X+Y) = X+Y (3)
(Tr(X)) = Tr(X) (4)
(XY) = (X)Y+X(Y) (5)
(X Y) = (X) Y+X (Y) (6)
(XY) = (X) Y+X(Y) (7)
(X
1
) = X
1
(X)X
1
(8)
(det(X)) = det(X)Tr(X
1
X) (9)
(ln(det(X))) = Tr(X
1
X) (10)
X
T
= (X)
T
(11)
X
H
= (X)
H
(12)
2.1 Derivatives of a Determinant
2.1.1 General form
det(Y)
x
= det(Y)Tr
_
Y
1
Y
x
_
2.1.2 Linear forms
det(X)
X
= det(X)(X
1
)
T
det(AXB)
X
= det(AXB)(X
1
)
T
= det(AXB)(X
T
)
1
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 7
2.2 Derivatives of an Inverse 2 DERIVATIVES
2.1.3 Square forms
If X is square and invertible, then
det(X
T
AX)
X
= 2 det(X
T
AX)X
T
If X is not square but A is symmetric, then
det(X
T
AX)
X
= 2 det(X
T
AX)AX(X
T
AX)
1
If X is not square and A is not symmetric, then
det(X
T
AX)
X
= det(X
T
AX)(AX(X
T
AX)
1
+A
T
X(X
T
A
T
X)
1
) (13)
2.1.4 Other nonlinear forms
Some special cases are (See [8])
lndet(X
T
X)[
X
= 2(X
+
)
T
lndet(X
T
X)
X
+
= 2X
T
ln[ det(X)[
X
= (X
1
)
T
= (X
T
)
1
det(X
k
)
X
= k det(X
k
)X
T
See [7].
2.2 Derivatives of an Inverse
From [15] we have the basic identity
Y
1
x
= Y
1
Y
x
Y
1
from which it follows
(X
1
)
kl
X
ij
= (X
1
)
ki
(X
1
)
jl
a
T
X
1
b
X
= X
T
ab
T
X
T
det(X
1
)
X
= det(X
1
)(X
1
)
T
Tr(AX
1
B)
X
= (X
1
BAX
1
)
T
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 8
2.3 Derivatives of Matrices, Vectors and Scalar Forms 2 DERIVATIVES
2.3 Derivatives of Matrices, Vectors and Scalar Forms
2.3.1 First Order
x
T
b
x
=
b
T
x
x
= b
a
T
Xb
X
= ab
T
a
T
X
T
b
X
= ba
T
a
T
Xa
X
=
a
T
X
T
a
X
= aa
T
X
X
ij
= J
ij
(XA)
ij
X
mn
=
im
(A)
nj
= (J
mn
A)
ij
(X
T
A)
ij
X
mn
=
in
(A)
mj
= (J
nm
A)
ij
2.3.2 Second Order

X
ij

klmn
X
kl
X
mn
= 2

kl
X
kl
b
T
X
T
Xc
X
= X(bc
T
+cb
T
)
(Bx +b)
T
C(Dx +d)
x
= B
T
C(Dx +d) +D
T
C
T
(Bx +b)
(X
T
BX)
kl
X
ij
=
lj
(X
T
B)
ki
+
kj
(BX)
il
(X
T
BX)
X
ij
= X
T
BJ
ij
+J
ji
BX (J
ij
)
kl
=
ik

jl
See Sec 8.2 for useful properties of the Single-entry matrix J
ij
x
T
Bx
x
= (B+B
T
)x
b
T
X
T
DXc
X
= D
T
Xbc
T
+DXcb
T

X
(Xb +c)
T
D(Xb +c) = (D+D
T
)(Xb +c)b
T
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 9
2.3 Derivatives of Matrices, Vectors and Scalar Forms 2 DERIVATIVES
Assume W is symmetric, then

s
(x As)
T
W(x As) = 2A
T
W(x As)

x
(x As)
T
W(x As) = 2W(x As)

A
(x As)
T
W(x As) = 2W(x As)s
T
2.3.3 Higher order and non-linear

X
a
T
X
n
b =
n1

r=0
(X
r
)
T
ab
T
(X
n1r
)
T
(14)

X
a
T
(X
n
)
T
X
n
b =
n1

r=0
_
X
n1r
ab
T
(X
n
)
T
X
r
+(X
r
)
T
X
n
ab
T
(X
n1r
)
T
_
(15)
See A.0.1 for a proof.
Assume s and r are functions of x, i.e. s = s(x), r = r(x), and that A is a
constant, then

x
s
T
As =
_
s
x
_
T
(A+A
T
)s

x
s
T
Ar =
_
s
x
_
T
As +
_
r
x
_
T
A
T
r
2.3.4 Gradient and Hessian
Using the above we have for the gradient and the hessian
f = x
T
Ax +b
T
x

x
f =
f
x
= (A+A
T
)x +b

2
f
xx
T
= A+A
T
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 10
2.4 Derivatives of Traces 2 DERIVATIVES
2.4 Derivatives of Traces
2.4.1 First Order

X
Tr(X) = I

X
Tr(XB) = B
T
(16)

X
Tr(BXC) = B
T
C
T

X
Tr(BX
T
C) = CB

X
Tr(X
T
C) = C

X
Tr(BX
T
) = B
2.4.2 Second Order

X
Tr(X
2
) = 2X

X
Tr(X
2
B) = (XB+BX)
T

X
Tr(X
T
BX) = BX+B
T
X

X
Tr(XBX
T
) = XB
T
+XB

X
Tr(X
T
X) = 2X

X
Tr(BXX
T
) = (B+B
T
)X

X
Tr(B
T
X
T
CXB) = C
T
XBB
T
+CXBB
T

X
Tr
_
X
T
BXC

= BXC+B
T
XC
T

X
Tr(AXBX
T
C) = A
T
C
T
XB
T
+CAXB

X
Tr
_
(AXb +c)(AXb +c)
T
_
= 2A
T
(AXb +c)b
T
See [7].
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 11
2.5 Derivatives of Structured Matrices 2 DERIVATIVES
2.4.3 Higher Order

X
Tr(X
k
) = k(X
k1
)
T

X
Tr(AX
k
) =
k1

r=0
(X
r
AX
kr1
)
T

X
Tr
_
B
T
X
T
CXX
T
CXB

= CXX
T
CXBB
T
+C
T
XBB
T
X
T
C
T
X
+ CXBB
T
X
T
CX+C
T
XX
T
C
T
XBB
T
2.4.4 Other

X
Tr(AX
1
B) = (X
1
BAX
1
)
T
= X
T
A
T
B
T
X
T
Assume B and C to be symmetric, then

X
Tr
_
(X
T
CX)
1
A
_
= (CX(X
T
CX)
1
)(A+A
T
)(X
T
CX)
1

X
Tr
_
(X
T
CX)
1
(X
T
BX)
_
= 2CX(X
T
CX)
1
X
T
BX(X
T
CX)
1
+2BX(X
T
CX)
1
See [7].
2.5 Derivatives of Structured Matrices
Assume that the matrix A has some structure, i.e. is symmetric, toeplitz, etc.
In that case the derivatives of the previous section does not apply in general.
In stead, consider the following general rule for dierentiating a scalar function
f(A)
df
dA
ij
=

kl
f
A
kl
A
kl
A
ij
= Tr
_
_
f
A
_
T
A
A
ij
_
The matrix dierentiated with respect to itself is in this document referred to
as the structure matrix of A and is dened simply by
A
A
ij
= S
ij
If A has no special structure we have simply S
ij
= J
ij
, that is, the structure
matrix is simply the singleentry matrix. Many structures have a representation
in singleentry matrices, see Sec. 8.2.7 for more examples of structure matrices.
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 12
2.5 Derivatives of Structured Matrices 2 DERIVATIVES
2.5.1 Symmetric
If A is symmetric, then S
ij
= J
ij
+J
ji
J
ij
J
ij
and therefore
df
dA
=
_
f
A
_
+
_
f
A
_
T
diag
_
f
A
_
That is, e.g., ([5], [16]):
Tr(AX)
X
= A+A
T
(A I), see (20) (17)
det(X)
X
= 2X(X I) (18)
lndet(X)
X
= 2X
1
(X
1
I) (19)
2.5.2 Diagonal
If X is diagonal, then ([10]):
Tr(AX)
X
= A I (20)
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 13
3 INVERSES
3 Inverses
3.1 Exact Relations
3.1.1 The Woodbury identity
(A+CBC
T
)
1
= A
1
A
1
C(B
1
+C
T
A
1
C)
1
C
T
A
1
If P, R are positive denite, then (see [17])
(P
1
+B
T
R
1
B)
1
B
T
R
1
= PB
T
(BPB
T
+R)
1
3.1.2 The Kailath Variant
(A+BC)
1
= A
1
A
1
B(I +CA
1
B)
1
CA
1
See [4] page 153.
3.1.3 The Searle Set of Identities
The following set of identities, can be found in [13], page 151,
(I +A
1
)
1
= A(A+I)
1
(A+BB
T
)
1
B = A
1
B(I +B
T
A
1
B)
1
(A
1
+B
1
)
1
= A(A+B)
1
B = B(A+B)
1
A
AA(A+B)
1
A = BB(A+B)
1
B
A
1
+B
1
= A
1
(A+B)B
1
(I +AB)
1
= I A(I +BA)
1
B
(I +AB)
1
A = A(I +AB)
1
3.2 Implication on Inverses
(A+B)
1
= A
1
+B
1
AB
1
A = BA
1
B
See [13].
3.2.1 A PosDef identity
Assume P, R to be positive denite and invertible, then
(P
1
+B
T
R
1
B)
1
B
T
R
1
= PB
T
(BPB
T
+R)
1
See [?].
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 14
3.3 Approximations 3 INVERSES
3.3 Approximations
(I +A)
1
= I A+A
2
A
3
+...
AA(I +A)
1
A

= I A
1
if A large and symmetric
If
2
is small then
(Q+
2
M)
1

= Q
1

2
Q
1
MQ
1
3.4 Generalized Inverse
3.4.1 Denition
A generalized inverse matrix of the matrix A is any matrix A

such that
AA

A = A
The matrix A

is not unique.
3.5 Pseudo Inverse
3.5.1 Denition
The pseudo inverse (or Moore-Penrose inverse) of a matrix A is the matrix A
+
that fulls
I AA
+
A = A
II A
+
AA
+
= A
+
III AA
+
symmetric
IV A
+
A symmetric
The matrix A
+
is unique and does always exist.
3.5.2 Properties
Assume A
+
to be the pseudo-inverse of A, then (See [3])
(A
+
)
+
= A
(A
T
)
+
= (A
+
)
T
(cA)
+
= (1/c)A
+
(A
T
A)
+
= A
+
(A
T
)
+
(AA
T
)
+
= (A
T
)
+
A
+
Assume A to have full rank, then
(AA
+
)(AA
+
) = AA
+
(A
+
A)(A
+
A) = A
+
A
Tr(AA
+
) = rank(AA
+
) (See [14])
Tr(A
+
A) = rank(A
+
A) (See [14])
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 15
3.5 Pseudo Inverse 3 INVERSES
3.5.3 Construction
Assume that A has full rank, then
A n n Square rank(A) = n A
+
= A
1
A n m Broad rank(A) = n A
+
= A
T
(AA
T
)
1
A n m Tall rank(A) = m A
+
= (A
T
A)
1
A
T
Assume Adoes not have full rank, i.e. Ais nm and rank(A) = r < min(n, m).
The pseudo inverse A
+
can be constructed from the singular value decomposi-
tion A = UDV
T
, by
A
+
= VD
+
U
T
A dierent way is this: There does always exists two matrices C n r and D
r m of rank r, such that A = CD. Using these matrices it holds that
A
+
= D
T
(DD
T
)
1
(C
T
C)
1
C
T
See [3].
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 16
4 COMPLEX MATRICES
4 Complex Matrices
4.1 Complex Derivatives
In order to dierentiate an expression f(z) with respect to a complex z, the
Cauchy-Riemann equations have to be satised ([7]):
df(z)
dz
=
'(f(z))
'z
+i
(f(z))
'z
(21)
and
df(z)
dz
= i
'(f(z))
z
+
(f(z))
z
(22)
or in a more compact form:
f(z)
z
= i
f(z)
'z
. (23)
A complex function that satises the Cauchy-Riemann equations for points in a
region R is said yo be analytic in this region R. In general, expressions involving
complex conjugate or conjugate transpose do not satisfy the Cauchy-Riemann
equations. In order to avoid this problem, a more generalized denition of
complex derivative is used ([12], [6]):
Generalized Complex Derivative:
df(z)
dz
=
1
2
_
f(z)
'z
i
f(z)
z
_
(24)
Conjugate Complex Derivative
df(z)
dz

=
1
2
_
f(z)
'z
+i
f(z)
z
_
(25)
The Generalized Complex Derivative equals the normal derivative, when f is an
analytic function. For a non-analytic function such as f(z) = z

, the derivative
equals zero. The Conjugate Complex Derivative equals zero, when f is an
analytic function. The Conjugate Complex Derivative has e.g been used by [11]
when deriving a complex gradient.
Notice:
df(z)
dz
,=
f(z)
'z
+i
f(z)
z
(26)
Complex Gradient Vector: If f is a real function of a complex vector z,
then the complex gradient vector is given by ([9, p. 798])
f(z) = 2
df(z)
dz

(27)
=
f(z)
'z
+i
f(z)
z
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 17
4.1 Complex Derivatives 4 COMPLEX MATRICES
Complex Gradient Matrix: If f is a real function of a complex matrix Z,
then the complex gradient matrix is given by ([2])
f(Z) = 2
df(Z)
dZ

(28)
=
f(Z)
'Z
+i
f(Z)
Z
These expressions can be used for gradient descent algorithms.
4.1.1 The Chain Rule for complex numbers
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 ([?])
g(u)
x
=
g
u
u
x
+
g
u

x
(29)
=
g
u
u
x
+
_
g

u
_

x
Notice, if the function is analytic, the second term reduces to zero, and the func-
tion 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:
g(U)
X
=
Tr((
g(U)
U
)
T
U)
X
+
Tr((
g(U)
U

)
T
U

)
X
. (30)
4.1.2 Complex Derivatives of Traces
If the derivatives involve complex numbers, the conjugate transpose is often in-
volved. 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

)
'X
=
Tr(X
H
)
'X
= I (31)
i
Tr(X

)
X
= i
Tr(X
H
)
X
= I (32)
Since the two results have the same sign, the conjugate complex derivative (25)
should be used.
Tr(X)
'X
=
Tr(X
T
)
'X
= I (33)
i
Tr(X)
X
= i
Tr(X
T
)
X
= I (34)
Here, the two results have dierent signs, the generalized complex derivative
(24) should be used. Hereby, it can be seen that (??) holds even if X is a
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 18
4.1 Complex Derivatives 4 COMPLEX MATRICES
complex number.
Tr(AX
H
)
'X
= A (35)
i
Tr(AX
H
)
X
= A (36)
Tr(AX

)
'X
= A
T
(37)
i
Tr(AX

)
X
= A
T
(38)
Tr(XX
H
)
'X
=
Tr(X
H
X)
'X
= 2'X (39)
i
Tr(XX
H
)
X
= i
Tr(X
H
X)
X
= i2X (40)
By inserting (39) and (40) in (24) and (25), it can be seen that
Tr(XX
H
)
X
= X

(41)
Tr(XX
H
)
X

= X (42)
Since the function Tr(XX
H
) is a real function of the complex matrix X, the
complex gradient matrix (28) is given by
Tr(XX
H
) = 2
Tr(XX
H
)
X

= 2X (43)
4.1.3 Complex Derivative Involving Determinants
Here, a calculation example is provided. The objective is to nd the derivative
of det(X
H
AX) with respect to X C
mn
. The derivative is found with respect
to the real part and the imaginary part of X, by use of (9) and (5), det(X
H
AX)
can be calculated as (see Sec. A.0.2 for details)
det(X
H
AX)
X
=
1
2
_
det(X
H
AX)
'X
i
det(X
H
AX)
X
_
= det(X
H
AX)
_
(X
H
AX)
1
X
H
A
_
T
(44)
and the complex conjugate derivative yields
det(X
H
AX)
X

=
1
2
_
det(X
H
AX)
'X
+i
det(X
H
AX)
X
_
= det(X
H
AX)AX(X
H
AX)
1
(45)
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 19
5 DECOMPOSITIONS
5 Decompositions
5.1 Eigenvalues and Eigenvectors
5.1.1 Denition
The eigenvectors v and eigenvalues are the ones satisfying
Av
i
=
i
v
i
AV = VD, (D)
ij
=
ij

i
where the columns of V are the vectors v
i
5.1.2 General Properties
eig(AB) = eig(BA)
A is n m At most min(n, m) distinct
i
rank(A) = r At most r non-zero
i
5.1.3 Symmetric
Assume A is symmetric, then
VV
T
= I (i.e. V is orthogonal)

i
R (i.e.
i
is real)
Tr(A
p
) =

i

p
i
eig(I +cA) = 1 +c
i
eig(A
1
) =
1
i
5.2 Singular Value Decomposition
Any n m matrix A can be written as
A = UDV
T
where
U = eigenvectors of AA
T
n n
D =
_
diag(eig(AA
T
)) n m
V = eigenvectors of A
T
A mm
5.2.1 Symmetric Square decomposed into squares
Assume A to be n n and symmetric. Then
_
A

=
_
V
_
D
_
V
T

where D is diagonal with the eigenvalues of A and V is orthogonal and the
eigenvectors of A.
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 20
5.3 Triangular Decomposition 5 DECOMPOSITIONS
5.2.2 Square decomposed into squares
Assume A to be n n. Then
_
A

=
_
V
_
D
_
U
T

where D is diagonal with the square root of the eigenvalues of AA
T
, V is the
eigenvectors of AA
T
and U
T
is the eigenvectors of A
T
A.
5.2.3 Square decomposed into rectangular
Assume V

U
T

= 0 then we can expand the SVD of A into


_
A

=
_
V V

_
D 0
0 D

_ _
U
T
U
T

_
where the SVD of A is A = VDU
T
.
5.2.4 Rectangular decomposition I
Assume A is n m
_
A

=
_
V
_
D
_
U
T

where D is diagonal with the square root of the eigenvalues of AA
T
, V is the
eigenvectors of AA
T
and U
T
is the eigenvectors of A
T
A.
5.2.5 Rectangular decomposition II
Assume A is n m
_
A

=
_
V

_
_
D
_
_
_
_
U
T
_
_
5.2.6 Rectangular decomposition III
Assume A is n m
_
A

=
_
V
_
D

_
_
U
T
_
_
where D is diagonal with the square root of the eigenvalues of AA
T
, V is the
eigenvectors of AA
T
and U
T
is the eigenvectors of A
T
A.
5.3 Triangular Decomposition
5.3.1 Cholesky-decomposition
Assume A is positive denite, then
A = B
T
B
where B is a unique upper triangular matrix.
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 21
6 GENERAL STATISTICS AND PROBABILITY
6 General Statistics and Probability
6.1 Moments of any distribution
6.1.1 Mean and covariance of linear forms
Assume X and x to be a matrix and a vector of random variables. Then
E[AXB+C] = AE[X]B+C
Var[Ax] = AVar[x]A
T
Cov[Ax, By] = ACov[x, y]B
T
See [14].
6.1.2 Mean and Variance of Square Forms
Assume A is symmetric, c = E[x] and = Var[x]. Assume also that all
coordinates x
i
are independent, have the same central moments
1
,
2
,
3
,
4
and denote a = diag(A). Then
E[x
T
Ax] = Tr(A) +c
T
Ac
Var[x
T
Ax] = 2
2
2
Tr(A
2
) + 4
2
c
T
A
2
c + 4
3
c
T
Aa + (
4
3
2
2
)a
T
a
See [14]
6.2 Expectations
Assume x to be a stochastic vector with mean m, covariance M and central
moments v
r
= E[(x m)
r
].
6.2.1 Linear Forms
E[Ax +b] = Am+b
E[Ax] = Am
E[x +b] = m+b
6.2.2 Quadratic Forms
E[(Ax +a)(Bx +b)
T
] = AMB
T
+ (Am+a)(Bm+b)
T
E[xx
T
] = M+mm
T
E[xa
T
x] = (M+mm
T
)a
E[x
T
ax
T
] = a
T
(M+mm
T
)
E[(Ax)(Ax)
T
] = A(M+mm
T
)A
T
E[(x +a)(x +a)
T
] = M+ (m+a)(m+a)
T
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 22
6.2 Expectations 6 GENERAL STATISTICS AND PROBABILITY
E[(Ax +a)
T
(Bx +b)] = Tr(AMB
T
) + (Am+a)
T
(Bm+b)
E[x
T
x] = Tr(M) +m
T
m
E[x
T
Ax] = Tr(AM) +m
T
Am
E[(Ax)
T
(Ax)] = Tr(AMA
T
) + (Am)
T
(Am)
E[(x +a)
T
(x +a)] = Tr(M) + (m+a)
T
(m+a)
See [7].
6.2.3 Cubic Forms
Assume x to be independent, then
E[(Ax +a)(Bx +b)
T
(Cx +c)] = Adiag(B
T
C)v
3
+Tr(BMC
T
)(Am+a)
+AMC
T
(Bm+b)
+(AMB
T
+ (Am+a)(Bm+b)
T
)(Cm+c)
E[xx
T
x] = v
3
+ 2Mm+ (Tr(M) +m
T
m)m
E[(Ax +a)(Ax +a)
T
(Ax +a)] = Adiag(A
T
A)v
3
+[2AMA
T
+ (Ax +a)(Ax +a)
T
](Am+a)
+Tr(AMA
T
)(Am+a)
E[(Ax +a)b
T
(Cx +c)(Dx +d)
T
] = (Ax +a)b
T
(CMD
T
+ (Cm+c)(Dm+d)
T
)
+(AMC
T
+ (Am+a)(Cm+c)
T
)b(Dm+d)
T
+b
T
(Cm+c)(AMD
T
(Am+a)(Dm+d)
T
)
See [7].
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 23
7 GAUSSIANS
7 Gaussians
7.1 One Dimensional
7.1.1 Density and Normalization
The density is
p(s) =
1

2
2
exp
_

(s )
2
2
2
_
Normalization integrals
_
e

(s)
2
2
2
ds =

2
2
_
e
(ax
2
+bx+c)
dx =
_

a
exp
_
b
2
4ac
4a
_
_
e
c
2
x
2
+c
1
x+c
0
dx =
_

c
2
exp
_
c
2
1
4c
2
c
0
4c
2
_
7.1.2 Completing the Squares
c
2
x
2
+c
1
x +c
0
= a(x b)
2
+w
a = c
2
b =
1
2
c
1
c
2
w =
1
4
c
2
1
c
2
+c
0
or
c
2
x
2
+c
1
x +c
0
=
1
2
2
(x )
2
+d
=
c
1
2c
2

2
=
1
2c
2
d = c
0

c
2
1
4c
2
7.1.3 Moments
If the density is expressed by
p(x) =
1

2
2
exp
_

(s )
2
2
2
_
or p(x) = C exp(c
2
x
2
+c
1
x)
then the rst few basic moments are
x) = =
c
1
2c2
x
2
) =
2
+
2
=
1
2c
2
+
_
c1
2c
2
_
2
x
3
) = 3
2
+
3
=
c
1
(2c
2
)
2
_
3
c
2
1
2c
2
_
x
4
) =
4
+ 6
2

2
+ 3
4
=
_
c
1
2c
2
_
4
+ 6
_
c
1
2c
2
_
2
_
1
2c
2
_
+ 3
_
1
2c
2
_
2
and the central moments are
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 24
7.2 Basics 7 GAUSSIANS
(x )) = 0 = 0
(x )
2
) =
2
=
_
1
2c2
_
(x )
3
) = 0 = 0
(x )
4
) = 3
4
= 3
_
1
2c2
_
2
A kind of pseudo-moments (un-normalized integrals) can easily be derived as
_
exp(c
2
x
2
+c
1
x)x
n
dx = Zx
n
) =
_

c
2
exp
_
c
2
1
4c
2
_
x
n
)
From the un-centralized moments one can derive other entities like
x
2
) x)
2
=
2
=
1
2c2
x
3
) x
2
)x) = 2
2
=
2c1
(2c2)
2
x
4
) x
2
)
2
= 2
4
+ 4
2

2
=
2
(2c2)
2
_
1 4
c
2
1
2c2
_
7.2 Basics
7.2.1 Density and normalization
The density of x ^(m, ) is
p(x) =
1
_
det(2)
exp
_

1
2
(x m)
T

1
(x m)
_
Note that if x is d-dimensional, then det(2) = (2)
d
det().
Integration and normalization
_
exp
_

1
2
(x m)
T

1
(x m)
_
dx =
_
det(2)
_
exp
_

1
2
x
T
Ax +b
T
x
_
dx =
_
det(2A
1
) exp
_
1
2
b
T
A
1
b
_
_
exp
_

1
2
Tr(S
T
AS) + Tr(B
T
S)
_
dS =
_
det(2A
1
) exp
_
1
2
Tr(B
T
A
1
B)
_
The derivatives of the density are
p(x)
x
= p(x)
1
(x m)

2
p
xx
T
= p(x)
_

1
(x m)(x m)
T

1
_
7.2.2 Linear combination
Assume x ^(m
x
,
x
) and y ^(m
y
,
y
) then
Ax +By +c ^(Am
x
+Bm
y
+c, A
x
A
T
+B
y
B
T
)
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 25
7.2 Basics 7 GAUSSIANS
7.2.3 Rearranging Means
^
Ax
[m, ] =
_
det(2(A
T

1
A)
1
)
_
det(2)
^
x
[A
1
m, (A
T

1
A)
1
]
7.2.4 Rearranging into squared form
If A is symmetric, then

1
2
x
T
Ax +b
T
x =
1
2
(x A
1
b)
T
A(x A
1
b) +
1
2
b
T
A
1
b

1
2
Tr(X
T
AX)+Tr(B
T
X) =
1
2
Tr[(XA
1
B)
T
A(XA
1
B)]+
1
2
Tr(B
T
A
1
B)
7.2.5 Sum of two squared forms
In vector formulation (assuming
1
,
2
are symmetric)

1
2
(x m
1
)
T

1
1
(x m
1
)

1
2
(x m
2
)
T

1
2
(x m
2
)
=
1
2
(x m
c
)
T

1
c
(x m
c
) +C

1
c
=
1
1
+
1
2
m
c
= (
1
1
+
1
2
)
1
(
1
1
m
1
+
1
2
m
2
)
C =
1
2
(m
T
1

1
1
+m
T
2

1
2
)(
1
1
+
1
2
)
1
(
1
1
m
1
+
1
2
m
2
)

1
2
_
m
T
1

1
1
m
1
+m
T
2

1
2
m
2
_
In a trace formulation (assuming
1
,
2
are symmetric)

1
2
Tr((XM
1
)
T

1
1
(XM
1
))

1
2
Tr((XM
2
)
T

1
2
(XM
2
))
=
1
2
Tr[(XM
c
)
T

1
c
(XM
c
)] +C

1
c
=
1
1
+
1
2
M
c
= (
1
1
+
1
2
)
1
(
1
1
M
1
+
1
2
M
2
)
C =
1
2
Tr
_
(
1
1
M
1
+
1
2
M
2
)
T
(
1
1
+
1
2
)
1
(
1
1
M
1
+
1
2
M
2
)
_

1
2
Tr(M
T
1

1
1
M
1
+M
T
2

1
2
M
2
)
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 26
7.3 Moments 7 GAUSSIANS
7.2.6 Product of gaussian densities
Let ^
x
(m, ) denote a density of x, then
^
x
(m
1
,
1
) ^
x
(m
2
,
2
) = c
c
^
x
(m
c
,
c
)
c
c
= ^
m1
(m
2
, (
1
+
2
))
=
1
_
det(2(
1
+
2
))
exp
_

1
2
(m
1
m
2
)
T
(
1
+
2
)
1
(m
1
m
2
)
_
m
c
= (
1
1
+
1
2
)
1
(
1
1
m
1
+
1
2
m
2
)

c
= (
1
1
+
1
2
)
1
but note that the product is not normalized as a density of x.
7.3 Moments
7.3.1 Mean and covariance of linear forms
First and second moments. Assume x ^(m, )
E(x) = m
Cov(x, x) = Var(x) = = E(xx
T
) E(x)E(x
T
) = E(xx
T
) mm
T
As for any other distribution is holds for gaussians that
E[Ax] = AE[x]
Var[Ax] = AVar[x]A
T
Cov[Ax, By] = ACov[x, y]B
T
7.3.2 Mean and variance of square forms
Mean and variance of square forms: Assume x ^(m, )
E(xx
T
) = +mm
T
E[x
T
Ax] = Tr(A) +m
T
Am
Var(x
T
Ax) = 2
4
Tr(A
2
) + 4
2
m
T
A
2
m
E[(x m

)
T
A(x m

)] = (mm

)
T
A(mm

) + Tr(A)
Assume x ^(0,
2
I) and A and B to be symmetric, then
Cov(x
T
Ax, x
T
Bx) = 2
4
Tr(AB)
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 27
7.3 Moments 7 GAUSSIANS
7.3.3 Cubic forms
E[xb
T
xx
T
] = mb
T
(M+mm
T
) + (M+mm
T
)bm
T
+b
T
m(Mmm
T
)
7.3.4 Mean of Quartic Forms
E[xx
T
xx
T
] = 2(+mm
T
)
2
+m
T
m(mm
T
)
+Tr()(+mm
T
)
E[xx
T
Axx
T
] = (+mm
T
)(A+A
T
)(+mm
T
)
+m
T
Am(mm
T
) + Tr[A(+mm
T
)]
E[x
T
xx
T
x] = 2Tr(
2
) + 4m
T
m+ (Tr() +m
T
m)
2
E[x
T
Axx
T
Bx] = Tr[A(B+B
T
)] +m
T
(A+A
T
)(B+B
T
)m
+(Tr(A) +m
T
Am)(Tr(B) +m
T
Bm)
E[a
T
xb
T
xc
T
xd
T
x]
= (a
T
(+mm
T
)b)(c
T
(+mm
T
)d)
+(a
T
(+mm
T
)c)(b
T
(+mm
T
)d)
+(a
T
(+mm
T
)d)(b
T
(+mm
T
)c) 2a
T
mb
T
mc
T
md
T
m
E[(Ax +a)(Bx +b)
T
(Cx +c)(Dx +d)
T
]
= [AB
T
+ (Am+a)(Bm+b)
T
][CD
T
+ (Cm+c)(Dm+d)
T
]
+[AC
T
+ (Am+a)(Cm+c)
T
][BD
T
+ (Bm+b)(Dm+d)
T
]
+(Bm+b)
T
(Cm+c)[AD
T
(Am+a)(Dm+d)
T
]
+Tr(BC
T
)[AD
T
+ (Am+a)(Dm+d)
T
]
E[(Ax +a)
T
(Bx +b)(Cx +c)
T
(Dx +d)]
= Tr[A(C
T
D+D
T
C)B
T
]
+[(Am+a)
T
B+ (Bm+b)
T
A][C
T
(Dm+d) +D
T
(Cm+c)]
+[Tr(AB
T
) + (Am+a)
T
(Bm+b)][Tr(CD
T
) + (Cm+c)
T
(Dm+d)]
See [7].
7.3.5 Moments
E[x] =

k
m
k
Cov(x) =

k
(
k
+m
k
m
T
k
m
k
m
T
k
)
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 28
7.4 Miscellaneous 7 GAUSSIANS
7.4 Miscellaneous
7.4.1 Whitening
Assume x ^(m, ) then
z =
1/2
(x m) ^(0, I)
Conversely having z ^(0, I) one can generate data x ^(m, ) by setting
x =
1/2
z +m ^(m, )
Note that
1/2
means the matrix which fulls
1/2

1/2
= , and that it exists
and is unique since is positive denite.
7.4.2 The Chi-Square connection
Assume x ^(m, ) and x to be n dimensional, then
z = (x m)
T

1
(x m)
2
n
7.4.3 Entropy
Entropy of a D-dimensional gaussian
H(x) =
_
^(m, ) ln^(m, )dx = ln
_
det(2)
D
2
7.5 One Dimensional Mixture of Gaussians
7.5.1 Density and Normalization
p(s) =
K

k
_
2
2
k
exp
_

1
2
(s
k
)
2

2
k
_
7.5.2 Moments
An useful fact of MoG, is that
x
n
) =

k
x
n
)
k
where )
k
denotes average with respect to the k.th component. We can calculate
the rst four moments from the densities
p(x) =

k
1
_
2
2
k
exp
_

1
2
(x
k
)
2

2
k
_
p(x) =

k
C
k
exp
_
c
k2
x
2
+c
k1
x

as
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 29
7.6 Mixture of Gaussians 7 GAUSSIANS
x) =

k

k

k
=

k

k
_
c
k1
2c
k2
_
x
2
) =

k

k
(
2
k
+
2
k
) =

k

k
_
1
2c
k2
+
_
c
k1
2c
k2
_
2
_
x
3
) =

k

k
(3
2
k

k
+
3
k
) =

k

k
_
c
k1
(2c
k2
)
2
_
3
c
2
k1
2c
k2
__
x
4
) =

k

k
(
4
k
+ 6
2
k

2
k
+ 3
4
k
) =

k

k
_
_
1
2c
k2
_
2
_
_
c
k1
2c
k2
_
2
6
c
2
k1
2c
k2
+ 3
__
If all the gaussians are centered, i.e.
k
= 0 for all k, then
x) = 0 = 0
x
2
) =

k

k

2
k
=

k

k
_
1
2c
k2
_
x
3
) = 0 = 0
x
4
) =

k

k
3
4
k
=

k

k
3
_
1
2c
k2
_
2
From the un-centralized moments one can derive other entities like
x
2
) x)
2
=

k,k

k

2
k
+
2
k

k

x
3
) x
2
)x) =

k,k

k

_
3
2
k

k
+
3
k
(
2
k
+
2
k
)
k

x
4
) x
2
)
2
=

k,k

k

4
k
+ 6
2
k

2
k
+ 3
4
k
(
2
k
+
2
k
)(
2
k
+
2
k
)

7.6 Mixture of Gaussians


7.6.1 Density
The variable x is distributed as a mixture of gaussians if it has the density
p(x) =
K

k=1

k
1
_
det(2
k
)
exp
_

1
2
(x m
k
)
T

1
k
(x m
k
)
_
where
k
sum to 1 and the
k
all are positive denite.
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 30
8 MISCELLANEOUS
8 Miscellaneous
8.1 Functions and Series
8.1.1 Finite Series
(X
n
I)(XI)
1
= I +X+X
2
+... +X
n1
8.1.2 Taylor Expansion of Scalar Function
Consider some scalar function f(x) which takes the vector x as an argument.
This we can Taylor expand around x
0
f(x)

= f(x
0
) +g(x
0
)
T
(x x
0
) +
1
2
(x x
0
)
T
H(x
0
)(x x
0
)
where
g(x
0
) =
f(x)
x

x0
H(x
0
) =

2
f(x)
xx
T

x0
8.1.3 Taylor Expansion of Vector Functions
8.1.4 Matrix Functions by Innite Series
As for analytical functions in one dimension, one can dene a matrix function
for square matrices X by an innite series
f (X) =

n=0
c
n
X
n
assuming the limit exists and is nite. If the coecients c
n
fulls

n
c
n
x
n
< ,
then one can prove that the above series exists and is nite, 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]:
p() = det(I A) =

n
c
n

n
p(A) = 0
2) If A is square it holds that [1]
A = UBU
1
f (A) = Uf (B)U
1
3) A useful fact when using power series is that
A
n
0 for n if [A[ < 1
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 31
8.2 Indices, Entries and Vectors 8 MISCELLANEOUS
8.1.5 Exponential Matrix Function
In analogy to the ordinary scalar exponential function, one can dene exponen-
tial and logarithmic matrix functions:
e
A
=

n=0
1
n!
A
n
= I +A+
1
2
A
2
+...
e
A
=

n=0
1
n!
(1)
n
A
n
= I A+
1
2
A
2
...
e
tA
=

n=0
1
n!
(tA)
n
= I +tA+
1
2
t
2
A
2
+...
ln(I +A) =

n=1
(1)
n1
n
A
n
= A
1
2
A
2
+
1
3
A
3
...
Some of the properties of the exponential function are [1]
e
A
e
B
= e
A+B
if AB = BA
(e
A
)
1
= e
A
d
dt
e
tA
= Ae
tA
, t R
8.1.6 Trigonometric Functions
sin(A) =

n=0
(1)
n
A
2n+1
(2n + 1)!
= A
1
3!
A
3
+
1
5!
A
5
...
cos(A) =

n=0
(1)
n
A
2n
(2n)!
= I
1
2!
A
2
+
1
4!
A
4
...
8.2 Indices, Entries and Vectors
Let e
i
denote the column vector which is 1 on entry i and zero elsewhere, i.e.
(e
i
)
j
=
ij
, and let J
ij
denote the matrix which is 1 on entry (i, j) and zero
elsewhere.
8.2.1 Rows and Columns
i.th row of A = e
T
i
A
j.th column of A = Ae
j
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 32
8.2 Indices, Entries and Vectors 8 MISCELLANEOUS
8.2.2 Permutations
Let P be some permutation matrix, e.g.
P =
_
_
0 1 0
1 0 0
0 0 1
_
_
=
_
e
2
e
1
e
3

=
_
_
e
T
2
e
T
1
e
T
3
_
_
then
AP =
_
Ae
2
Ae
1
Ae
2

PA =
_
_
e
T
2
A
e
T
1
A
e
T
3
A
_
_
That is, the rst 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 se-
quence.
8.2.3 Swap and Zeros
Assume A to be n m and J
ij
to be mp
AJ
ij
=
_
0 0 . . . A
i
. . . 0

i.e. an n p matrix of zeros with the i.th column of A in the placed of the j.th
column. Assume A to be n m and J
ij
to be p n
J
ij
A =
_

_
0
0
.
.
.
A
j
.
.
.
0
_

_
i.e. an p m matrix of zeros with the j.th row of A in the placed of the i.th
row.
8.2.4 Rewriting product of elements
A
ki
B
jl
= (Ae
i
e
T
j
B)
kl
= (AJ
ij
B)
kl
A
ik
B
lj
= (A
T
e
i
e
T
j
B
T
)
kl
= (A
T
J
ij
B
T
)
kl
A
ik
B
jl
= (A
T
e
i
e
T
j
B)
kl
= (A
T
J
ij
B)
kl
A
ki
B
lj
= (Ae
i
e
T
j
B
T
)
kl
= (AJ
ij
B
T
)
kl
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 33
8.2 Indices, Entries and Vectors 8 MISCELLANEOUS
8.2.5 Properties of the Singleentry Matrix
If i = j
J
ij
J
ij
= J
ij
(J
ij
)
T
(J
ij
)
T
= J
ij
J
ij
(J
ij
)
T
= J
ij
(J
ij
)
T
J
ij
= J
ij
If i ,= j
J
ij
J
ij
= 0 (J
ij
)
T
(J
ij
)
T
= 0
J
ij
(J
ij
)
T
= J
ii
(J
ij
)
T
J
ij
= J
jj
8.2.6 The Singleentry Matrix in Scalar Expressions
Assume A is n m and J is mn, then
Tr(AJ
ij
) = Tr(J
ij
A) = (A
T
)
ij
Assume A is n n, J is n m and B is mn, then
Tr(AJ
ij
B) = (A
T
B
T
)
ij
Tr(AJ
ji
B) = (BA)
ij
Tr(AJ
ij
J
ij
B) = diag(A
T
B
T
)
ij
Assume A is n n, J
ij
is n m B is mn, then
x
T
AJ
ij
Bx = (A
T
xx
T
B
T
)
ij
x
T
AJ
ij
J
ij
Bx = diag(A
T
xx
T
B
T
)
ij
8.2.7 Structure Matrices
The structure matrix is dened by
A
A
ij
= S
ij
If A has no special structure then
S
ij
= J
ij
If A is symmetric then
S
ij
= J
ij
+J
ji
J
ij
J
ij
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 34
8.3 Solutions to Systems of Equations 8 MISCELLANEOUS
8.3 Solutions to Systems of Equations
8.3.1 Existence in Linear Systems
Assume A is n m and consider the linear system
Ax = b
Construct the augmented matrix B = [A b] then
Condition Solution
rank(A) = rank(B) = m Unique solution x
rank(A) = rank(B) < m Many solutions x
rank(A) < rank(B) No solutions x
8.3.2 Standard Square
Assume A is square and invertible, then
Ax = b x = A
1
b
8.3.3 Degenerated Square
8.3.4 Over-determined Rectangular
Assume A to be n m, n > m (tall) and rank(A) = m, then
Ax = b x = (A
T
A)
1
A
T
b = A
+
b
that is if there exists a solution x at all! If there is no solution the following
can be useful:
Ax = b x
min
= A
+
b
Now x
min
is the vector x which minimizes [[Ax b[[
2
, i.e. the vector which is
least wrong. The matrix A
+
is the pseudo-inverse of A. See [3].
8.3.5 Under-determined Rectangular
Assume A is n m and n < m (broad).
Ax = b x
min
= A
T
(AA
T
)
1
b
The equation have many solutions x. But x
min
is the solution which minimizes
[[Axb[[
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 mn and B is n n, then
AX = B X
min
= A
+
B
The equation have many solutions X. But X
min
is the solution which minimizes
[[AXB[[
2
and also the solution with the smallest norm [[X[[
2
. See [3].
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 35
8.4 Block matrices 8 MISCELLANEOUS
Similar but dierent: Assume A is square n n and the matrices B
0
, B
1
are n N, where N > n, then if B
0
has maximal rank
AB
0
= B
1
A
min
= B
1
B
T
0
(B
0
B
T
0
)
1
where A
min
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 B
0
into the columns vectors of B
1
.
8.3.6 Linear form and zeros
Ax = 0, x A = 0
8.3.7 Square form and zeros
If A is symmetric, then
x
T
Ax = 0, x A = 0
8.4 Block matrices
Let A
ij
denote the ij.th block of A.
8.4.1 Multiplication
Assuming the dimensions of the blocks matches we have
_
A
11
A
12
A
21
A
22
_ _
B
11
B
12
B
21
B
22
_
=
_
A
11
B
11
+A
12
B
21
A
11
B
12
+A
12
B
22
A
21
B
11
+A
22
B
21
A
21
B
12
+A
22
B
22
_
8.4.2 The Determinant
The determinant can be expressed as by the use of
C
1
= A
11
A
12
A
1
22
A
21
C
2
= A
22
A
21
A
1
11
A
12
as
det
__
A
11
A
12
A
21
A
22
__
= det(A
22
) det(C
1
) = det(A
11
) det(C
2
)
8.4.3 The Inverse
The inverse can be expressed as by the use of
C
1
= A
11
A
12
A
1
22
A
21
C
2
= A
22
A
21
A
1
11
A
12
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 36
8.5 Matrix Norms 8 MISCELLANEOUS
as
_
A
11
A
12
A
21
A
22
_
1
=
_
C
1
1
A
1
11
A
12
C
1
2
C
1
2
A
21
A
1
11
C
1
2
_
=
_
A
1
11
+A
1
11
A
12
C
1
2
A
21
A
1
11
C
1
1
A
12
A
1
22
A
1
22
A
21
C
1
1
A
1
22
+A
1
22
A
21
C
1
1
A
12
A
1
22
_
8.4.4 Block diagonal
For block diagonal matrices we have
_
A
11
0
0 A
22
_
1
=
_
(A
11
)
1
0
0 (A
22
)
1
_
det
__
A
11
0
0 A
22
__
= det(A
11
) det(A
22
)
8.5 Matrix Norms
8.5.1 Denitions
A matrix norm is a mapping which fulls
[[A[[ 0 [[A[[ = 0 A = 0
[[cA[[ = [c[[[A[[, c R
[[A+B[[ [[A[[ +[[B[[
8.5.2 Examples
[[A[[
1
= max
j

i
[A
ij
[
[[A[[
2
=
_
max eig(A
T
A)
[[A[[
p
= ( max
||x||p=1
[[Ax[[
p
)
1/p
[[A[[

= max
i

j
[A
ij
[
[[A[[
F
=

ij
[A
ij
[
2
(Frobenius)
[[A[[
max
= max
ij
[A
ij
[
[[A[[
KF
= [[sing(A)[[
1
(Ky Fan)
where sing(A) is the vector of singular values of the matrix A.
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 37
8.6 Positive Denite and Semi-denite Matrices 8 MISCELLANEOUS
8.5.3 Inequalities
E. H. Rasmussen has in yet unpublished material derived and collected the
following inequalities. They are collected in a table as below, assuming A is an
mn, and d = minm, n
[[A[[
max
[[A[[
1
[[A[[

[[A[[
2
[[A[[
F
[[A[[
KF
[[A[[
max
1 1 1 1 1
[[A[[
1
m m

m

m

m
[[A[[

n n

n

n

n
[[A[[
2

mn

n

m 1 1
[[A[[
F

mn

n

m

d 1
[[A[[
KF

mnd

nd

md d

d
which are to be read as, e.g.
[[A[[
2

m [[A[[

8.6 Positive Denite and Semi-denite Matrices


8.6.1 Denitions
A matrix A is positive denite if and only if
x
T
Ax > 0, x
A matrix A is positive semi-denite if and only if
x
T
Ax 0, x
Note that if A is positive denite, then A is also positive semi-denite.
8.6.2 Eigenvalues
The following holds with respect to the eigenvalues:
A pos. def. eig(A) > 0
A pos. semi-def. eig(A) 0
8.6.3 Trace
The following holds with respect to the trace:
A pos. def. Tr(A) > 0
A pos. semi-def. Tr(A) 0
8.6.4 Inverse
If A is positive denite, then A is invertible and A
1
is also positive denite.
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 38
8.7 Integral Involving Dirac Delta Functions 8 MISCELLANEOUS
8.6.5 Diagonal
If A is positive denite, then A
ii
> 0, i
8.6.6 Decomposition I
The matrix A is positive semi-denite of rank r there exists a matrix B of
rank r such that A = BB
T
The matrix A is positive denite there exists an invertible matrix B such
that A = BB
T
8.6.7 Decomposition II
Assume A is an n n positive semi-denite, then there exists an n r matrix
B of rank r such that B
T
AB = I.
8.6.8 Equation with zeros
Assume A is positive semi-denite, then X
T
AX = 0 AX = 0
8.6.9 Rank of product
Assume A is positive denite, then rank(BAB
T
) = rank(B)
8.6.10 Positive denite property
If A is n n positive denite and B is r n of rank r, then BAB
T
is positive
denite.
8.6.11 Outer Product
If X is n r of rank r, then XX
T
is positive denite.
8.6.12 Small pertubations
If A is positive denite and B is symmetric, then AtB is positive denite for
suciently small t.
8.7 Integral Involving Dirac Delta Functions
Assuming A to be square, then
_
p(s)(x As)ds =
1
det(A)
p(A
1
x)
Assuming A to be underdetermined, i.e. tall, then
_
p(s)(x As)ds =
_
1

det(A
T
A)
p(A
+
x) if x = AA
+
x
0 elsewhere
_
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 39
8.8 Miscellaneous 8 MISCELLANEOUS
See [8].
8.8 Miscellaneous
For any A it holds that
rank(A) = rank(A
T
) = rank(AA
T
) = rank(A
T
A)
Assume A is positive denite. Then
rank(B
T
AB) = rank(B)
A is positive denite B invertible, such that A = BB
T
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 40
A PROOFS AND DETAILS
A Proofs and Details
A.0.1 Proof of Equation 14
Essentially we need to calculate
(X
n
)
kl
X
ij
=

X
ij

u
1
,...,u
n1
X
k,u
1
X
u
1
,u
2
...X
u
n1
,l
=
k,i

u1,j
X
u1,u2
...X
un1,l
+X
k,u1

u1,i

u2,j
...X
un1,l
.
.
.
+X
k,u1
X
u1,u2
...
un1,i

l,j
=
n1

r=0
(X
r
)
ki
(X
n1r
)
jl
=
n1

r=0
(X
r
J
ij
X
n1r
)
kl
Using the properties of the single entry matrix found in Sec. 8.2.5, the result
follows easily.
A.0.2 Details on Eq. 47
det(X
H
AX) = det(X
H
AX)Tr[(X
H
AX)
1
(X
H
AX)]
= det(X
H
AX)Tr[(X
H
AX)
1
((X
H
)AX+X
H
(AX))]
= det(X
H
AX)
_
Tr[(X
H
AX)
1
(X
H
)AX] + Tr[(X
H
AX)
1
X
H
(AX)]
_
= det(X
H
AX)
_
Tr[AX(X
H
AX)
1
(X
H
)] + Tr[(X
H
AX)
1
X
H
A(X)]
_
First, the derivative is found with respect to the real part of X
det(X
H
AX)
'X
= det(X
H
AX)
_
Tr[AX(X
H
AX)
1
(X
H
)]
'X
+
Tr[(X
H
AX)
1
X
H
A(X)]
'X
_
= det(X
H
AX)
_
AX(X
H
AX)
1
+ ((X
H
AX)
1
X
H
A)
T
_
Through the calculations, (16) and (35) were used. In addition, by use of (36),
the derivative is found with respect to the imaginary part of X
i
det(X
H
AX)
X
= i det(X
H
AX)
_
Tr[AX(X
H
AX)
1
(X
H
)]
X
+
Tr[(X
H
AX)
1
X
H
A(X)]
X
_
= det(X
H
AX)
_
AX(X
H
AX)
1
((X
H
AX)
1
X
H
A)
T
_
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 41
A PROOFS AND DETAILS
Hence, derivative yields
det(X
H
AX)
X
=
1
2
_
det(X
H
AX)
'X
i
det(X
H
AX)
X
_
= det(X
H
AX)
_
(X
H
AX)
1
X
H
A
_
T
and the complex conjugate derivative yields
det(X
H
AX)
X

=
1
2
_
det(X
H
AX)
'X
+i
det(X
H
AX)
X
_
= det(X
H
AX)AX(X
H
AX)
1
Notice, for real X, A, the sum of (44) and (45) is reduced to (13).
Similar calculations yield
det(XAX
H
)
X
=
1
2
_
det(XAX
H
)
'X
i
det(XAX
H
)
X
_
= det(XAX
H
)
_
AX
H
(XAX
H
)
1
_
T
(46)
and
det(XAX
H
)
X

=
1
2
_
det(XAX
H
)
'X
+i
det(XAX
H
)
X
_
= det(XAX
H
)(XAX
H
)
1
XA (47)
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 42
REFERENCES REFERENCES
References
[1] Karl Gustav Andersson and Lars-Christer Boiers. Ordinaera dierentialek-
vationer. Studenterlitteratur, 1992.
[2] Jorn Anem uller, Terrence J. Sejnowski, and Scott Makeig. Complex inde-
pendent component analysis of frequency-domain electroencephalographic
data. Neural Networks, 16(9):13111323, November 2003.
[3] S. Barnet. Matrices. Methods and Applications. Oxford Applied Mathe-
matics and Computin Science Series. Clarendon Press, 1990.
[4] Christoer Bishop. Neural Networks for Pattern Recognition. Oxford Uni-
versity 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] Mads Dyrholm. Some matrix results, 2004. Website August 23, 2004.
[9] Simon Haykin. Adaptive Filter Theory. Prentice Hall, Upper Saddle River,
NJ, 4th edition, 2002.
[10] Thomas P. Minka. Old and new matrix algebra useful for statistics, De-
cember 2000. Notes.
[11] L. Parra and C. Spence. Convolutive blind separation of non-stationary
sources. In IEEE Transactions Speech and Audio Processing, pages 320
327, May 2000.
[12] Laurent Schwartz. Cours dAnalyse, volume II. Hermann, Paris, 1967. As
referenced in [9].
[13] Shayle R. Searle. Matrix Algebra Useful for Statistics. John Wiley and
Sons, 1982.
[14] G. Seber and A. Lee. Linear Regression Analysis. John Wiley and Sons,
2002.
[15] S. M. Selby. Standard Mathematical Tables. CRC Press, 1974.
[16] Inna Stainvas. Matrix algebra in dierential calculus. Neural Computing
Research Group, Information Engeneering, Aston University, UK, August
2002. Notes.
[17] Max Welling. The kalman lter. Lecture Note.
Petersen & Pedersen, The Matrix Cookbook (Version: January 5, 2005), Page 43

You might also like