You are on page 1of 71

The Matrix Cookbook

[ http://matrixcookbook.com ]
Kaare Brandt Petersen
Michael Syskind Pedersen
Version: November 14, 2008
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 .
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.
Very likely there are errors, typos, and mistakes for which we apolo-
gize and would be grateful to receive corrections at cookbook@2302.dk.
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.
Your suggestion for additional content or elaboration of some
topics is most welcome at cookbook@2302.dk.
Matrix algebra, matrix relations, matrix identities, derivative of
determinant, derivative of inverse matrix, dierentiate a matrix.
We would like to thank the following for contributions
and suggestions: Bill Baxter, Brian Templeton, Christian Rishj, Christian
Schroppel Douglas L. Theobald, Esben Hoegh-Rasmussen, Glynne Casteel, Jan
Larsen, Jun Bin Gao, J urgen Struckmeier, Kamil Dedecius, Korbinian Strim-
mer, Lars Christiansen, Lars Kai Hansen, Leland Wilkinson, Liguo He, Loic
Thibaut, Miguel Barao, Ole Winther, Pavel Sakov, Stephan Hattinger, Vasile
Sima, Vincent Rabaud, Zhaoshui He. We would also like thank The Oticon
Foundation for funding our PhD studies.
1
CONTENTS CONTENTS
Contents
1.1 Trace and Determinants . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 The Special Case 2x2 . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1 Derivatives of a Determinant . . . . . . . . . . . . . . . . . . . . 7
2.2 Derivatives of an Inverse . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Derivatives of Eigenvalues . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Derivatives of Matrices, Vectors and Scalar Forms . . . . . . . . 9
2.5 Derivatives of Traces . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.6 Derivatives of vector norms . . . . . . . . . . . . . . . . . . . . . 13
2.7 Derivatives of matrix norms . . . . . . . . . . . . . . . . . . . . . 13
2.8 Derivatives of Structured Matrices . . . . . . . . . . . . . . . . . 14
3.1 Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2 Exact Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 Implication on Inverses . . . . . . . . . . . . . . . . . . . . . . . . 19
3.4 Approximations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.5 Generalized Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.6 Pseudo Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1 Complex Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2 Higher order and non-linear derivatives . . . . . . . . . . . . . . . 26
4.3 Inverse of complex sum . . . . . . . . . . . . . . . . . . . . . . . 26
5.1 Solutions to linear equations . . . . . . . . . . . . . . . . . . . . . 27
5.2 Eigenvalues and Eigenvectors . . . . . . . . . . . . . . . . . . . . 29
5.3 Singular Value Decomposition . . . . . . . . . . . . . . . . . . . . 30
5.4 Triangular Decomposition . . . . . . . . . . . . . . . . . . . . . . 32
5.5 LU decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.6 LDM decomposition . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.7 LDL decompositions . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.1 Denition of Moments . . . . . . . . . . . . . . . . . . . . . . . . 33
6.2 Expectation of Linear Combinations . . . . . . . . . . . . . . . . 34
6.3 Weighted Scalar Variable . . . . . . . . . . . . . . . . . . . . . . 35
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 2
CONTENTS CONTENTS
7.1 Cauchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.2 Dirichlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.3 Normal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.4 Normal-Inverse Gamma . . . . . . . . . . . . . . . . . . . . . . . 36
7.5 Gaussian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.6 Multinomial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.7 Students t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.8 Wishart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.9 Wishart, Inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.2 Moments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
8.3 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
8.4 Mixture of Gaussians . . . . . . . . . . . . . . . . . . . . . . . . . 44
9.1 Block matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
9.2 Discrete Fourier Transform Matrix, The . . . . . . . . . . . . . . 46
9.3 Hermitian Matrices and skew-Hermitian . . . . . . . . . . . . . . 47
9.4 Idempotent Matrices . . . . . . . . . . . . . . . . . . . . . . . . . 48
9.5 Orthogonal matrices . . . . . . . . . . . . . . . . . . . . . . . . . 48
9.6 Positive Denite and Semi-denite Matrices . . . . . . . . . . . . 50
9.7 Singleentry Matrix, The . . . . . . . . . . . . . . . . . . . . . . . 51
9.8 Symmetric, Skew-symmetric/Antisymmetric . . . . . . . . . . . . 53
9.9 Toeplitz Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
9.10 Transition matrices . . . . . . . . . . . . . . . . . . . . . . . . . . 55
9.11 Units, Permutation and Shift . . . . . . . . . . . . . . . . . . . . 56
9.12 Vandermonde Matrices . . . . . . . . . . . . . . . . . . . . . . . . 57
10.1 Functions and Series . . . . . . . . . . . . . . . . . . . . . . . . . 58
10.2 Kronecker and Vec Operator . . . . . . . . . . . . . . . . . . . . 59
10.3 Vector Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.4 Matrix Norms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
10.5 Rank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
10.6 Integral Involving Dirac Delta Functions . . . . . . . . . . . . . . 62
10.7 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
A.1 Gaussian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
A.2 One Dimensional Mixture of Gaussians . . . . . . . . . . . . . . . 65
B.1 Misc Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 3
CONTENTS CONTENTS
Notation and Nomenclature
Matrix
ij
Matrix indexed for some purpose
i
Matrix indexed for some purpose
ij
Matrix indexed for some purpose
n
Matrix indexed for some purpose
The n.th power of a square matrix

The inverse matrix of the matrix


The pseudo inverse matrix of the matrix (see Sec. 3.6)
/
The square root of a matrix (if unique), not elementwise
( )
ij
The ( ).th entry of the matrix
ij
The ( ).th entry of the matrix
[ ]
ij
The -submatrix, i.e. with i.th row and j.th column deleted
Vector
i
Vector indexed for some purpose
i
The i.th element of the vector
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( ) Determinant of
Tr( ) Trace of the matrix
diag( ) Diagonal matrix of the matrix , i.e. (diag( ))
ij
=
ij ij
eig( ) Eigenvalues of the matrix
vec( ) The vector-version of the matrix (see Sec. 10.2.2)
sup Supremum of a set
[[ [[ Matrix norm (subscript if any denotes what norm)
T
Transposed matrix
T
The inverse of the transposed and vice versa,
T
= (

)
T
= (
T
)

Complex conjugated matrix


H
Transposed and complex conjugated matrix (Hermitian)
Hadamard (elementwise) product
Kronecker product
The null matrix. Zero in all entries.
The identity matrix
ij
The single-entry matrix, 1 at ( ) and zero elsewhere
A positive denite matrix
A diagonal matrix
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 4
1 BASICS
1 Basics
( )

=

(1)
( )

=

(2)
(
T
)

= (

)
T
(3)
( + )
T
=
T
+
T
(4)
( )
T
=
T T
(5)
( )
T
=
T T T
(6)
(
H
)

= (

)
H
(7)
( + )
H
=
H
+
H
(8)
( )
H
=
H H
(9)
( )
H
=
H H H
(10)
1.1 Trace and Determinants
Tr( ) =

i
ii
(11)
Tr( ) =

i
i i
= eig( ) (12)
Tr( ) = Tr(
T
) (13)
Tr( ) = Tr( ) (14)
Tr( + ) = Tr( ) + Tr( ) (15)
Tr( ) = Tr( ) = Tr( ) (16)
det( ) =

i
i i
= eig( ) (17)
det( ) =
n
det( ) if R
nn
(18)
det(
T
) = det( ) (19)
det( ) = det( ) det( ) (20)
det(

) = 1 det( ) (21)
det(
n
) = det( )
n
(22)
det( +
T
) = 1 +
T
(23)
det( + )

= 1 + Tr( ) small (24)
1.2 The Special Case 2x2
Consider the matrix
=
_ _
Determinant and trace
det( ) = (25)
Tr( ) = + (26)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 5
1.2 The Special Case 2x2 1 BASICS
Eigenvalues
Tr( ) + det( ) = 0
=
Tr( ) +
_
Tr( ) 4 det( )
2
=
Tr( )
_
Tr( ) 4 det( )
2
+ = Tr( ) = det( )
Eigenvectors

_

_

_

_
Inverse

=
1
det( )
_

_
(27)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 6
2 DERIVATIVES
2 Derivatives
This section is covering dierentiation of a number of expressions with respect to
a matrix . Note that it is always assumed that has no special structure, i.e.
that the elements of are independent (e.g. not symmetric, Toeplitz, positive
denite). See section 2.8 for dierentiation of structured matrices. The basic
assumptions can be written in a formula as
kl
ij
=
ik lj
(28)
that is for e.g. vector forms,
_ _
i
=
i
_ _
i
=
i
_ _
ij
=
i
j
2.2 Derivatives of an Inverse 2 DERIVATIVES
det( )
= det( )(

)
T
(43)

k
det( )
ik
jk
=
ij
det( ) (44)
det( )
= det( )(

)
T
= det( )(
T
)

(45)
If is square and invertible, then
det(
T
)
= 2 det(
T
)
T
(46)
If is not square but is symmetric, then
det(
T
)
= 2 det(
T
) (
T
)

(47)
If is not square and is not symmetric, then
det(
T
)
= det(
T
)( (
T
)

+
T
(
T T
)

) (48)
Some special cases are (See [9, 7])
lndet(
T
)[
= 2( )
T
(49)
lndet(
T
)
= 2
T
(50)
ln[ det( )[
= (

)
T
= (
T
)

(51)
det(
k
)
= det(
k
)
T
(52)
2.2 Derivatives of an Inverse
From [27] we have the basic identity

=

(53)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 8
2.3 Derivatives of Eigenvalues 2 DERIVATIVES
from which it follows
(

)
kl
ij
= (

)
ki
(

)
jl
(54)
T
=
T T T
(55)
det(

)
= det(

)(

)
T
(56)
Tr(

)
= (

)
T
(57)
Tr(( + )

)
= (( + )

( + )

)
T
(58)
From [32] we have the following result: Let be an invertible square
matrix, be the inverse of , and ( ) is an -variate and dierentiable
function with respect to , then the partial dierentials of with respect to
and satisfy
=
T T
2.3 Derivatives of Eigenvalues

eig( ) = Tr( ) = (59)

eig( ) = det( ) = det( )


T
(60)
2.4 Derivatives of Matrices, Vectors and Scalar Forms
T
=
T
= (61)
T
=
T
(62)
T T
=
T
(63)
T
=
T T
=
T
(64)
ij
=
ij
(65)
( )
ij
mn
=
im
( )
nj
= (
mn
)
ij
(66)
(
T
)
ij
mn
=
in
( )
mj
= (
nm
)
ij
(67)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 9
2.4 Derivatives of Matrices, Vectors and Scalar Forms 2 DERIVATIVES
ij

klmn
kl mn
= 2

kl
kl
(68)
T T
= (
T
+
T
) (69)
( + )
T
( + )
=
T
( + ) +
T T
( + ) (70)
(
T
)
kl
ij
=
lj
(
T
)
ki
+
kj
( )
il
(71)
(
T
)
ij
=
T ij
+
ji
(
ij
)
kl
=
ik jl
(72)
See Sec 9.7 for useful properties of the Single-entry matrix
ij
T
= ( +
T
) (73)
T T
=
T T
+
T
(74)
( + )
T
( + ) = ( +
T
)( + )
T
(75)
Assume is symmetric, then
( )
T
( ) = 2
T
( ) (76)
( )
T
( ) = 2 ( ) (77)
( )
T
( ) = 2 ( ) (78)
( )
T
( ) = 2 ( ) (79)
( )
T
( ) = 2 ( )
T
(80)
As a case with complex values the following holds
(
H
)
= 2 (
H
)

(81)
This formula is also known from the LMS algorithm [14]
(
n
)
kl
ij
=
n

r
(
r ij n r
)
kl
(82)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 10
2.5 Derivatives of Traces 2 DERIVATIVES
For proof of the above, see B.1.1.
T n
=
n

r
(
r
)
T T
(
n r
)
T
(83)
T
(
n
)
T n
=
n

r
_
n r T
(
n
)
T r
+(
r
)
T n T
(
n r
)
T
_
(84)
See B.1.1 for a proof.
Assume and are functions of , i.e. = ( ) = ( ), and that is a
constant, then
T
=
_ _
T
+
_ _
T
T
(85)
( )
T
( )
( )
T
( )
=
T T
T T
(86)
= 2
T
T
2
T T T
(
T T
)
(87)
Using the above we have for the gradient and the Hessian
=
T
+
T
(88)

x
= = ( +
T
) + (89)
T
= +
T
(90)
2.5 Derivatives of Traces
Assume ( ) to be a dierentiable function of each of the elements of . It
then holds that
Tr( ( ))
= ( )
T
where () is the scalar derivative of ().
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 11
2.5 Derivatives of Traces 2 DERIVATIVES
Tr( ) = (91)
Tr( ) =
T
(92)
Tr( ) =
T T
(93)
Tr(
T
) = (94)
Tr(
T
) = (95)
Tr(
T
) = (96)
Tr( ) = Tr( ) (97)
Tr( ) = 2
T
(98)
Tr( ) = ( + )
T
(99)
Tr(
T
) = +
T
(100)
Tr(
T
) =
T
+ (101)
Tr( ) =
T T T
+
T T T
(102)
Tr(
T
) = 2 (103)
Tr(
T
) = ( +
T
) (104)
Tr(
T T
) =
T T
+
T
(105)
Tr
_
T

= +
T T
(106)
Tr(
T
) =
T T T
+ (107)
Tr
_
( + )( + )
T
_
= 2
T
( + )
T
(108)
Tr( ) = Tr( )Tr( ) = 2Tr( ) (109)
See [7].
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 12
2.6 Derivatives of vector norms 2 DERIVATIVES
Tr(
k
) = (
k
)
T
(110)
Tr(
k
) =
k

r
(
r kr
)
T
(111)

X
Tr
_
T T T

=
T T
+
T T T T
+
T T
+
T T T T
(112)
Tr(

) = (

)
T
=
T T T T
(113)
Assume and to be symmetric, then
Tr
_
(
T
)

_
= ( (
T
)

)( +
T
)(
T
)

(114)
Tr
_
(
T
)

(
T
)
_
= 2 (
T
)
T
(
T
)

+2 (
T
)

(115)
Tr
_
( +
T
)

(
T
)
_
= 2 ( +
T
)
T
( +
T
)

+2 ( +
T
)

(116)
See [7].
Tr(sin( ))
= cos( )
T
(117)
2.6 Derivatives of vector norms
[[ [[ =

[[ [[
(118)

| |
=
| |

( )( )
T
| |
(119)
[[ [[
=
[[
T
[[
= 2 (120)
2.7 Derivatives of matrix norms
For more on matrix norms, see Sec. 10.4.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 13
2.8 Derivatives of Structured Matrices 2 DERIVATIVES
[[ [[ = Tr(
H
) = 2 (121)
See (227). Note that this is also a special case of the result in equation 108.
2.8 Derivatives of Structured Matrices
Assume that the matrix 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
( )
ij
=

kl
kl
kl
ij
= Tr
_
_ _
T
ij
_
(122)
The matrix dierentiated with respect to itself is in this document referred to
as the structure matrix of and is dened simply by
ij
=
ij
(123)
If has no special structure we have simply
ij
=
ij
, that is, the structure
matrix is simply the singleentry matrix. Many structures have a representation
in singleentry matrices, see Sec. 9.7.6 for more examples of structure matrices.
Sometimes the objective is to nd the derivative of a matrix which is a function
of another matrix. Let = ( ), the goal is to nd the derivative of the
function g( ) with respect to :
( )
=
( ( ))
(124)
Then the Chain Rule can then be written the following way:
( )
=
( )
ij
=
M

k
N

l
( )
kl
kl
ij
(125)
Using matrix notation, this can be written as:
( )
ij
= Tr
_
(
( )
)
T
ij
_
(126)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 14
2.8 Derivatives of Structured Matrices 2 DERIVATIVES
If is symmetric, then
ij
=
ij
+
ji

ij ij
and therefore
=
_ _
+
_ _
T
diag
_ _
(127)
That is, e.g., ([5]):
Tr( )
= +
T
( ) see (131) (128)
det( )
= det( )(2

(

)) (129)
lndet( )
= 2

(

) (130)
If is diagonal, then ([19]):
Tr( )
= (131)
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( )
(132)
=
Tr( )
=
_

_
Tr(A) Tr([A
T
]
n1
) Tr([[A
T
]
1n
]
n1,2
) A
n1
Tr([A
T
]
1n
)) Tr(A)
.
.
.
.
.
.
.
.
.
Tr([[A
T
]
1n
]
2,n1
)
.
.
.
.
.
.
.
.
. Tr([[A
T
]
1n
]
n1,2
)
.
.
.
.
.
.
.
.
.
.
.
. Tr([A
T
]
n1
)
A
1n
Tr([[A
T
]
1n
]
2,n1
) Tr([A
T
]
1n
)) Tr(A)
_

_
( )
As it can be seen, the derivative ( ) also has a Toeplitz structure. Each value
in the diagonal is the sum of all the diagonal valued in , the values in the
diagonals next to the main diagonal equal the sum of the diagonal next to the
main diagonal in
T
. This result is only valid for the unconstrained Toeplitz
matrix. If the Toeplitz matrix also is symmetric, the same derivative yields
Tr( )
=
Tr( )
= ( ) +( )
T
( ) (133)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 15
3 INVERSES
3 Inverses
3.1 Basic
The inverse

of a matrix C
nn
is dened such that

=

= (134)
where is the identity matrix. If

exists, is said to be nonsingular.
Otherwise, is said to be singular (see e.g. [12]).
The submatrix of a matrix , denoted by [ ]
ij
is a ( 1) ( 1) matrix
obtained by deleting the th row and the th column of . The ( ) cofactor
of a matrix is dened as
cof( ) = (1)
i j
det([ ]
ij
) (135)
The matrix of cofactors can be created from the cofactors
cof( ) =
_

_
cof( 1 1) cof( 1 )
.
.
. cof( )
.
.
.
cof( 1) cof( )
_

_
(136)
The adjoint matrix is the transpose of the cofactor matrix
adj( ) = (cof( ))
T
(137)
The determinant of a matrix C
nn
is dened as (see [12])
det( ) =
n

j
(1)
j
j
det ([ ]
j
) (138)
=
n

j
j
cof( 1 ) (139)
The inverse matrix can be constructed, using the adjoint matrix, by

=
1
det( )
adj( ) (140)
For the case of 2 2 matrices, see section 1.2.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 16
3.2 Exact Relations 3 INVERSES
The condition number of a matrix ( ) is the ratio between the largest and the
smallest singular value of a matrix (see Section 5.3 on singular values),
( ) =

(141)
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
( ) = | | |

| (142)
where | | is a norm such as e.g the 1-norm, the 2-norm, the -norm or the
Frobenius norm (see Sec 10.4 for more on matrix norms).
The 2-norm of equals
_
(max(eig(
H
))) [12, p.57]. For a symmetric
matrix, this reduces to [[ [[ = max([eig( )[) [12, p.394]. If the matrix ia
symmetric and positive denite, [[ [[ = max(eig( )). The condition number
based on the 2-norm thus reduces to
| | |

| = max(eig( )) max(eig(

)) =
max(eig( ))
min(eig( ))
(143)
3.2 Exact Relations
( )

=

(144)
The Woodbury identity comes in many variants. The latter of the two can be
found in [12]
( +
T
)

=



(

+
T
)
T
(145)
( + )

=



(

+

)

(146)
If are positive denite, then (see [30])
(

+
T
)
T
=
T
(
T
+ )

(147)
( + )

=



( +

)

(148)
See [4, page 153].
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 17
3.2 Exact Relations 3 INVERSES
The following set of identities, can be found in [25, page 151],
( +

)

= ( + )

(149)
( +
T
)

=

( +
T
)

(150)
(

+

)

= ( + )

= ( + )

(151)
( + )

= ( + )

(152)

+

=

( + )

(153)
( + )

= ( + )

(154)
( + )

= ( + )

(155)
The following is a rank-1 update for the Moore-Penrose pseudo-inverse of real
valued matrices and proof can be found in [18]. The matrix is dened below:
( +
T
) = + (156)
Using the the notation
= 1 +
T
(157)
= (158)
= ( )
T
(159)
= ( ) (160)
= ( )
T
(161)
the solution is given as six dierent cases, depending on the entities [[ [[,
[[ [[, and . Please note, that for any (column) vector it holds that =
T
(
T
)

=
v
T
||v||
2
. The solution is:
Case 1 of 6: If [[ [[ ,= 0 and [[ [[ ,= 0. Then
= ( )
T T
+ ( )
T
(162)
=
1
[[ [[
T

1
[[ [[
T
+
[[ [[ [[ [[
T
(163)
Case 2 of 6: If [[ [[ = 0 and [[ [[ ,= 0 and = 0. Then
= ( )
T T
(164)
=
1
[[ [[
T

1
[[ [[
T
(165)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 18
3.3 Implication on Inverses 3 INVERSES
Case 3 of 6: If [[ [[ = 0 and ,= 0. Then
=
1
T

[[ [[ [[ [[ +[ [
_
[[ [[
+
__
[[ [[
( )
T
+
_
T
(166)
Case 4 of 6: If [[ [[ ,= 0 and [[ [[ = 0 and = 0. Then
= (167)
=
1
[[ [[
T

1
[[ [[
T
(168)
Case 5 of 6: If [[ [[ = 0 and ,= 0. Then
=
1
T

[[ [[ [[ [[ +[ [
_
[[ [[
+
__
[[ [[
+
_
T
(169)
Case 6 of 6: If [[ [[ = 0 and [[ [[ = 0 and = 0. Then
= + (170)
=
1
[[ [[
T

1
[[ [[
T
+
T
[[ [[ [[ [[
T
(171)
3.3 Implication on Inverses
If ( + )

=

+

then

=

(172)
See [25].
Assume to be positive denite and invertible, then
(

+
T
)
T
=
T
(
T
+ )

(173)
See [30].
3.4 Approximations
The following is a Taylor expansion if
n
0 when ,
( + )

= + + (174)
Note the following variant can be useful
( + )

=
1
_
1

1
+
1

1
+
_
(175)
The following approximation is from [22] and holds when large and symmetric
( + )


=

(176)
If is small compared to and then
( + )


=



(177)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 19
3.5 Generalized Inverse 3 INVERSES
3.5 Generalized Inverse
A generalized inverse matrix of the matrix is any matrix

such that (see
[26])

= (178)
The matrix

is not unique.
3.6 Pseudo Inverse
The pseudo inverse (or Moore-Penrose inverse) of a matrix is the matrix
that fulls
I =
II =
III symmetric
IV symmetric
The matrix is unique and does always exist. Note that in case of com-
plex matrices, the symmetric condition is substituted by a condition of being
Hermitian.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 20
3.6 Pseudo Inverse 3 INVERSES
Assume to be the pseudo-inverse of , then (See [3] for some of them)
( ) = (179)
(
T
) = ( )
T
(180)
(
H
) = ( )
H
(181)
(

) = ( )

(182)
( )
H
=
H
(183)
( )
T
,=
T
(184)
( ) = (1 ) (185)
= (
T
)
T
(186)
=
T
(
T
) (187)
(
T
) = (
T
) (188)
(
T
) = (
T
) (189)
= (
H
)
H
(190)
=
H
(
H
) (191)
(
H
) = (
H
) (192)
(
H
) = (
H
) (193)
( ) = ( ) ( ) (194)
(
H
) (0) = [ (
H
) (0) ] (195)
(
H
) (0) = [ (
H
) (0) ] (196)
where C
nm
.
Assume to have full rank, then
( )( ) = (197)
( )( ) = (198)
Tr( ) = rank( ) (See [26]) (199)
Tr( ) = rank( ) (See [26]) (200)
For two matrices it hold that
( ) = ( ) ( ) (201)
( ) = (202)
Assume that has full rank, then
Square rank( ) = =

Broad rank( ) = =
T
(
T
)

Tall rank( ) = = (
T
)
T
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 21
3.6 Pseudo Inverse 3 INVERSES
Assume does not have full rank, i.e. is and rank( ) = min( ).
The pseudo inverse can be constructed from the singular value decomposi-
tion =
T
, by
=
r

r
T
r
(203)
where
r r
, and
r
are the matrices with the degenerated rows and columns
deleted. A dierent way is this: There do always exist two matrices
and of rank , such that = . Using these matrices it holds that
=
T
(
T
)

(
T
)
T
(204)
See [3].
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 22
4 COMPLEX MATRICES
4 Complex Matrices
4.1 Complex Derivatives
In order to dierentiate an expression ( ) with respect to a complex , the
Cauchy-Riemann equations have to be satised ([7]):
( )
=
'( ( ))
'
+
( ( ))
'
(205)
and
( )
=
'( ( ))

+
( ( ))

(206)
or in a more compact form:
( )

=
( )
'
(207)
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 ([24], [6]):
Generalized Complex Derivative:
( )
=
1
2
_
( )
'

( )

_
(208)
Conjugate Complex Derivative
( )

=
1
2
_
( )
'
+
( )

_
(209)
The Generalized Complex Derivative equals the normal derivative, when is an
analytic function. For a non-analytic function such as ( ) =

, the derivative
equals zero. The Conjugate Complex Derivative equals zero, when is an
analytic function. The Conjugate Complex Derivative has e.g been used by [21]
when deriving a complex gradient.
Notice:
( )
,=
( )
'
+
( )

(210)
Complex Gradient Vector: If is a real function of a complex vector ,
then the complex gradient vector is given by ([14, p. 798])
( ) = 2
( )

(211)
=
( )
'
+
( )

Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 23
4.1 Complex Derivatives 4 COMPLEX MATRICES
Complex Gradient Matrix: If is a real function of a complex matrix ,
then the complex gradient matrix is given by ([2])
( ) = 2
( )

(212)
=
( )
'
+
( )

These expressions can be used for gradient descent algorithms.


The chain rule is a little more complicated when the function of a complex
= ( ) is non-analytic. For a non-analytic function, the following chain rule
can be applied ([7])
( )
= +

(213)
= +
_ _


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 ( ), the chain rule can be written the following way:
( )
=
Tr((
g U
U
)
T
)
+
Tr((
g U
U

)
T
)
(214)
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(

)
'
=
Tr(
H
)
'
= (215)
Tr(

)

=
Tr(
H
)

= (216)
Since the two results have the same sign, the conjugate complex derivative (209)
should be used.
Tr( )
'
=
Tr(
T
)
'
= (217)
Tr( )

=
Tr(
T
)

= (218)
Here, the two results have dierent signs, and the generalized complex derivative
(208) should be used. Hereby, it can be seen that (92) holds even if is a
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 24
4.1 Complex Derivatives 4 COMPLEX MATRICES
complex number.
Tr(
H
)
'
= (219)
Tr(
H
)

= (220)
Tr(

)
'
=
T
(221)
Tr(

)

=
T
(222)
Tr(
H
)
'
=
Tr(
H
)
'
= 2' (223)
Tr(
H
)

=
Tr(
H
)

= 2 (224)
By inserting (223) and (224) in (208) and (209), it can be seen that
Tr(
H
)
=

(225)
Tr(
H
)

= (226)
Since the function Tr(
H
) is a real function of the complex matrix , the
complex gradient matrix (212) is given by
Tr(
H
) = 2
Tr(
H
)

= 2 (227)
Here, a calculation example is provided. The objective is to nd the derivative of
det(
H
) with respect to C
mn
. The derivative is found with respect to
the real part and the imaginary part of , by use of (37) and (33), det(
H
)
can be calculated as (see App. B.1.2 for details)
det(
H
)
=
1
2
_
det(
H
)
'

det(
H
)

_
= det(
H
)
_
(
H
)
H
_
T
(228)
and the complex conjugate derivative yields
det(
H
)

=
1
2
_
det(
H
)
'
+
det(
H
)

_
= det(
H
) (
H
)

(229)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 25
4.2 Higher order and non-linear derivatives 4 COMPLEX MATRICES
4.2 Higher order and non-linear derivatives
( )
H
( )
( )
H
( )
=
H H
H H
(230)
= 2
H
H
2
H H H
(
H H
)
(231)
4.3 Inverse of complex sum
Given real matrices nd the inverse of the complex sum + . Form
the auxiliary matrices
= + (232)
= (233)
and nd a value of such that

exists. Then
( + )

= (1 )( + )

(234)
= (1 )(( +

)

( +

)

)(235)
= (1 )( +

)

(

) (236)
= ( +

)

((

) ( +

)) (237)
= ( +

)

(

)
( +

)

( +

) (238)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 26
5 SOLUTIONS AND DECOMPOSITIONS
5 Solutions and Decompositions
5.1 Solutions to linear equations
Assume we have data (
n n
) for = 1 and are seeking the parameters
R such that
i

= i
+ . With a least squares error function, the optimal
values for can be expressed using the notation
= (
N
)
T
= (
N
)
T
= (1 1)
T
R
N
and
xx
=
T
x
=
T
=
T
yx
=
T
y
=
T
as
_ _
=
_
xx x
x
_

_
x,y
y
_
(239)
Assume is and consider the linear system
= (240)
Construct the augmented matrix = [ ] then
Condition Solution
rank( ) = rank( ) = Unique solution
rank( ) = rank( ) Many solutions
rank( ) rank( ) No solutions
Assume is square and invertible, then
= =

(241)
Assume is but of rank . In that case, the system = is solved
by
=
where is the pseudo-inverse of the rank-decient matrix, constructed as
described in section 3.6.3.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 27
5.1 Solutions to linear equations5 SOLUTIONS AND DECOMPOSITIONS
The equation
= (242)
where is square has exactly one solution if the th element in can be
found as
i
=
det
det
(243)
where equals , but the th column in has been substituted by .
Assume to be , (tall) and rank( ) = , then
= = (
T
)
T
= (244)
that is if there exists a solution at all! If there is no solution the following
can be useful:
=
min
= (245)
Now
min
is the vector which minimizes [[ [[ , i.e. the vector which is
least wrong. The matrix is the pseudo-inverse of . See [3].
Assume is and (broad) and rank( ) = .
=
min
=
T
(
T
)

(246)
The equation have many solutions . But
min
is the solution which minimizes
[[ [[ and also the solution with the smallest norm [[ [[ . The same holds
for a matrix version: Assume is , is and is , then
=
min
= (247)
The equation have many solutions . But
min
is the solution which minimizes
[[ [[ and also the solution with the smallest norm [[ [[ . See [3].
Similar but dierent: Assume is square and the matrices
are , where , then if has maximal rank
=
min
=
T
(
T
)

(248)
where
min
denotes the matrix which is optimal in a least square sense. An
interpretation is that is the linear approximation which maps the columns
vectors of into the columns vectors of .
= = (249)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 28
5.2 Eigenvalues and Eigenvectors5 SOLUTIONS AND DECOMPOSITIONS
If is symmetric, then
T
= = (250)
+ = (251)
vec( ) = ( +
T
)

vec( ) (252)
Sec 10.2.1 and 10.2.2 for details on the Kronecker product and the vec op-
erator.

n
n n
= (253)
vec( ) =
_
n
T
n

n
_

vec( ) (254)
See Sec 10.2.1 and 10.2.2 for details on the Kronecker product and the vec
operator.
5.2 Eigenvalues and Eigenvectors
The eigenvectors and eigenvalues are the ones satisfying
i
=
i i
(255)
= ( )
ij
=
ij i
(256)
where the columns of are the vectors
i
Assume that R
nm
and R
mn
,
eig( ) = eig( ) (257)
is At most min( ) distinct
i
(258)
rank( ) = At most non-zero
i
(259)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 29
5.3 Singular Value Decomposition 5 SOLUTIONS AND DECOMPOSITIONS
Assume is symmetric, then
T
= (i.e. is orthogonal) (260)
i
R (i.e.
i
is real) (261)
Tr(
p
) =

i
p
i
(262)
eig( + ) = 1 +
i
(263)
eig( ) =
i
(264)
eig(

) =

i
(265)
For a symmetric, positive matrix ,
eig(
T
) = eig(
T
) = eig( ) eig( ) (266)
The characteristic polynomial for the matrix is
0 = det( ) (267)
=
n

n
+
n
+ (1)
n
n
(268)
Note that the coecients
j
for = 1 are the invariants under rotation
of . Thus,
j
is the sum of the determinants of all the sub-matrices of taken
rows and columns at a time. That is, is the trace of , and is the sum
of the determinants of the ( 1) 2 sub-matrices that can be formed from
by deleting all but two rows and columns, and so on see [17].
5.3 Singular Value Decomposition
Any matrix can be written as
=
T
(269)
where
= eigenvectors of
T

=
_
diag(eig(
T
))
= eigenvectors of
T

(270)
Assume to be and symmetric. Then
_
=
_ _ _
T

(271)
where is diagonal with the eigenvalues of , and is orthogonal and the
eigenvectors of .
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 30
5.3 Singular Value Decomposition 5 SOLUTIONS AND DECOMPOSITIONS
Assume R
nn
. Then
_
=
_ _ _
T

(272)
where is diagonal with the square root of the eigenvalues of
T
, is the
eigenvectors of
T
and
T
is the eigenvectors of
T
.
Assume

T

= then we can expand the SVD of into


_
=
_

_

_ _
T
T

_
(273)
where the SVD of is =
T
.
Assume is , is , is ,
T
is
_
=
_ _ _
T

(274)
where is diagonal with the square root of the eigenvalues of
T
, is the
eigenvectors of
T
and
T
is the eigenvectors of
T
.
Assume is , is , is ,
T
is
_
=
_
_
_
_
_
_
_
T
_
_
(275)
Assume is , is , is ,
T
is
_
=
_ _
_
_
T
_
_
(276)
where is diagonal with the square root of the eigenvalues of
T
, is the
eigenvectors of
T
and
T
is the eigenvectors of
T
.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 31
5.4 Triangular Decomposition 5 SOLUTIONS AND DECOMPOSITIONS
5.4 Triangular Decomposition
5.5 LU decomposition
Assume is a square matrix with non-zero leading principal minors, then
= (277)
where is a unique unit lower triangular matrix and is a unique upper
triangular matrix.
Assume is a symmetric positive denite square matrix, then
=
T
=
T
(278)
where is a unique upper triangular matrix and is a unique lower triangular
matrix.
5.6 LDM decomposition
Assume is a square matrix with non-zero leading principal minors , then
=
T
(279)
where are unique unit lower triangular matrices and is a unique diagonal
matrix.
5.7 LDL decompositions
The LDL decomposition are special cases of the LDM decomposition. Assume
is a non-singular symmetric denite square matrix, then
=
T
=
T
(280)
where is a unit lower triangular matrix and is a diagonal matrix. If is
also positive denite, then has strictly positive diagonal entries.
1
If the matrix that corresponds to a principal minor is a quadratic upper-left part of the
larger matrix (i.e., it consists of matrix elements in rows and columns from 1 to k), then the
principal minor is called a leading principal minor. For an n times n square matrix, there are
n leading principal minors. [31]
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 32
6 STATISTICS AND PROBABILITY
6 Statistics and Probability
6.1 Denition of Moments
Assume R
n
is a random variable
The vector of means, , is dened by
( )
i
=
i
) (281)
The matrix of covariance is dened by
( )
ij
= (
i

i
))(
j

j
))) (282)
or alternatively as
= ( )( )
T
) (283)
The matrix of third centralized moments in some contexts referred to as
coskewness is dened using the notation
ijk
= (
i

i
))(
j

j
))(
k

k
))) (284)
as
=
_
n
_
(285)
where : denotes all elements within the given index. can alternatively be
expressed as
= ( )( )
T
( )
T
) (286)
The matrix of fourth centralized moments in some contexts referred to as
cokurtosis is dened using the notation
ijkl
= (
i

i
))(
j

j
))(
k

k
))(
l

l
))) (287)
as
=
_
n
[
n
[ [
n n nn
_
(288)
or alternatively as
= ( )( )
T
( )
T
( )
T
) (289)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 33
6.2 Expectation of Linear Combinations 6 STATISTICS AND PROBABILITY
6.2 Expectation of Linear Combinations
Assume and to be a matrix and a vector of random variables. Then (see
See [26])
[ + ] = [ ] + (290)
Var[ ] = Var[ ]
T
(291)
Cov[ ] = Cov[ ]
T
(292)
Assume to be a stochastic vector with mean , then (see [7])
[ + ] = + (293)
[ ] = (294)
[ + ] = + (295)
Assume is symmetric, = [ ] and = Var[ ]. Assume also that all
coordinates
i
are independent, have the same central moments
and denote = diag( ). Then (See [26])
[
T
] = Tr( ) +
T
(296)
Var[
T
] = 2 Tr( ) + 4
T
+ 4
T
+ ( 3 )
T
(297)
Also, assume to be a stochastic vector with mean , and covariance . Then
(see [7])
[( + )( + )
T
] =
T
+ ( + )( + )
T
(298)
[
T
] = +
T
(299)
[
T
] = ( +
T
) (300)
[
T T
] =
T
( +
T
) (301)
[( )( )
T
] = ( +
T
)
T
(302)
[( + )( + )
T
] = + ( + )( + )
T
(303)
[( + )
T
( + )] = Tr(
T
) + ( + )
T
( + ) (304)
[
T
] = Tr( ) +
T
(305)
[
T
] = Tr( ) +
T
(306)
[( )
T
( )] = Tr(
T
) + ( )
T
( ) (307)
[( + )
T
( + )] = Tr( ) + ( + )
T
( + ) (308)
See [7].
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 34
6.3 Weighted Scalar Variable 6 STATISTICS AND PROBABILITY
Assume to be a stochastic vector with independent coordinates, mean ,
covariance and central moments = [( ) ]. Then (see [7])
[( + )( + )
T
( + )] = diag(
T
)
+Tr(
T
)( + )
+
T
( + )
+(
T
+ ( + )( + )
T
)( + )
[
T
] = + 2 + (Tr( ) +
T
)
[( + )( + )
T
( + )] = diag(
T
)
+[2
T
+ ( + )( + )
T
]( + )
+Tr(
T
)( + )
[( + )
T
( + )( + )
T
] = ( + )
T
(
T
+ ( + )( + )
T
)
+(
T
+ ( + )( + )
T
) ( + )
T
+
T
( + )(
T
( + )( + )
T
)
6.3 Weighted Scalar Variable
Assume R
n
is a random variable, R
n
is a vector of constants and
is the linear combination =
T
. Assume further that
denotes the mean, covariance, and central third and fourth moment matrix of
the variable . Then it holds that
) =
T
(309)
( )) ) =
T
(310)
( )) ) =
T
(311)
( )) ) =
T
(312)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 35
7 MULTIVARIATE DISTRIBUTIONS
7 Multivariate Distributions
7.1 Cauchy
The density function for a Cauchy distributed vector R
P
, is given by
( [ ) =
P/
(
P
)
(1 2)
det( )
/
_
1 + ( )
T

( )

P /
(313)
where is the location, is positive denite, and denotes the gamma func-
tion. The Cauchy distribution is a special case of the Student-t distribution.
7.2 Dirichlet
The Dirichlet distribution is a kind of inverse distribution compared to the
multinomial distribution on the bounded continuous variate = [
P
]
[16, p. 44]
( [) =

P
p
p
_

P
p
(
p
)
P

p
p
p
7.3 Normal
The normal distribution is also known as a Gaussian distribution. See sec. 8.
7.4 Normal-Inverse Gamma
7.5 Gaussian
See sec. 8.
7.6 Multinomial
If the vector contains counts, i.e. ( )
i
0 1 2 , then the discrete multino-
mial disitrbution for is given by
( [ ) =
!
!
d
!
d

i
ni
i
d

i
i
= (314)
where
i
are probabilities, i.e. 0
i
1 and

i
i
= 1.
7.7 Students t
The density of a Student-t distributed vector R
P
, is given by
( [ ) = ( )
P/
(
P
)
( 2)
det( )
/
_
1 +

( )
T

( )

P /
(315)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 36
7.8 Wishart 7 MULTIVARIATE DISTRIBUTIONS
where is the location, the scale matrix is symmetric, positive denite,
is the degrees of freedom, and denotes the gamma function. For = 1, the
Student-t distribution becomes the Cauchy distribution (see sec 7.1).
E( ) = 1 (316)
cov( ) =
2
2 (317)
The notion mode meaning the position of the most probable value
mode( ) = (318)
If instead of a vector R
P
one has a matrix R
PN
, then the Student-t
distribution for is
( [ ) =
NP/
P

p
[( + + 1) 2]
[( + 1) 2]

det( )
/
det( )
N/

det
_

+ ( )

( )
T

P /
(319)
where is the location, is the rescaling matrix, is positive denite, is
the degrees of freedom, and denotes the gamma function.
7.8 Wishart
The central Wishart distribution for R
PP
, is positive denite, where
can be regarded as a degree of freedom parameter [16, equation 3.8.1] [8,
section 2.5],[11]
( [ ) =
1
2
mP/ P P /

P
p
[ ( + 1 )]

det( )
m/
det( )
mP /

exp
_

1
2
Tr(

)
_
(320)
( ) = (321)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 37
7.9 Wishart, Inverse 7 MULTIVARIATE DISTRIBUTIONS
7.9 Wishart, Inverse
The (normal) Inverse Wishart distribution for R
PP
, is positive de-
nite, where can be regarded as a degree of freedom parameter [11]
( [ ) =
1
2
mP/ P P /

P
p
[ ( + 1 )]

det( )
m/
det( )
mP /

exp
_

1
2
Tr(

)
_
(322)
( ) =
1
1
(323)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 38
8 GAUSSIANS
8 Gaussians
8.1 Basics
The density of ^( ) is
( ) =
1
_
det(2 )
exp
_

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

1
2
( )
T
( )
_
=
_
det(2 )
_
exp
_

1
2
T
+
T
_
=
_
det(2 ) exp
_
1
2
T
_
_
exp
_

1
2
T
+
T
_
=
_
det(2

) exp
_
1
2
T T
_
If = [
n
] and = [
n
], then
_
exp
_

1
2
Tr(
T
) + Tr(
T
)
_
=
_
det(2

)
n
exp
_
1
2
Tr(
T
)
_
The derivatives of the density are
( )
= ( )

( ) (325)
T
= ( )
_

( )( )
T


_
(326)
Assume ^
x
( ) where
=
_
a
b
_
=
_

a

b
_
=
_
a c
T
c b
_
(327)
then
(
a
) = ^
xa
(
a a
) (328)
(
b
) = ^
x
b
(
b b
) (329)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 39
8.1 Basics 8 GAUSSIANS
Assume ^
x
( ) where
=
_
a
b
_
=
_

a

b
_
=
_
a c
T
c b
_
(330)
then
(
a
[
b
) = ^
xa
(
a

a
)
_

a
=
a
+
c

b
(
b

b
)

a
=
a

b
T
c
(331)
(
b
[
a
) = ^
x
b
(
b

b
)
_

b
=
b
+
T
c

a
(
a

a
)

b
=
b

T
c

a c
(332)
Note, that the covariance matrices are the Schur complement of the block ma-
trix, see 9.1.5 for details.
Assume ^(
x x
) and ^(
y y
) then
+ + ^(
x
+
y
+
x
T
+
y
T
) (333)
^
Ax
[ ] =
_
det(2 (
T
)

)
_
det(2 )
^
x
[

(
T
)

] (334)
If is symmetric, then

1
2
T
+
T
=
1
2
(

)
T
(

) +
1
2
T

1
2
Tr(
T
) + Tr(
T
) =
1
2
Tr[(

)
T
(

)] +
1
2
Tr(
T
)
In vector formulation (assuming are symmetric)

1
2
( )
T
( ) (335)

1
2
( )
T
( ) (336)
=
1
2
(
c
)
T
c
(
c
) + (337)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 40
8.2 Moments 8 GAUSSIANS

c
=

+

(338)
c
= (

+

)

(

+

) (339)
=
1
2
(
T
+
T
)(

+

)

(

+

)(340)

1
2
_
T
+
T
_
(341)
In a trace formulation (assuming are symmetric)

1
2
Tr(( )
T
( )) (342)

1
2
Tr(( )
T
( )) (343)
=
1
2
Tr[(
c
)
T
c
(
c
)] + (344)

c
=

+

(345)
c
= (

+

)

(

+

) (346)
=
1
2
Tr
_
(

+

)
T
(

+

)

(

+

)
_

1
2
Tr(
T
+
T
) (347)
Let ^
x
( ) denote a density of , then
^
x
( ) ^
x
( ) =
c
^
x
(
c c
) (348)
c
= ^
m1
( ( + ))
=
1
_
det(2 ( + ))
exp
_

1
2
( )
T
( + )

( )
_
c
= (

+

)

(

+

)
c
= (

+

)

but note that the product is not normalized as a density of .


8.2 Moments
First and second moments. Assume ^( )
( ) = (349)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 41
8.2 Moments 8 GAUSSIANS
Cov( ) = Var( ) = = (
T
) ( ) (
T
) = (
T
)
T
(350)
As for any other distribution is holds for gaussians that
[ ] = [ ] (351)
Var[ ] = Var[ ]
T
(352)
Cov[ ] = Cov[ ]
T
(353)
Mean and variance of square forms: Assume ^( )
(
T
) = +
T
(354)
[
T
] = Tr( ) +
T
(355)
Var(
T
) = Tr[ ( +
T
) ] +
+
T
( +
T
) ( +
T
) (356)
[(

)
T
(

)] = (

)
T
(

) + Tr( ) (357)
If = and is symmetric, then
Var(
T
) = 2 Tr( ) + 4
T
(358)
Assume ^( ) and and to be symmetric, then
Cov(
T T
) = 2 Tr( ) (359)
[
T T
] =
T
( +
T
) + ( +
T
)
T
+
T
(
T
) (360)
[
T T
] = 2( +
T
) +
T
(
T
)
+Tr( )( +
T
)
[
T T
] = ( +
T
)( +
T
)( +
T
)
+
T
(
T
) + Tr[ ]( +
T
)
[
T T
] = 2Tr( ) + 4
T
+ (Tr( ) +
T
)
[
T T
] = Tr[ ( +
T
) ] +
T
( +
T
) ( +
T
)
+(Tr( ) +
T
)(Tr( ) +
T
)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 42
8.3 Miscellaneous 8 GAUSSIANS
[
T T T T
]
= (
T
( +
T
) )(
T
( +
T
) )
+(
T
( +
T
) )(
T
( +
T
) )
+(
T
( +
T
) )(
T
( +
T
) ) 2
T T T T
[( + )( + )
T
( + )( + )
T
]
= [
T
+ ( + )( + )
T
][
T
+ ( + )( + )
T
]
+[
T
+ ( + )( + )
T
][
T
+ ( + )( + )
T
]
+( + )
T
( + )[
T
( + )( + )
T
]
+Tr(
T
)[
T
+ ( + )( + )
T
]
[( + )
T
( + )( + )
T
( + )]
= Tr[ (
T
+
T
)
T
]
+[( + )
T
+ ( + )
T
] [
T
( + ) +
T
( + )]
+[Tr(
T
) + ( + )
T
( + )][Tr(
T
) + ( + )
T
( + )]
See [7].
[ ] =

k
k k
(361)
Cov( ) =

k k
(
k
+
k
T
k

k
T
k
) (362)
8.3 Miscellaneous
Assume ^( ) then
=
/
( ) ^( ) (363)
Conversely having ^( ) one can generate data ^( ) by setting
=
/
+ ^( ) (364)
Note that
/
means the matrix which fulls
/ /
= , and that it exists
and is unique since is positive denite.
Assume ^( ) and to be dimensional, then
= ( )
T
( )
n
(365)
where
n
denotes the Chi square distribution with degrees of freedom.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 43
8.4 Mixture of Gaussians 8 GAUSSIANS
Entropy of a -dimensional gaussian
( ) =
_
^( ) ln^( ) = ln
_
det(2 ) +
2
(366)
8.4 Mixture of Gaussians
The variable is distributed as a mixture of gaussians if it has the density
( ) =
K

k
k
1
_
det(2
k
)
exp
_

1
2
(
k
)
T
k
(
k
)
_
(367)
where
k
sum to 1 and the
k
all are positive denite.
Dening ( ) =

k
k
^
s
(
k k
) one get
ln ( )
j
=
j
^
s
(
j j
)

k
k
^
s
(
k k
)
j
ln[
j
^
s
(
j j
)] (368)
=
j
^
s
(
j j
)

k
k
^
s
(
k k
)
1
j
(369)
ln ( )

j
=
j
^
s
(
j j
)

k
k
^
s
(
k k
)
j
ln[
j
^
s
(
j j
)] (370)
=
j
^
s
(
j j
)

k
k
^
s
(
k k
)
_

j
(
j
)

(371)
ln ( )
j
=
j
^
s
(
j j
)

k
k
^
s
(
k k
)
j
ln[
j
^
s
(
j j
)] (372)
=
j
^
s
(
j j
)

k
k
^
s
(
k k
)
1
2
_


j
+

j
(
j
)(
j
)
T
j

(373)
But
k
and
k
needs to be constrained.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 44
9 SPECIAL MATRICES
9 Special Matrices
9.1 Block matrices
Let
ij
denote the th block of .
Assuming the dimensions of the blocks matches we have
_ _ _ _
=
_
+ +
+ +
_
The determinant can be expressed as by the use of
=

(374)
=

(375)
as
det
__ __
= det( ) det( ) = det( ) det( )
The inverse can be expressed as by the use of
=

(376)
=

(377)
as
_ _

=
_



_
=
_

+



+

_
For block diagonal matrices we have
_ _

=
_
( )

( )

_
(378)
det
__ __
= det( ) det( ) (379)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 45
9.2 Discrete Fourier Transform Matrix, The 9 SPECIAL MATRICES
The Schur complement of the matrix
_ _
is the matrix


that is, what is denoted above. Using the Schur complement, one can rewrite
the inverse of a block matrix
_ _

=
_


_ _
(

)

_ _


_
The Schur complement is useful when solving linear systems of the form
_ _ _ _
=
_ _
which has the following equation for
(

) =

When the appropriate inverses exists, this can be solved for which can then
be inserted in the equation for to solve for .
9.2 Discrete Fourier Transform Matrix, The
The DFT matrix is an symmetric matrix
N
, where the th element
is given by
kn
N
=
j2kn
N
(380)
Thus the discrete Fourier transform (DFT) can be expressed as
( ) =
N

n
( )
kn
N
(381)
Likewise the inverse discrete Fourier transform (IDFT) can be expressed as
( ) =
1
N

k
( )
kn
N
(382)
The DFT of the vector = [ (0) (1) ( 1)]
T
can be written in matrix
form as
=
N
(383)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 46
9.3 Hermitian Matrices and skew-Hermitian 9 SPECIAL MATRICES
where = [ (0) (1) ( 1)]
T
. The IDFT is similarly given as
=

N
(384)
Some properties of
N
exist:

N
=
1

N
(385)
N

N
= (386)

N
=
H
N
(387)
If
N
=
j2
N
, then [23]
m N/
N
=
m
N
(388)
Notice, the DFT matrix is a Vandermonde Matrix.
The following important relation between the circulant matrix and the dis-
crete Fourier transform (DFT) exists
C
=

N
( (
N
))
N
(389)
where = [
n
]
T
is the rst row of
C
.
9.3 Hermitian Matrices and skew-Hermitian
A matrix C
mn
is called Hermitian if
H
=
For real valued matrices, Hermitian and symmetric matrices are equivalent.
is Hermitian
H
R C
n
(390)
is Hermitian eig( ) R (391)
Note that
= +
where are hermitian, then
=
+
H
2
=

H
2
A matrix is called skew-hermitian if
=
H
For real valued matrices, skew-Hermitian and skew-symmetric matrices are
equivalent.
Hermitian is skew-hermitian (392)
skew-Hermitian
H
=
H H
(393)
skew-Hermitian eig( ) = R (394)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 47
9.4 Idempotent Matrices 9 SPECIAL MATRICES
9.4 Idempotent Matrices
A matrix is idempotent if
=
Idempotent matrices and , have the following properties
n
= for = 1 2 3 (395)
is idempotent (396)
H
is idempotent (397)

H
is idempotent (398)
If = is idempotent (399)
rank( ) = Tr( ) (400)
( ) = (401)
( ) = (402)
= (403)
( + ) = ( ) ( ) + ( + ) (404)
Note that is not necessarily idempotent.
A matrix is nilpotent if
=
A nilpotent matrix has the following property:
( + ) = ( ) +

( ) (405)
A matrix is unipotent if
=
A unipotent matrix has the following property:
( + ) = [( + ) ( + ) + ( ) ( )] 2 (406)
9.5 Orthogonal matrices
If a square matrix is orthogonal, if and only if,
T
=
T
=
and then has the following properties
Its eigenvalues are placed on the unit circle.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 48
9.5 Orthogonal matrices 9 SPECIAL MATRICES
Its eigenvectors are unitary, i.e. have length one.
The inverse of an orthogonal matrix is orthogonal too.
Basic properties for the orthogonal matrix

=
T
T
=
T
=
T
=
det( ) = 1
A matrix which simultaneously is orthogonal and symmetric is called an
ortho-sym matrix [20]. Hereby
T
= (407)
=
T
(408)
The powers of an ortho-sym matrix are given by the following rule
k
=
1 + (1)
k
2
+
1 + (1)
k
2
(409)
=
1 + cos( )
2
+
1 cos( )
2
(410)
A matrix which simultaneously is orthogonal and antisymmetric is called an
ortho-skew matrix [20]. Hereby
H

= (411)

=
H

(412)
The powers of an ortho-skew matrix are given by the following rule
k

=
k
+ ( )
k
2

k
( )
k
2

(413)
= cos(
2
) + sin(
2
)

(414)
A square matrix can always be written as a sum of a symmetric and an
antisymmetric matrix

= +

(415)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 49
9.6 Positive Denite and Semi-denite Matrices 9 SPECIAL MATRICES
9.6 Positive Denite and Semi-denite Matrices
A matrix is positive denite if and only if
T
,= (416)
A matrix is positive semi-denite if and only if
T
(417)
Note that if is positive denite, then is also positive semi-denite.
The following holds with respect to the eigenvalues:
pos. def. eig(
A A
H
) 0
pos. semi-def. eig(
A A
H
) 0
(418)
The following holds with respect to the trace:
pos. def. Tr( ) 0
pos. semi-def. Tr( ) 0
(419)
If is positive denite, then is invertible and

is also positive denite.
If is positive denite, then
ii
0
The matrix is positive semi-denite of rank there exists a matrix of
rank such that =
T
The matrix is positive denite there exists an invertible matrix such
that =
T
Assume is an positive semi-denite, then there exists an matrix
of rank such that
T
= .
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 50
9.7 Singleentry Matrix, The 9 SPECIAL MATRICES
Assume is positive semi-denite, then
T
= =
Assume is positive denite, then rank(
T
) = rank( )
If is positive denite and is of rank , then
T
is positive
denite.
If is , where and rank( ) = , then
T
is positive denite.
If is positive denite and is symmetric, then is positive denite for
suciently small .
If is a positive denite or semi-denite matrix, then
det( )

i
ii
See [15, pp.477]
Assume that =
T
and =
T
are semi positive denite matrices, it
then holds that
=
T
where the columns of are constructed as follows:
i j N
A
=
i

j
, for
= 1 2
A
and = 1 2
B
. The result is unpublished, but reported by
Pavel Sakov and Craig Bishop.
9.7 Singleentry Matrix, The
The single-entry matrix
ij
R
nn
is dened as the matrix which is zero
everywhere except in the entry ( ) in which it is 1. In a 4 4 example one
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 51
9.7 Singleentry Matrix, The 9 SPECIAL MATRICES
might have
=
_

_
0 0 0 0
0 0 1 0
0 0 0 0
0 0 0 0
_

_
(420)
The single-entry matrix is very useful when working with derivatives of expres-
sions involving matrices.
Assume to be and
ij
to be
ij
=
_
i

(421)
i.e. an matrix of zeros with the i.th column of in place of the j.th
column. Assume to be and
ij
to be
ij
=
_

_
.
.
.
j
.
.
.
_

_
(422)
i.e. an matrix of zeros with the j.th row of in the placed of the i.th
row.
ki jl
= (
i
T
j
)
kl
= (
ij
)
kl
(423)
ik lj
= (
T
i
T
j
T
)
kl
= (
T ij T
)
kl
(424)
ik jl
= (
T
i
T
j
)
kl
= (
T ij
)
kl
(425)
ki lj
= (
i
T
j
T
)
kl
= (
ij T
)
kl
(426)
If =
ij ij
=
ij
(
ij
)
T
(
ij
)
T
=
ij
ij
(
ij
)
T
=
ij
(
ij
)
T ij
=
ij
If ,=
ij ij
= (
ij
)
T
(
ij
)
T
=
ij
(
ij
)
T
=
ii
(
ij
)
T ij
=
jj
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 52
9.8 Symmetric, Skew-symmetric/Antisymmetric 9 SPECIAL MATRICES
Assume is and is , then
Tr(
ij
) = Tr(
ij
) = (
T
)
ij
(427)
Assume is , is and is , then
Tr(
ij
) = (
T T
)
ij
(428)
Tr(
ji
) = ( )
ij
(429)
Tr(
ij ij
) = diag(
T T
)
ij
(430)
Assume is ,
ij
is is , then
T ij
= (
T T T
)
ij
(431)
T ij ij
= diag(
T T T
)
ij
(432)
The structure matrix is dened by
ij
=
ij
(433)
If has no special structure then
ij
=
ij
(434)
If is symmetric then
ij
=
ij
+
ji

ij ij
(435)
9.8 Symmetric, Skew-symmetric/Antisymmetric
The matrix is said to be symmetric if
=
T
(436)
Symmetric matrices have many important properties, e.g. that their eigenvalues
are real and eigenvectors orthogonal.
The antisymmetric matrix is also known as the skew symmetric matrix. It has
the following property from which it is dened
=
T
(437)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 53
9.9 Toeplitz Matrices 9 SPECIAL MATRICES
Hereby, it can be seen that the antisymmetric matrices always have a zero
diagonal. The antisymmetric matrices also have the following properties.
det(
T
) = det( ) = (1)
n
det( ) (438)
det( ) = det( ) = 0 if is odd (439)
The eigenvalues of an antisymmetric matrix are placed on the imaginary axis
and the eigenvectors are unitary.
A square matrix can always be written as a sum of a symmetric and an
antisymmetric matrix

= +

(440)
Such a decomposition could e.g. be
=
+
T
2
+

T
2
= +

(441)
9.9 Toeplitz Matrices
A Toeplitz matrix is a matrix where the elements of each diagonal is the
same. In the square case, it has the following structure:
=
_

_

n
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
n

_

_
=
_

_

n

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
n


_

_
(442)
A Toeplitz matrix is persymmetric. If a matrix is persymmetric (or orthosym-
metric), it means that the matrix is symmetric about its northeast-southwest
diagonal (anti-diagonal) [12]. Persymmetric matrices is a larger class of matri-
ces, since a persymmetric matrix not necessarily has a Toeplitz structure. There
are some special cases of Toeplitz matrices. The symmetric Toeplitz matrix is
given by:
=
_

_

n
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
n

_

_
(443)
The circular Toeplitz matrix:
C
=
_

_

n
n
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

n
_

_
(444)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 54
9.10 Transition matrices 9 SPECIAL MATRICES
The upper triangular Toeplitz matrix:
U
=
_

_

n
0
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
0 0
_

_
(445)
and the lower triangular Toeplitz matrix:
L
=
_

_
0 0

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 0
n


_

_
(446)
The Toeplitz matrix has some computational advantages. The addition of two
Toeplitz matrices can be done with O( ) ops, multiplication of two Toeplitz
matrices can be done in O( ln ) ops. Toeplitz equation systems can be solved
in O( ) ops. The inverse of a positive denite Toeplitz matrix can be found
in O( ) ops 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
A square matrix is a transition matrix, also known as stochastic matrix or
probability matrix, if
0 ( )
ij
1

j
( )
ij
= 1
The transition matrix usually describes the probability of moving from state
to in one step and is closely related to markov processes. Transition matrices
have the following properties
Prob[ in 1 step] = ( )
ij
(447)
Prob[ in 2 steps] = ( )
ij
(448)
Prob[ in steps] = (
k
)
ij
(449)
If all rows are identical
n
= (450)
= is called invariant (451)
where is a so-called stationary probability vector, i.e., 0
i
1 and

i
i
=
1.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 55
9.11 Units, Permutation and Shift 9 SPECIAL MATRICES
9.11 Units, Permutation and Shift
Let
i
R
n
be the th unit vector, i.e. the vector which is zero in all entries
except the th at which it is 1.
row of =
T
i
(452)
column of =
j
(453)
Let be some permutation matrix, e.g.
=
_
_
0 1 0
1 0 0
0 0 1
_
_
=
_
=
_
_
T
T
T
_
_
(454)
For permutation matrices it holds that
T
= (455)
and that
=
_
=
_
_
T
T
T
_
_
(456)
That is, the rst is a matrix which has columns of but in permuted sequence
and the second is a matrix which has the rows of but in the permuted se-
quence.
Let denote the lag (or translation or shift) operator dened on a 4 4
example by
=
_

_
0 0 0 0
1 0 0 0
0 1 0 0
0 0 1 0
_

_
(457)
i.e. a matrix of zeros with one on the sub-diagonal, ( )
ij
=
i,j
. With some
signal
t
for = 1 , the n.th power of the lag operator shifts the indices,
i.e.
(
n
)
t
=
_
0 for = 1
tn
for = + 1
(458)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 56
9.12 Vandermonde Matrices 9 SPECIAL MATRICES
A related but slightly dierent matrix is the recurrent shifted operator dened
on a 4x4 example by

=
_

_
0 0 0 1
1 0 0 0
0 1 0 0
0 0 1 0
_

_
(459)
i.e. a matrix dened by (

)
ij
=
i,j
+
i, j,dim L
. On a signal it has the
eect
(

n
)
t
=
t


= [( ) mod ] + 1 (460)
That is,

is like the shift operator except that it wraps the signal as if it
was periodic and shifted (substituting the zeros with the rear end of the signal).
Note that

is invertible and orthogonal, i.e.

=

T
(461)
9.12 Vandermonde Matrices
A Vandermonde matrix has the form [15]
=
_

_
1
n
1
n
.
.
.
.
.
.
.
.
.
.
.
.
1
n n

n
n
_

_
(462)
The transpose of is also said to a Vandermonde matrix. The determinant is
given by [29]
det =

i>j
(
i

j
) (463)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 57
10 FUNCTIONS AND OPERATORS
10 Functions and Operators
10.1 Functions and Series
(
n
)( )

= + + + +
n
(464)
Consider some scalar function ( ) which takes the vector as an argument.
This we can Taylor expand around
( )

= ( ) + ( )
T
( ) +
1
2
( )
T
( )( ) (465)
where
( ) =
( )

x0
( ) =
( )
T

x0
As for analytical functions in one dimension, one can dene a matrix function
for square matrices by an innite series
( ) =

n
n
n
(466)
assuming the limit exists and is nite. If the coecients
n
fulls

n
n
n
,
then one can prove that the above series exists and is nite, see [1]. Thus for
any analytical function ( ) there exists a corresponding matrix function ( )
constructed by the Taylor expansion. Using this one can prove the following
results:
1) A matrix is a zero of its own characteristic polynomium [1]:
( ) = det( ) =

n
n
n
( ) = (467)
2) If is square it holds that [1]
=

( ) = ( )

(468)
3) A useful fact when using power series is that
n
for if [ [ 1 (469)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 58
10.2 Kronecker and Vec Operator 10 FUNCTIONS AND OPERATORS
In analogy to the ordinary scalar exponential function, one can dene exponen-
tial and logarithmic matrix functions:
A

n
1
!
n
= + +
1
2
+ (470)
A

n
1
!
(1)
n n
= +
1
2
(471)
tA

n
1
!
( )
n
= + +
1
2
+ (472)
ln( + )

n
(1)
n
n
=
1
2
+
1
3
(473)
Some of the properties of the exponential function are [1]
A B
=
A B
if = (474)
(
A
)

=
A
(475)
tA
=
tA
=
tA
R (476)
Tr(
tA
) = Tr(
tA
) (477)
det(
A
) =
A
(478)
sin( )

n
(1)
n n
(2 + 1)!
=
1
3!
+
1
5!
(479)
cos( )

n
(1)
n n
(2 )!
=
1
2!
+
1
4!
(480)
10.2 Kronecker and Vec Operator
The Kronecker product of an matrix and an matrix , is an
matrix, dened as
=
_

_
n
n
.
.
.
.
.
.
m m mn
_

_
(481)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 59
10.2 Kronecker and Vec Operator 10 FUNCTIONS AND OPERATORS
The Kronecker product has the following properties (see [19])
( + ) = + (482)
,= in general (483)
( ) = ( ) (484)
(
A

B
) =
A B
( ) (485)
( )
T
=
T

T
(486)
( )( ) = (487)
( )

=



(488)
( ) = (489)
rank( ) = rank( )rank( ) (490)
Tr( ) = Tr( )Tr( ) = Tr(
A

B
) (491)
det( ) = det( )
rank B
det( )
rank A
(492)
eig( ) = eig( ) if are square (493)
eig( ) = eig( )eig( )
T
(494)
if are symmetric and square
eig( ) = eig( ) eig( ) (495)
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
.
The vec-operator applied on a matrix stacks the columns into a vector, i.e.
for a 2 2 matrix
=
_ _
vec( ) =
_

_
_

_
Properties of the vec-operator include (see [19])
vec( ) = (
T
)vec( ) (496)
Tr(
T
) = vec( )
T
vec( ) (497)
vec( + ) = vec( ) + vec( ) (498)
vec( ) = vec( ) (499)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 60
10.3 Vector Norms 10 FUNCTIONS AND OPERATORS
10.3 Vector Norms
[[ [[ =

i
[
i
[ (500)
[[ [[ =
H
(501)
[[ [[
p
=
_

i
[
i
[
p
_
/p
(502)
[[ [[

= max
i
[
i
[ (503)
Further reading in e.g. [12, p. 52]
10.4 Matrix Norms
A matrix norm is a mapping which fulls
[[ [[ 0 (504)
[[ [[ = 0 = (505)
[[ [[ = [ [[[ [[ R (506)
[[ + [[ [[ [[ +[[ [[ (507)
An induced norm is a matrix norm induced by a vector norm by the following
[[ [[ = sup[[ [[ [ [[ [[ = 1 (508)
where [[ [[ ont the left side is the induced matrix norm, while [[ [[ on the right
side denotes the vector norm. For induced norms it holds that
[[ [[ = 1 (509)
[[ [[ [[ [[ [[ [[ for all (510)
[[ [[ [[ [[ [[ [[ for all (511)
[[ [[ = max
j

i
[
ij
[ (512)
[[ [[ =
_
max eig(
H
) (513)
[[ [[
p
= ( max
||x||p
[[ [[
p
)
/p
(514)
[[ [[

= max
i

j
[
ij
[ (515)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 61
10.5 Rank 10 FUNCTIONS AND OPERATORS
[[ [[ =

ij
[
ij
[ =
_
Tr(
H
) (Frobenius) (516)
[[ [[ = max
ij
[
ij
[ (517)
[[ [[ = [[sing( )[[ (Ky Fan) (518)
where sing( ) is the vector of singular values of the matrix .
E. H. Rasmussen has in yet unpublished material derived and collected the
following inequalities. They are collected in a table as below, assuming is an
, and = rank( )
[[ [[ [[ [[ [[ [[

[[ [[ [[ [[ [[ [[
[[ [[ 1 1 1 1 1
[[ [[

[[ [[


[[ [[

1 1
[[ [[


1
[[ [[

which are to be read as, e.g.
[[ [[

[[ [[

(519)
The 2-norm of equals
_
(max(eig(
T
))) [12, p.57]. For a symmetric, pos-
itive denite matrix, this reduces to max(eig( )) The condition number based
on the 2-norm thus reduces to
| | |

| = max(eig( )) max(eig(

)) =
max(eig( ))
min(eig( ))
(520)
10.5 Rank
If is and is , then
rank( ) + rank( ) rank( ) minrank( ) rank( ) (521)
10.6 Integral Involving Dirac Delta Functions
Assuming to be square, then
_
( ) ( ) =
1
det( )
(

) (522)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 62
10.7 Miscellaneous 10 FUNCTIONS AND OPERATORS
Assuming to be underdetermined, i.e. tall, then
_
( ) ( ) =
_

A
T
A
( ) if =
0 elsewhere
_
(523)
See [9].
10.7 Miscellaneous
For any it holds that
rank( ) = rank(
T
) = rank(
T
) = rank(
T
) (524)
It holds that
is positive denite invertible, such that =
T
(525)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 63
A ONE-DIMENSIONAL RESULTS
A One-dimensional Results
A.1 Gaussian
( ) =
1

2
exp
_

( )
2
_
(526)
_

(s)
2
2
2
=

2 (527)
_
ax
2
bx c
=
_
exp
_
4
4
_
(528)
_
c2x
2
c1x c0
=
_

exp
_
4
4
_
(529)
( )
= ( )
( )
(530)
ln ( )
=
( )
(531)
( )
= ( )
1
_
( )
1
_
(532)
ln ( )
=
1
_
( )
1
_
(533)
+ + = ( ) +
= =
1
2
=
1
4
+
or
+ + =
1
2
( ) +
=

2
=
1
2
=
4
If the density is expressed by
( ) =
1

2
exp
_

( )
2
_
or ( ) = exp( + ) (534)
then the rst few basic moments are
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 64
A.2 One Dimensional Mixture of Gaussians A ONE-DIMENSIONAL RESULTS
) = =
c1
c2
) = + =

c2
+
_
c1
c2
_
) = 3 + =
c1
c2
2
_
3
c
2
1
c2
_
) = + 6 + 3 =
_
c1
c2
_
+ 6
_
c1
c2
_ _

c2
_
+ 3
_
c2
_
and the central moments are
( )) = 0 = 0
( ) ) = =
_

c2
_
( ) ) = 0 = 0
( ) ) = 3 = 3
_
c2
_
A kind of pseudo-moments (un-normalized integrals) can easily be derived as
_
exp( + )
n
=
n
) =
_

exp
_
4
_

n
) (535)
From the un-centralized moments one can derive other entities like
) ) = =

c2
) ) ) = 2 =
c1
c2
2
) ) = 2 + 4 =
c2
2
_
1 4
c
2
1
c2
_
A.2 One Dimensional Mixture of Gaussians
( ) =
K

k
k
_
2
k
exp
_

1
2
(
k
)
k
_
(536)
An useful fact of MoG, is that

n
) =

k
k

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

k
k
1
_
2
k
exp
_

1
2
(
k
)
k
_
(538)
( ) =

k
k k
exp
_
k
+
k

(539)
as
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 65
A.2 One Dimensional Mixture of Gaussians A ONE-DIMENSIONAL RESULTS
) =

k
k k
=

k
k
_
c
k1
c
k2
_
) =

k
k
(
k
+
k
) =

k
k
_

c
k2
+
_
c
k1
c
k2
_
_
) =

k
k
(3
k
k
+
k
) =

k
k
_
c
k1
c
k2
2
_
3
c
2
k1
c
k2
__
) =

k
k
(
k
+ 6
k k
+ 3
k
) =

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

k
k
k
=

k
k
_

c
k2
_
) = 0 = 0
) =

k
k
3
k
=

k
k
3
_

c
k2
_
From the un-centralized moments one can derive other entities like
) ) =

k,k
k k

_
k
+
k

k k

) ) ) =

k,k
k k

_
3
k
k
+
k
(
k
+
k
)
k

) ) =

k,k
k k

_
k
+ 6
k k
+ 3
k
(
k
+
k
)(
k
+
k
)

Dening ( ) =

k
k
^
s
(
k
k
) we get for a parameter
j
of the j.th compo-
nent
ln ( )
j
=
j
^
s
(
j
j
)

k
k
^
s
(
k
k
)
ln(
j
^
s
(
j
j
))
j
(540)
that is,
ln ( )
j
=
j
^
s
(
j
j
)

k
k
^
s
(
k
k
)
1
j
(541)
ln ( )
j
=
j
^
s
(
j
j
)

k
k
^
s
(
k
k
)
(
j
)
j
(542)
ln ( )
j
=
j
^
s
(
j
j
)

k
k
^
s
(
k
k
)
1
j
_
(
j
)
j
1
_
(543)
Note that
k
must be constrained to be proper ratios. Dening the ratios by
j
=
rj

k
r
k
, we obtain
ln ( )
j
=

l
ln ( )
l
l
j
where
l
j
=
l
(
lj

j
) (544)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 66
B PROOFS AND DETAILS
B Proofs and Details
B.1 Misc Proofs
Essentially we need to calculate
(
n
)
kl
ij
=
ij

u1,...,un1
k,u1 u1,u2 un1,l
=
k,i u1,j u1,u2 un1,l
+
k,u1 u1,i u2,j un1,l
.
.
.
+
k,u1 u1,u2 un1,i l,j
=
n

r
(
r
)
ki
(
n r
)
jl
=
n

r
(
r ij n r
)
kl
Using the properties of the single entry matrix found in Sec. 9.7.4, the result
follows easily.
det(
H
) = det(
H
)Tr[(
H
)

(
H
)]
= det(
H
)Tr[(
H
)

( (
H
) +
H
( ))]
= det(
H
)
_
Tr[(
H
)

(
H
) ]
+Tr[(
H
)
H
( )]
_
= det(
H
)
_
Tr[ (
H
)

(
H
)]
+Tr[(
H
)
H
( )]
_
First, the derivative is found with respect to the real part of
det(
H
)
'
= det(
H
)
_
Tr[ (
H
)

(
H
)]
'
+
Tr[(
H
)
H
( )]
'
_
= det(
H
)
_
(
H
)

+ ((
H
)
H
)
T
_
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 67
B.1 Misc Proofs B PROOFS AND DETAILS
Through the calculations, (92) and (219) were used. In addition, by use of (220),
the derivative is found with respect to the imaginary part of
det(
H
)

= det(
H
)
_
Tr[ (
H
)

(
H
)]

+
Tr[(
H
)
H
( )]

_
= det(
H
)
_
(
H
)

((
H
)
H
)
T
_
Hence, derivative yields
det(
H
)
=
1
2
_
det(
H
)
'

det(
H
)

_
= det(
H
)
_
(
H
)
H
_
T
and the complex conjugate derivative yields
det(
H
)

=
1
2
_
det(
H
)
'
+
det(
H
)

_
= det(
H
) (
H
)

Notice, for real , , the sum of (228) and (229) is reduced to (48).
Similar calculations yield
det(
H
)
=
1
2
_
det(
H
)
'

det(
H
)

_
= det(
H
)
_
H
(
H
)

_
T
(545)
and
det(
H
)

=
1
2
_
det(
H
)
'
+
det(
H
)

_
= det(
H
)(
H
)

(546)
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 68
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] 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 Engi-
neering,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,
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 69
REFERENCES REFERENCES
[18] Carl D. Meyer. Generalized inversion of modied matrices. SIAM Journal
of Applied Mathematics, 24(3):315323, May 1973.
[19] Thomas P. Minka. Old and new matrix algebra useful for statistics, De-
cember 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
ltering 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),
[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.
Petersen & Pedersen, The Matrix Cookbook, Version: November 14, 2008, Page 70
Index
Anti-symmetric, 49
Block matrix, 41
Chain rule, 14
Cholesky-decomposition, 28
Co-kurtosis, 29
Co-skewness, 29
Condition number, 61
Cramers Rule, 57
Derivative of a complex matrix, 22
Derivative of a determinant, 7
Derivative of a trace, 11
Derivative of an inverse, 8
Derivative of symmetric matrix, 15
Derivatives of Toeplitz matrix, 15
Dirichlet distribution, 33
Eigenvalues, 26
Eigenvectors, 26
Exponential Matrix Function, 55
Gaussian, conditional, 36
Gaussian, entropy, 40
Gaussian, linear combination, 36
Gaussian, marginal, 35
Gaussian, product of densities, 37
Generalized inverse, 20
Hermitian, 43
Idempotent, 44
Kronecker product, 55
LDL decomposition, 28
LDM-decomposition, 28
Linear regression, 56
LU decomposition, 28
Lyapunov Equation, 59
Moore-Penrose inverse, 20
Multinomial distribution, 33
Nilpotent, 44
Norm of a matrix, 59
Norm of a vector, 59
Normal-Inverse Gamma distribution, 33
Normal-Inverse Wishart distribution, 34
Orthogonal, 44
Power series of matrices, 54
Probability matrix, 51
Pseudo-inverse, 20
Schur complement, 36, 42
Single entry matrix, 47
Singular Valued Decomposition (SVD),
26
Skew-Hermitian, 43
Skew-symmetric, 49
Stochastic matrix, 51
Student-t, 32
Sylvesters Inequality, 61
Symmetric, 49
Taylor expansion, 54
Toeplitz matrix, 50
Transition matrix, 51
Trigonometric functions, 55
Unipotent, 44
Vandermonde matrix, 53
Vec operator, 55, 56
Wishart distribution, 33
Woodbury identity, 17
71

You might also like