The Matrix Cookbook
Kaare Brandt Petersen Michael Syskind Pedersen Version: February 16, 2006
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 [email protected].
Its ongoing: The project of keeping a large repository of relations involving matrices is naturally ongoing and the version will be apparent from the date in the header.
Suggestions: Your suggestion for additional content or elaboration of some topics is most welcome at [email protected].
Keywords: Matrix algebra, matrix relations, matrix identities, derivative of determinant, derivative of inverse matrix, differentiate a matrix.
Acknowledgements: We would like to thank the following for contribu- tions and suggestions: Christian Rishøj, Douglas L. Theobald, Esben Hoegh- Rasmussen, Lars Christiansen, and Vasile Sima. We would also like thank The Oticon Foundation for funding our PhD studies.
1 CONTENTS CONTENTS
Contents
1 Basics 5 1.1 Trace and Determinants ...... 5 1.2 The Special Case 2x2 ...... 5
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 15 3.1 Basic ...... 15 3.2 Exact Relations ...... 16 3.3 Implication on Inverses ...... 17 3.4 Approximations ...... 17 3.5 Generalized Inverse ...... 17 3.6 Pseudo Inverse ...... 17
4 Complex Matrices 19 4.1 Complex Derivatives ...... 19
5 Decompositions 22 5.1 Eigenvalues and Eigenvectors ...... 22 5.2 Singular Value Decomposition ...... 22 5.3 Triangular Decomposition ...... 24
6 Statistics and Probability 25 6.1 Definition of Moments ...... 25 6.2 Expectation of Linear Combinations ...... 26 6.3 Weighted Scalar Variable ...... 27
7 Gaussians 28 7.1 Basics ...... 28 7.2 Moments ...... 30 7.3 Miscellaneous ...... 32 7.4 Mixture of Gaussians ...... 33
8 Special Matrices 34 8.1 Units, Permutation and Shift ...... 34 8.2 The Singleentry Matrix ...... 35 8.3 Symmetric and Antisymmetric ...... 37 8.4 Vandermonde Matrices ...... 37 8.5 Toeplitz Matrices ...... 38 8.6 The DFT Matrix ...... 39
Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 2 CONTENTS CONTENTS
8.7 Positive Definite and Semi-definite Matrices ...... 40 8.8 Block matrices ...... 41
9 Functions and Operators 43 9.1 Functions and Series ...... 43 9.2 Kronecker and Vec Operator ...... 44 9.3 Solutions to Systems of Equations ...... 45 9.4 Matrix Norms ...... 47 9.5 Rank ...... 48 9.6 Integral Involving Dirac Delta Functions ...... 48 9.7 Miscellaneous ...... 49
A One-dimensional Results 50 A.1 Gaussian ...... 50 A.2 One Dimensional Mixture of Gaussians ...... 51
B Proofs and Details 53 B.1 Misc Proofs ...... 53
Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 3 CONTENTS CONTENTS
Notation and Nomenclature A Matrix Aij Matrix indexed for some purpose Ai Matrix indexed for some purpose Aij Matrix indexed for some purpose An 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 (see Sec. 3.6) A1/2 The square root of a matrix (if unique), not elementwise (A)ij The (i, j).th entry of the matrix A Aij The (i, j).th entry of the matrix A [A]ij The ij-submatrix, i.e. A with i.th row and j.th column deleted a Vector ai Vector indexed for some purpose ai The i.th element of the vector a a Scalar
det(A) Determinant of A Tr(A) Trace of the matrix A diag(A) Diagonal matrix of the matrix A, i.e. (diag(A))ij = δijAij vec(A) The vector-version of the matrix A (see Sec. 9.2.2) ||A|| Matrix norm (subscript if any denotes what norm) AT Transposed matrix A∗ Complex conjugated matrix AH Transposed and complex conjugated matrix (Hermitian) A ◦ B Hadamard (elementwise) product A ⊗ B Kronecker product 0 The null matrix. Zero in all entries. I The identity matrix Jij The single-entry matrix, 1 at (i, j) and zero elsewhere Σ A positive definite matrix Λ A diagonal matrix Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 4 1 BASICS 1 Basics (AB)−1 = B−1A−1 (ABC...)−1 = ...C−1B−1A−1 (AT )−1 = (A−1)T (A + B)T = AT + BT (AB)T = BT AT (ABC...)T = ...CT BT AT (AH )−1 = (A−1)H (A + B)H = AH + BH (AB)H = BH AH (ABC...)H = ...CH BH AH 1.1 Trace and Determinants P Tr(A) = Aii Pi Tr(A) = iλi, λi = eig(A) Tr(A) = Tr(AT ) Tr(AB) = Tr(BA) Tr(A + B) = Tr(A) + Tr(B) Tr(ABC) = Tr(BCA) = Tr(CAB) Q det(A) = iλi λi = eig(A) det(AB) = det(A) det(B) det(A−1) = 1/ det(A) det(I + uvT ) = 1 + uT v 1.2 The Special Case 2x2 Consider the matrix A A A A = 11 12 A21 A22 Determinant and trace det(A) = A11A22 − A12A21 Tr(A) = A11 + A22 Eigenvalues λ2 − λ · Tr(A) + det(A) = 0 Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 5 1.2 The Special Case 2x2 1 BASICS p p Tr(A) + Tr(A)2 − 4 det(A) Tr(A) − Tr(A)2 − 4 det(A) λ = λ = 1 2 2 2 λ1 + λ2 = Tr(A) λ1λ2 = det(A) Eigenvectors A12 A12 v1 ∝ v2 ∝ λ1 − A11 λ2 − A11 Inverse 1 A −A A−1 = 22 12 det(A) −A21 A11 Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 6 2 DERIVATIVES 2 Derivatives This section is covering differentiation 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 definite). See section 2.5 for differentiation of structured matrices. The basic assumptions can be written in a formula as ∂Xkl = δikδlj ∂Xij that is for e.g. vector forms, ∂x ∂x ∂x ∂x ∂x ∂x = i = = i ∂y i ∂y ∂y i ∂yi ∂y ij ∂yj The following rules are general and very useful when deriving the differential of an expression ([13]): ∂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) ∂(X ⊗ Y) = (∂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) ∂XT = (∂X)T (11) ∂XH = (∂X)H (12) 2.1 Derivatives of a Determinant 2.1.1 General form ∂ det(Y) ∂Y = det(Y)Tr Y−1 ∂x ∂x 2.1.2 Linear forms ∂ det(X) = det(X)(X−1)T ∂X ∂ det(AXB) = det(AXB)(X−1)T = det(AXB)(XT )−1 ∂X Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 7 2.2 Derivatives of an Inverse 2 DERIVATIVES 2.1.3 Square forms If X is square and invertible, then ∂ det(XT AX) = 2 det(XT AX)X−T ∂X If X is not square but A is symmetric, then ∂ det(XT AX) = 2 det(XT AX)AX(XT AX)−1 ∂X If X is not square and A is not symmetric, then ∂ det(XT AX) = det(XT AX)(AX(XT AX)−1 + AT X(XT AT X)−1) (13) ∂X 2.1.4 Other nonlinear forms Some special cases are (See [8, 7]) ∂ ln det(XT X)| = 2(X+)T ∂X ∂ ln det(XT X) = −2XT ∂X+ ∂ ln | det(X)| = (X−1)T = (XT )−1 ∂X ∂ det(Xk) = k det(Xk)X−T ∂X 2.2 Derivatives of an Inverse From [19] we have the basic identity ∂Y−1 ∂Y = −Y−1 Y−1 ∂x ∂x from which it follows −1 ∂(X )kl −1 −1 = −(X )ki(X )jl ∂Xij ∂aT X−1b = −X−T abT X−T ∂X ∂ det(X−1) = − det(X−1)(X−1)T ∂X ∂Tr(AX−1B) = −(X−1BAX−1)T ∂X Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, 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 ∂xT a ∂aT x = = a ∂x ∂x ∂aT Xb = abT ∂X ∂aT XT b = baT ∂X ∂aT Xa ∂aT XT a = = aaT ∂X ∂X ∂X = Jij ∂Xij ∂(XA)ij mn = δim(A)nj = (J A)ij ∂Xmn T ∂(X A)ij nm = δin(A)mj = (J A)ij ∂Xmn 2.3.2 Second Order ∂ X X XklXmn = 2 Xkl ∂Xij klmn kl ∂bT XT Xc = X(bcT + cbT ) ∂X ∂(Bx + b)T C(Dx + d) = BT C(Dx + d) + DT CT (Bx + b) ∂x T ∂(X BX)kl T = δlj(X B)ki + δkj(BX)il ∂Xij T ∂(X BX) T ij ji ij = X BJ + J BX (J )kl = δikδjl ∂Xij See Sec 8.2 for useful properties of the Single-entry matrix Jij ∂xT Bx = (B + BT )x ∂x ∂bT XT DXc = DT XbcT + DXcbT ∂X ∂ (Xb + c)T D(Xb + c) = (D + DT )(Xb + c)bT ∂X Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 9 2.3 Derivatives of Matrices, Vectors and Scalar Forms 2 DERIVATIVES Assume W is symmetric, then ∂ (x − As)T W(x − As) = −2AT W(x − As) ∂s ∂ (x − s)T W(x − s) = −2W(x − s) ∂s ∂ (x − As)T W(x − As) = 2W(x − As) ∂x ∂ (x − As)T W(x − As) = −2W(x − As)sT ∂A 2.3.3 Higher order and non-linear ∂ nX−1 aT Xnb = (Xr)T abT (Xn−1−r)T (14) ∂X r=0 ∂ nX−1 h aT (Xn)T Xnb = Xn−1−rabT (Xn)T Xr ∂X r=0 i +(Xr)T XnabT (Xn−1−r)T (15) See B.1.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 ∂ ∂s T ∂r sT Ar = Ar + sT A ∂x ∂x ∂x 2.3.4 Gradient and Hessian Using the above we have for the gradient and the hessian f = xT Ax + bT x ∂f ∇ f = = (A + AT )x + b x ∂x ∂2f = A + AT ∂x∂xT Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 10 2.4 Derivatives of Traces 2 DERIVATIVES 2.4 Derivatives of Traces 2.4.1 First Order ∂ Tr(X) = I ∂X ∂ Tr(XA) = AT (16) ∂X ∂ Tr(AXB) = AT BT ∂X ∂ Tr(AXT B) = BA ∂X ∂ Tr(XT A) = A ∂X ∂ Tr(AXT ) = A ∂X 2.4.2 Second Order ∂ Tr(X2) = 2XT ∂X ∂ Tr(X2B) = (XB + BX)T ∂X ∂ Tr(XT BX) = BX + BT X ∂X ∂ Tr(XBXT ) = XBT + XB ∂X ∂ Tr(AXBX) = AT XT BT + BT XT AT ∂X ∂ Tr(XT X) = 2X ∂X ∂ Tr(BXXT ) = (B + BT )X ∂X ∂ Tr(BT XT CXB) = CT XBBT + CXBBT ∂X ∂ Tr XT BXC = BXC + BT XCT ∂X ∂ Tr(AXBXT C) = AT CT XBT + CAXB ∂X ∂ h i Tr (AXb + c)(AXb + c)T = 2AT (AXb + c)bT ∂X See [7]. Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 11 2.5 Derivatives of Structured Matrices 2 DERIVATIVES 2.4.3 Higher Order ∂ Tr(Xk) = k(Xk−1)T ∂X ∂ kX−1 Tr(AXk) = (XrAXk−r−1)T ∂X r=0 ∂ T T T T T ∂X Tr B X CXX CXB = CXX CXBB +CT XBBT XT CT X +CXBBT XT CX +CT XXT CT XBBT 2.4.4 Other ∂ Tr(AX−1B) = −(X−1BAX−1)T = −X−T AT BT X−T ∂X Assume B and C to be symmetric, then ∂ h i Tr (XT CX)−1A = −(CX(XT CX)−1)(A + AT )(XT CX)−1 ∂X ∂ h i Tr (XT CX)−1(XT BX) = −2CX(XT CX)−1XT BX(XT CX)−1 ∂X +2BX(XT CX)−1 See [7]. 2.5 Derivatives of Structured Matrices Assume that the matrix A has some structure, i.e. symmetric, toeplitz, etc. In that case the derivatives of the previous section does not apply in general. Instead, consider the following general rule for differentiating a scalar function f(A) " # df X ∂f ∂A ∂f T ∂A = kl = Tr dAij ∂Akl ∂Aij ∂A ∂Aij kl The matrix differentiated with respect to itself is in this document referred to as the structure matrix of A and is defined simply by ∂A = Sij ∂Aij If A has no special structure we have simply Sij = Jij, that is, the structure matrix is simply the singleentry matrix. Many structures have a representation in singleentry matrices, see Sec. 8.2.6 for more examples of structure matrices. Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 12 2.5 Derivatives of Structured Matrices 2 DERIVATIVES 2.5.1 The Chain Rule Sometimes the objective is to find the derivative of a matrix which is a function of another matrix. Let U = f(X), the goal is to find the derivative of the function g(U) with respect to X: ∂g(U) ∂g(f(X)) = (17) ∂X ∂X Then the Chain Rule can then be written the following way: ∂g(U) ∂g(U) XM XN ∂g(U) ∂u = = kl (18) ∂X ∂xij ∂ukl ∂xij k=1 l=1 Using matrix notation, this can be written as: ∂g(U) h ∂g(U) ∂U i = Tr ( )T . (19) ∂Xij ∂U ∂Xij 2.5.2 Symmetric If A is symmetric, then Sij = Jij + Jji − Jij Jij and therefore df ∂f ∂f T ∂f = + − diag dA ∂A ∂A ∂A That is, e.g., ([5], [20]): ∂Tr(AX) = A + AT − (A ◦ I), see (23) (20) ∂X ∂ det(X) = det(X)(2X−1 − (X−1 ◦ I)) (21) ∂X ∂ ln det(X) = 2X−1 − (X−1 ◦ I) (22) ∂X 2.5.3 Diagonal If X is diagonal, then ([13]): ∂Tr(AX) = A ◦ I (23) ∂X 2.5.4 Toeplitz Like symmetric matrices and diagonal matrices also Toeplitz matrices has a special structure which should be taken into account when the derivative with respect to a matrix with Toeplitz structure. Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 13 2.5 Derivatives of Structured Matrices 2 DERIVATIVES ∂Tr(AT) (24) ∂T ∂Tr(TA) = ∂T T T Tr(A) Tr([A ]n1) Tr([[A ]1n]n−1,2) ··· An1 . . . T . . . Tr([A ]1n)) Tr(A) . . . . . . . . . = T . . . T Tr([[A ]1n]2,n−1) Tr([[A ]1n]n−1,2) . . . . ...... T . . Tr([A ]n1) T T A1n ··· Tr([[A ]1n]2,n−1) Tr([A ]1n)) Tr(A) ≡ α(A) As it can be seen, the derivative α(A) also has a Toeplitz structure. Each value in the diagonal is the sum of all the diagonal valued in A, the values in the diagonals next to the main diagonal equal the sum of the diagonal next to the main diagonal in AT . This result is only valid for the unconstrained Toeplitz matrix. If the Toeplitz matrix also is symmetric, the same derivative yields ∂Tr(AT) ∂Tr(TA) = ∂T ∂T = α(A) + α(A)T − α(A) ◦ I (25) Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 14 3 INVERSES 3 Inverses 3.1 Basic 3.1.1 Definition The inverse A−1 of a matrix A ∈ Cn×n is defined such that AA−1 = A−1A = I, (26) where I is the n × n identity matrix. If A−1 exists, A is said to be nonsingular. Otherwise, A is said to be singular (see e.g. [9]). 3.1.2 Cofactors and Adjoint The submatrix of a matrix A, denoted by [A]ij is a (n − 1) × (n − 1) matrix obtained by deleting the ith row and the jth column of A. The (i, j) cofactor of a matrix is defined as i+j cof(A, i, j) = (−1) det([A]ij), (27) The matrix of cofactors can be created from the cofactors cof(A, 1, 1) ··· cof(A, 1, n) . . cof(A) = . . (28) . cof(A, i, j) . cof(A, n, 1) ··· cof(A, n, n) The adjoint matrix is the transpose of the cofactor matrix adj(A) = (cof(A))T , (29) 3.1.3 Determinant The determinant of a matrix A ∈ Cn×n is defined as (see [9]) Xn j+1 det(A) = (−1) A1j det ([A]1j) j=1 Xn = A1jcof(A, 1, j). (30) j=1 3.1.4 Construction The inverse matrix can be constructed, using the adjoint matrix, by 1 A−1 = · adj(A) (31) det(A) Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 15 3.2 Exact Relations 3 INVERSES 3.1.5 Condition number The condition number of a matrix c(A) is the ratio between the largest and the smallest singular value of a matrix (see Section 5.2 on singular values), d c(A) = + d− The condition number can be used to measure how singular a matrix is. If the condition number is large, it indicates that the matrix is nearly singular. The condition number can also be estimated from the matrix norms. Here c(A) = kAk · kA−1k, (32) where k · k is a norm such as e.g the 1-norm, the 2-norm, the ∞-norm or the Frobenius norm (see Sec 9.4 for more on matrix norms). 3.2 Exact Relations 3.2.1 The Woodbury identity (A + CBCT )−1 = A−1 − A−1C(B−1 + CT A−1C)−1CT A−1 If P, R are positive definite, then (see [22]) (P−1 + BT R−1B)−1BT R−1 = PBT (BPBT + R)−1 3.2.2 The Kailath Variant (A + BC)−1 = A−1 − A−1B(I + CA−1B)−1CA−1 See [4] page 153. 3.2.3 The Searle Set of Identities The following set of identities, can be found in [17], page 151, (I + A−1)−1 = A(A + I)−1 (A + BBT )−1B = A−1B(I + BT A−1B)−1 (A−1 + B−1)−1 = A(A + B)−1B = B(A + B)−1A A − A(A + B)−1A = B − B(A + B)−1B A−1 + B−1 = A−1(A + B)B−1 (I + AB)−1 = I − A(I + BA)−1B (I + AB)−1A = A(I + BA)−1 Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 16 3.3 Implication on Inverses 3 INVERSES 3.3 Implication on Inverses (A + B)−1 = A−1 + B−1 ⇒ AB−1A = BA−1B See [17]. 3.3.1 A PosDef identity Assume P, R to be positive definite and invertible, then (P−1 + BT R−1B)−1BT R−1 = PBT (BPBT + R)−1 See [22]. 3.4 Approximations (I + A)−1 = I − A + A2 − A3 + ... A − A(I + A)−1A =∼ I − A−1 if A large and symmetric If σ2 is small then (Q + σ2M)−1 =∼ Q−1 − σ2Q−1MQ−1 3.5 Generalized Inverse 3.5.1 Definition A generalized inverse matrix of the matrix A is any matrix A− such that (see [18]) AA−A = A The matrix A− is not unique. 3.6 Pseudo Inverse 3.6.1 Definition The pseudo inverse (or Moore-Penrose inverse) of a matrix A is the matrix A+ that fulfils I AA+A = A II A+AA+ = A+ III AA+ symmetric IV A+A symmetric The matrix A+ is unique and does always exist. Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 17 3.6 Pseudo Inverse 3 INVERSES 3.6.2 Properties Assume A+ to be the pseudo-inverse of A, then (See [3]) (A+)+ = A (AT )+ = (A+)T (cA)+ = (1/c)A+ (AT A)+ = A+(AT )+ (AAT )+ = (AT )+A+ Assume A to have full rank, then (AA+)(AA+) = AA+ (A+A)(A+A) = A+A Tr(AA+) = rank(AA+) (See [18]) Tr(A+A) = rank(A+A) (See [18]) 3.6.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+ = AT (AAT )−1 A n × m Tall rank(A) = m ⇒ A+ = (AT A)−1AT Assume A does not have full rank, i.e. A is n×m and rank(A) = r < min(n, m). The pseudo inverse A+ can be constructed from the singular value decomposi- tion A = UDVT , by A+ = VD+UT A different 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+ = DT (DDT )−1(CT C)−1CT See [3]. Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 18 4 COMPLEX MATRICES 4 Complex Matrices 4.1 Complex Derivatives In order to differentiate an expression f(z) with respect to a complex z, the Cauchy-Riemann equations have to be satisfied ([7]): df(z) ∂<(f(z)) ∂=(f(z)) = + i (33) dz ∂ ∂f(z) ∂f(z) = i . (35) ∂=z ∂ df(z) 1∂f(z) ∂f(z) = − i . (36) dz 2 ∂ • Conjugate Complex Derivative df(z) 1∂f(z) ∂f(z) = + i . (37) dz∗ 2 ∂ 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 [14] when deriving a complex gradient. Notice: df(z) ∂f(z) ∂f(z) 6= + i . (38) dz ∂ df(z) ∇f(z) = 2 (39) dz∗ ∂f(z) ∂f(z) = + i . ∂ Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 19 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]) df(Z) ∇f(Z) = 2 (40) dZ∗ ∂f(Z) ∂f(Z) = + i . ∂ 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 ([7]) ∂g(u) ∂g ∂u ∂g ∂u∗ = + (41) ∂x ∂u ∂x ∂u∗ ∂x ∂g ∂u ∂g∗ ∗ ∂u∗ = + ∂u ∂x ∂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) T ∂g(U) T ∗ ∂g(U) Tr(( ) ∂U) Tr(( ∗ ) ∂U ) = ∂U + ∂U . (42) ∂X ∂X ∂X 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∗) ∂Tr(XH ) = = I (43) ∂ Petersen & Pedersen, The Matrix Cookbook, Version: February 16, 2006, Page 20 4.1 Complex Derivatives 4 COMPLEX MATRICES complex number. ∂Tr(AXH ) = A (47) ∂ ∂Tr(AX∗) = AT (49) ∂ ∂Tr(XXH ) ∂Tr(XH X) = = 2 ∂Tr(XXH ) = X∗ (53) ∂X ∂Tr(XXH ) = X (54) ∂X∗ Since the function Tr(XXH ) is a real function of the complex matrix X, the complex gradient matrix (40) is given by ∂Tr(XXH ) ∇Tr(XXH ) = 2 = 2X (55) ∂X∗ 4.1.3 Complex Derivative Involving Determinants Here, a calculation example is provided. The objective is to find the derivative of det(XH AX) with respect to X ∈ Cm×n. The derivative is found with respect to the real part and the imaginary part of X, by use of (9) and (5), det(XH AX) can be calculated as (see Sec. B.1.2 for details) ∂ det(XH AX) 1∂ det(XH AX) ∂ det(XH AX) = − i ∂X 2 ∂