In mathematics, matrix calculus is a specialized notation for doing multivariable calculus, especially over spaces of matrices. It collects the various partial derivatives of a single function with respect to many variables, and/or of a multivariate function with respect to a single variable, into vectors and matrices that can be treated as single entities. This greatly simplifies operations such as finding the maximum or minimum of a multivariate function and solving systems of differential equations. The notation used here is commonly used in statistics and engineering, while the tensor index notation is preferred in physics.
Two competing notational conventions split the field of matrix calculus into two separate groups. The two groups can be distinguished by whether they write the derivative of a scalar with respect to a vector as a column vector or a row vector. Both of these conventions are possible even when the common assumption is made that vectors should be treated as column vectors when combined with matrices (rather than row vectors). A single convention can be somewhat standard throughout a single field that commonly uses matrix calculus (e.g. econometrics, statistics, estimation theory and machine learning). However, even within a given field different authors can be found using competing conventions. Authors of both groups often write as though their specific conventions were standard. Serious mistakes can result when combining results from different authors without carefully verifying that compatible notations have been used. Definitions of these two conventions and comparisons between them are collected in the layout conventions section.
Matrix calculus refers to a number of different notations that use matrices and vectors to collect the derivative of each component of the dependent variable with respect to each component of the independent variable. In general, the independent variable can be a scalar, a vector, or a matrix while the dependent variable can be any of these as well. Each different situation will lead to a different set of rules, or a separate calculus, using the broader sense of the term. Matrix notation serves as a convenient way to collect the many derivatives in an organized way.
As a first example, consider the gradient from vector calculus. For a scalar function of three independent variables,
f(x1,x2,x3)
\nablaf=
\partialf | |
\partialx1 |
\hat{x}1+
\partialf | |
\partialx2 |
\hat{x}2+
\partialf | |
\partialx3 |
\hat{x}3,
where
\hat{x}i
xi
1\lei\le3
x
\nablaf=\left(
\partialf | |
\partialx |
\right)T= \begin{bmatrix} \dfrac{\partialf}{\partialx1}& \dfrac{\partialf}{\partialx2}& \dfrac{\partialf}{\partialx3}\\ \end{bmatrix}sf{T}.
More complicated examples include the derivative of a scalar function with respect to a matrix, known as the gradient matrix, which collects the derivative with respect to each matrix element in the corresponding position in the resulting matrix. In that case the scalar must be a function of each of the independent variables in the matrix. As another example, if we have an -vector of dependent variables, or functions, of independent variables we might consider the derivative of the dependent vector with respect to the independent vector. The result could be collected in an matrix consisting of all of the possible derivative combinations.
There are a total of nine possibilities using scalars, vectors, and matrices. Notice that as we consider higher numbers of components in each of the independent and dependent variables we can be left with a very large number of possibilities. The six kinds of derivatives that can be most neatly organized in matrix form are collected in the following table.
Scalar | Vector | Matrix | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Scalar |
|
|
| |||||||||
Vector |
|
| ||||||||||
Matrix |
|
Here, we have used the term "matrix" in its most general sense, recognizing that vectors are simply matrices with one column (and scalars are simply vectors with one row). Moreover, we have used bold letters to indicate vectors and bold capital letters for matrices. This notation is used throughout.
Notice that we could also talk about the derivative of a vector with respect to a matrix, or any of the other unfilled cells in our table. However, these derivatives are most naturally organized in a tensor of rank higher than 2, so that they do not fit neatly into a matrix. In the following three sections we will define each one of these derivatives and relate them to other branches of mathematics. See the layout conventions section for a more detailed table.
The matrix derivative is a convenient notation for keeping track of partial derivatives for doing calculations. The Fréchet derivative is the standard way in the setting of functional analysis to take derivatives with respect to vectors. In the case that a matrix function of a matrix is Fréchet differentiable, the two derivatives will agree up to translation of notations. As is the case in general for partial derivatives, some formulae may extend under weaker analytic conditions than the existence of the derivative as approximating linear mapping.
Matrix calculus is used for deriving optimal stochastic estimators, often involving the use of Lagrange multipliers. This includes the derivation of:
The vector and matrix derivatives presented in the sections to follow take full advantage of matrix notation, using a single variable to represent a large number of variables. In what follows we will distinguish scalars, vectors and matrices by their typeface. We will let denote the space of real matrices with rows and columns. Such matrices will be denoted using bold capital letters:,,, etc. An element of, that is, a column vector, is denoted with a boldface lowercase letter:,,, etc. An element of is a scalar, denoted with lowercase italic typeface:,,, etc. denotes matrix transpose, is the trace, and or is the determinant. All functions are assumed to be of differentiability class unless otherwise noted. Generally letters from the first half of the alphabet (a, b, c, ...) will be used to denote constants, and from the second half (t, x, y, ...) to denote variables.
NOTE: As mentioned above, there are competing notations for laying out systems of partial derivatives in vectors and matrices, and no standard appears to be emerging yet. The next two introductory sections use the numerator layout convention simply for the purposes of convenience, to avoid overly complicating the discussion. The section after them discusses layout conventions in more detail. It is important to realize the following:
The tensor index notation with its Einstein summation convention is very similar to the matrix calculus, except one writes only a single component at a time. It has the advantage that one can easily manipulate arbitrarily high rank tensors, whereas tensors of rank higher than two are quite unwieldy with matrix notation. All of the work here can be done in this notation without use of the single-variable matrix notation. However, many problems in estimation theory and other areas of applied mathematics would result in too many indices to properly keep track of, pointing in favor of matrix calculus in those areas. Also, Einstein notation can be very useful in proving the identities presented here (see section on differentiation) as an alternative to typical element notation, which can become cumbersome when the explicit sums are carried around. Note that a matrix can be considered a tensor of rank two.
See main article: Vector calculus. Because vectors are matrices with only one column, the simplest matrix derivatives are vector derivatives.
The notations developed here can accommodate the usual operations of vector calculus by identifying the space of -vectors with the Euclidean space, and the scalar is identified with . The corresponding concept from vector calculus is indicated at the end of each subsection.
NOTE: The discussion in this section assumes the numerator layout convention for pedagogical purposes. Some authors use different conventions. The section on layout conventions discusses this issue in greater detail. The identities given further down are presented in forms that can be used in conjunction with all common layout conventions.
y=\begin{bmatrix} y1& y2& … & ym \end{bmatrix}T
dy | |
dx |
= \begin{bmatrix}
dy1 | |
dx |
\\
dy2 | |
dx |
\\ \vdots\\
dym | |
dx |
\\ \end{bmatrix}.
In vector calculus the derivative of a vector with respect to a scalar is known as the tangent vector of the vector,
\partialy | |
\partialx |
Example Simple examples of this include the velocity vector in Euclidean space, which is the tangent vector of the position vector (considered as a function of time). Also, the acceleration is the tangent vector of the velocity.
The derivative of a scalar by a vector
x=\begin{bmatrix} x1& x2& … & xn \end{bmatrix}T
\partialy | |
\partialx |
= \begin{bmatrix} \dfrac{\partialy}{\partialx1}& \dfrac{\partialy}{\partialx2}& … & \dfrac{\partialy}{\partialxn} \end{bmatrix}.
In vector calculus, the gradient of a scalar field (whose independent coordinates are the components of) is the transpose of the derivative of a scalar by a vector.
\nablaf=\begin{bmatrix}
\partialf | |
\partialx1 |
\ \vdots\
\partialf | |
\partialxn |
\end{bmatrix}=\left(
\partialf | |
\partialx |
\right)T
By example, in physics, the electric field is the negative vector gradient of the electric potential.
The directional derivative of a scalar function of the space vector in the direction of the unit vector (represented in this case as a column vector) is defined using the gradient as follows.
\nablau{f}(x)=\nablaf(x) ⋅ u
\nablauf=
\partialf | |
\partialx |
u.
Each of the previous two cases can be considered as an application of the derivative of a vector with respect to a vector, using a vector of size one appropriately. Similarly we will find that the derivatives involving matrices will reduce to derivatives involving vectors in a corresponding way.
The derivative of a vector function (a vector whose components are functions)
y=\begin{bmatrix} y1& y2& … & ym \end{bmatrix}T
x=\begin{bmatrix} x1& x2& … & xn \end{bmatrix}T
\partialy | |
\partialx |
= \begin{bmatrix}
\partialy1 | |
\partialx1 |
&
\partialy1 | |
\partialx2 |
& … &
\partialy1 | |
\partialxn |
\\
\partialy2 | |
\partialx1 |
&
\partialy2 | |
\partialx2 |
& … &
\partialy2 | |
\partialxn |
\\ \vdots&\vdots&\ddots&\vdots\\
\partialym | |
\partialx1 |
&
\partialym | |
\partialx2 |
& … &
\partialym | |
\partialxn |
\\ \end{bmatrix}.
In vector calculus, the derivative of a vector function with respect to a vector whose components represent a space is known as the pushforward (or differential), or the Jacobian matrix.
The pushforward along a vector function with respect to vector in is given by
df(v)=
\partialf | |
\partialv |
dv.
There are two types of derivatives with matrices that can be organized into a matrix of the same size. These are the derivative of a matrix by a scalar and the derivative of a scalar by a matrix. These can be useful in minimization problems found in many areas of applied mathematics and have adopted the names tangent matrix and gradient matrix respectively after their analogs for vectors.
Note: The discussion in this section assumes the numerator layout convention for pedagogical purposes. Some authors use different conventions. The section on layout conventions discusses this issue in greater detail. The identities given further down are presented in forms that can be used in conjunction with all common layout conventions.
The derivative of a matrix function by a scalar is known as the tangent matrix and is given (in numerator layout notation) by
\partialY | = \begin{bmatrix} | |
\partialx |
\partialy11 | |
\partialx |
&
\partialy12 | |
\partialx |
& … &
\partialy1n | \\ | |
\partialx |
\partialy21 | |
\partialx |
&
\partialy22 | |
\partialx |
& … &
\partialy2n | |
\partialx |
\\ \vdots&\vdots&\ddots&\vdots\\
\partialym1 | |
\partialx |
&
\partialym2 | |
\partialx |
& … &
\partialymn | |
\partialx |
\\ \end{bmatrix}.
The derivative of a scalar function, with respect to a matrix of independent variables, is given (in numerator layout notation) by
\partialy | = \begin{bmatrix} | |
\partialX |
\partialy | |
\partialx11 |
&
\partialy | |
\partialx21 |
& … &
\partialy | \\ | |
\partialxp1 |
\partialy | |
\partialx12 |
&
\partialy | |
\partialx22 |
& … &
\partialy | |
\partialxp2 |
\\ \vdots&\vdots&\ddots&\vdots\\
\partialy | |
\partialx1q |
&
\partialy | |
\partialx2q |
& … &
\partialy | |
\partialxpq |
\\ \end{bmatrix}.
Important examples of scalar functions of matrices include the trace of a matrix and the determinant.
In analog with vector calculus this derivative is often written as the following.
\nablaXy(X)=
\partialy(X) | |
\partialX |
\nablaYf=\operatorname{tr}\left(
\partialf | |
\partialX |
Y\right).
It is the gradient matrix, in particular, that finds many uses in minimization problems in estimation theory, particularly in the derivation of the Kalman filter algorithm, which is of great importance in the field.
The three types of derivatives that have not been considered are those involving vectors-by-matrices, matrices-by-vectors, and matrices-by-matrices. These are not as widely considered and a notation is not widely agreed upon.
This section discusses the similarities and differences between notational conventions that are used in the various fields that take advantage of matrix calculus. Although there are largely two consistent conventions, some authors find it convenient to mix the two conventions in forms that are discussed below. After this section, equations will be listed in both competing forms separately.
The fundamental issue is that the derivative of a vector with respect to a vector, i.e.
\partialy | |
\partialx |
\partialy | |
\partialx |
y
\partialy | |
\partialx |
\partialy | |
\partialx |
,
\partialy | |
\partialx |
\partialy | |
\partialx' |
,
\partialy | |
\partialx |
\partialy | |
\partialx |
,
\partialy | |
\partialx |
,
\partialy | |
\partialx |
\partialy | |
\partialx |
\partialy | |
\partialx |
,
\partialy | |
\partialx |
\partialy | |
\partialx |
\partialy | |
\partialx' |
\partialy | |
\partialx |
,
Not all math textbooks and papers are consistent in this respect throughout. That is, sometimes different conventions are used in different contexts within the same book or paper. For example, some choose denominator layout for gradients (laying them out as column vectors), but numerator layout for the vector-by-vector derivative
\partialy | |
\partialx |
.
Similarly, when it comes to scalar-by-matrix derivatives
\partialy | |
\partialX |
\partialY | |
\partialx |
,
\partialY | |
\partialx |
,
\partialY | |
\partialx |
\partialy | |
\partialX |
\partialY | |
\partialx |
\partialy | |
\partialX |
\partialy | |
\partialX' |
,
In the following formulas, we handle the five possible combinations
\partialy | |
\partialx |
,
\partialy | |
\partialx |
,
\partialy | |
\partialx |
,
\partialy | |
\partialX |
\partialY | |
\partialx |
Keep in mind that various authors use different combinations of numerator and denominator layouts for different types of derivatives, and there is no guarantee that an author will consistently use either numerator or denominator layout for all types. Match up the formulas below with those quoted in the source to determine the layout used for that particular type of derivative, but be careful not to assume that derivatives of other types necessarily follow the same kind of layout.
When taking derivatives with an aggregate (vector or matrix) denominator in order to find a maximum or minimum of the aggregate, it should be kept in mind that using numerator layout will produce results that are transposed with respect to the aggregate. For example, in attempting to find the maximum likelihood estimate of a multivariate normal distribution using matrix calculus, if the domain is a k×1 column vector, then the result using the numerator layout will be in the form of a 1×k row vector. Thus, either the results should be transposed at the end or the denominator layout (or mixed layout) should be used.
Scalar | Column vector (size) | Matrix (size) | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Notation | Type | Notation | Type | Notation | Type | |||||||||||
Scalar | Numerator |
| Scalar |
| Size- column vector |
| matrix | |||||||||
Denominator | Size-m row vector | |||||||||||||||
Column vector (size) | Numerator |
| Size- row vector |
| matrix |
| ||||||||||
Denominator | Size- column vector | matrix | ||||||||||||||
Matrix (size) | Numerator |
| matrix |
|
| |||||||||||
Denominator | matrix |
The results of operations will be transposed when switching between numerator-layout and denominator-layout notation.
Using numerator-layout notation, we have:[1]
\begin{align}
\partialy | |
\partialx |
&=\begin{bmatrix}
\partialy | |
\partialx1 |
&
\partialy | |
\partialx2 |
& … &
\partialy | |
\partialxn |
\end{bmatrix}.\\
\partialy | |
\partialx |
&=\begin{bmatrix}
\partialy1 | |
\partialx |
\\
\partialy2 | |
\partialx |
\\ \vdots\\
\partialym | |
\partialx |
\\ \end{bmatrix}.\\
\partialy | |
\partialx |
&=\begin{bmatrix}
\partialy1 | |
\partialx1 |
&
\partialy1 | |
\partialx2 |
& … &
\partialy1 | |
\partialxn |
\\
\partialy2 | |
\partialx1 |
&
\partialy2 | |
\partialx2 |
& … &
\partialy2 | |
\partialxn |
\\ \vdots&\vdots&\ddots&\vdots\\
\partialym | |
\partialx1 |
&
\partialym | |
\partialx2 |
& … &
\partialym | |
\partialxn |
\\ \end{bmatrix}.\\
\partialy | |
\partialX |
&=\begin{bmatrix}
\partialy | |
\partialx11 |
&
\partialy | |
\partialx21 |
& … &
\partialy | |
\partialxp1 |
\\
\partialy | |
\partialx12 |
&
\partialy | |
\partialx22 |
& … &
\partialy | |
\partialxp2 |
\\ \vdots&\vdots&\ddots&\vdots\\
\partialy | |
\partialx1q |
&
\partialy | |
\partialx2q |
& … &
\partialy | |
\partialxpq |
\\ \end{bmatrix}. \end{align}
The following definitions are only provided in numerator-layout notation:
\begin{align}
\partialY | |
\partialx |
&=\begin{bmatrix}
\partialy11 | |
\partialx |
&
\partialy12 | |
\partialx |
& … &
\partialy1n | |
\partialx |
\\
\partialy21 | |
\partialx |
&
\partialy22 | |
\partialx |
& … &
\partialy2n | |
\partialx |
\\ \vdots&\vdots&\ddots&\vdots\\
\partialym1 | |
\partialx |
&
\partialym2 | |
\partialx |
& … &
\partialymn | |
\partialx |
\\ \end{bmatrix}.\\ dX&=\begin{bmatrix} dx11&dx12& … &dx1n\\ dx21&dx22& … &dx2n\\ \vdots&\vdots&\ddots&\vdots\\ dxm1&dxm2& … &dxmn\\ \end{bmatrix}. \end{align}
Using denominator-layout notation, we have:[2]
\begin{align}
\partialy | |
\partialx |
&=\begin{bmatrix}
\partialy | |
\partialx1 |
\\
\partialy | |
\partialx2 |
\\ \vdots\\
\partialy | |
\partialxn |
\\ \end{bmatrix}.\\
\partialy | |
\partialx |
&=\begin{bmatrix}
\partialy1 | |
\partialx |
&
\partialy2 | |
\partialx |
& … &
\partialym | |
\partialx |
\end{bmatrix}.\\
\partialy | |
\partialx |
&=\begin{bmatrix}
\partialy1 | |
\partialx1 |
&
\partialy2 | |
\partialx1 |
& … &
\partialym | |
\partialx1 |
\\
\partialy1 | |
\partialx2 |
&
\partialy2 | |
\partialx2 |
& … &
\partialym | |
\partialx2 |
\\ \vdots&\vdots&\ddots&\vdots\\
\partialy1 | |
\partialxn |
&
\partialy2 | |
\partialxn |
& … &
\partialym | |
\partialxn |
\\ \end{bmatrix}.\\
\partialy | |
\partialX |
&=\begin{bmatrix}
\partialy | |
\partialx11 |
&
\partialy | |
\partialx12 |
& … &
\partialy | |
\partialx1q |
\\
\partialy | |
\partialx21 |
&
\partialy | |
\partialx22 |
& … &
\partialy | |
\partialx2q |
\\ \vdots&\vdots&\ddots&\vdots\\
\partialy | |
\partialxp1 |
&
\partialy | |
\partialxp2 |
& … &
\partialy | |
\partialxpq |
\\ \end{bmatrix}. \end{align}
As noted above, in general, the results of operations will be transposed when switching between numerator-layout and denominator-layout notation.
To help make sense of all the identities below, keep in mind the most important rules: the chain rule, product rule and sum rule. The sum rule applies universally, and the product rule applies in most of the cases below, provided that the order of matrix products is maintained, since matrix products are not commutative. The chain rule applies in some of the cases, but unfortunately does not apply in matrix-by-scalar derivatives or scalar-by-matrix derivatives (in the latter case, mostly involving the trace operator applied to matrices). In the latter case, the product rule can't quite be applied directly, either, but the equivalent can be done with a bit more work using the differential identities.
The following identities adopt the following conventions:
This is presented first because all of the operations that apply to vector-by-vector differentiation apply directly to vector-by-scalar or scalar-by-vector differentiation simply by reducing the appropriate vector in the numerator or denominator to a scalar.
Expression | Numerator layout, i.e. by and | Denominator layout, i.e. by and | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
is not a function of |
= | 0 | |||||||||||||||||||||||
= | I | ||||||||||||||||||||||||
is not a function of |
= | A | A\top | ||||||||||||||||||||||
is not a function of |
= | A\top | A | ||||||||||||||||||||||
is not a function of, |
= |
| |||||||||||||||||||||||
, is not a function of |
= |
|
a\top | ||||||||||||||||||||||
, |
= | v
+u
|
+
u\top | ||||||||||||||||||||||
is not a function of, |
= |
|
A\top | ||||||||||||||||||||||
, |
= |
+
| |||||||||||||||||||||||
= |
|
| |||||||||||||||||||||||
= |
|
|
The fundamental identities are placed above the thick black line.
Expression | Numerator layout, i.e. by ; result is row vector | Denominator layout, i.e. by ; result is column vector | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
is not a function of |
= | 0\top | 0 | ||||||||||||||||||||||||||||||||||||||
is not a function of, |
= |
| |||||||||||||||||||||||||||||||||||||||
, |
= |
+
| |||||||||||||||||||||||||||||||||||||||
, |
= |
+v
| |||||||||||||||||||||||||||||||||||||||
= |
| ||||||||||||||||||||||||||||||||||||||||
= |
| ||||||||||||||||||||||||||||||||||||||||
, |
=
= |
+
,
|
v+
u
,
| ||||||||||||||||||||||||||||||||||||||
,, is not a function of |
=
= |
+v\top
,
|
Av+
A\topu
,
| ||||||||||||||||||||||||||||||||||||||
= | H\top | H | |||||||||||||||||||||||||||||||||||||||
is not a function of |
=
=
=
= | a\top | a | ||||||||||||||||||||||||||||||||||||||
is not a function of is not a function of |
= | b\topA | A\topb | ||||||||||||||||||||||||||||||||||||||
is not a function of |
= | x\top\left(A+A\top\right) | \left(A+A\top\right)x | ||||||||||||||||||||||||||||||||||||||
= | 2x\topA | 2Ax | |||||||||||||||||||||||||||||||||||||||
is not a function of |
= | A+A\top | |||||||||||||||||||||||||||||||||||||||
= | 2A | ||||||||||||||||||||||||||||||||||||||||
=
=
= | 2x\top | 2x | |||||||||||||||||||||||||||||||||||||||
is not a function of, |
=
= |
|
a
| ||||||||||||||||||||||||||||||||||||||
, are not functions of |
\topbf{b}}{\partial bf{x}}= | bf{x}\top\left(bf{a}bf{b}\top+bf{b}bf{a}\top\right) | \left(bf{a}bf{b}\top+bf{b}bf{a}\top\right)bf{x} | ||||||||||||||||||||||||||||||||||||||
,,,, are not functions of |
bf{b})\topbf{C}(bf{D}bf{x}+bf{e})}{\partial bf{x}}= | (bf{D}bf{x}+bf{e})\topbf{C}\topbf{A}+(bf{A}bf{x}+bf{b})\topbf{C}bf{D} | bf{D}\topbf{C}\top(bf{A}bf{x}+bf{b})+bf{A}\topbf{C}(bf{D}bf{x}+bf{e}) | ||||||||||||||||||||||||||||||||||||||
is not a function of |
= |
|
|
Expression | Numerator layout, i.e. by, result is column vector | Denominator layout, i.e. by, result is row vector | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
is not a function of |
= | 0 | ||||||||||||||||||||||
is not a function of, |
= |
| ||||||||||||||||||||||
is not a function of x, |
= |
|
A\top | |||||||||||||||||||||
= |
\right)\top | |||||||||||||||||||||||
, |
= |
+
| ||||||||||||||||||||||
, |
= |
\right)\top x v+u\top x
|
x v+u\top x \left(
\right)\top | |||||||||||||||||||||
= |
|
| ||||||||||||||||||||||
Assumes consistent matrix layout; see below. | ||||||||||||||||||||||||
= |
|
| ||||||||||||||||||||||
Assumes consistent matrix layout; see below. | ||||||||||||||||||||||||
, |
= |
x v+U x
| v\top x \left(
\right)+
x U\top |
NOTE: The formulas involving the vector-by-vector derivatives
\partialg(u) | |
\partialu |
\partialf(g) | |
\partialg |
Note that exact equivalents of the scalar product rule and chain rule do not exist when applied to matrix-valued functions of matrices. However, the product rule of this sort does apply to the differential form (see below), and this is the way to derive many of the identities below involving the trace function, combined with the fact that the trace function allows transposing and cyclic permutation, i.e.:
\begin{align} \operatorname{tr}(A)&=
\operatorname{tr}\left(A\top\right) |
\\ \operatorname{tr}(ABCD)&=\operatorname{tr}(BCDA)=\operatorname{tr}(CDAB)=\operatorname{tr}(DABC) \end{align}
For example, to compute
\partial\operatorname{tr | |
|
X
Therefore,
\partial\operatorname{tr | |
|
X
\partial\operatorname{tr | |
|
X
(For the last step, see the Conversion from differential to derivative form section.)
Expression | Numerator layout, i.e. by | Denominator layout, i.e. by | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
is not a function of |
= | 0\top | 0 | |||||||||||||||
is not a function of, |
= |
| ||||||||||||||||
, |
= |
+
| ||||||||||||||||
, |
= |
+v
| ||||||||||||||||
= |
| |||||||||||||||||
= |
| |||||||||||||||||
= | \operatorname{tr}\left(
\right) | \operatorname{tr}\left(\left(
\right)\top
\right) | ||||||||||||||||
Both forms assume numerator layout for
, i.e. mixed layout if denominator layout for is being used. | ||||||||||||||||||
and are not functions of |
= | ba\top | ab\top | |||||||||||||||
and are not functions of |
= | ab\top | ba\top | |||||||||||||||
, and are not functions of |
= | \left(\left(C+C\top\right)(Xa+b)a\top\right)\top | \left(C+C\top\right)(Xa+b)a\top | |||||||||||||||
, and are not functions of |
= | \left(CXba\top+C\topXab\top\right)\top | CXba\top+C\topXab\top | |||||||||||||||
X | I | |||||||||||||||||
, |
+V)}{\partialX |
X | ||||||||||||||||
is not a function of, |
X |
X | ||||||||||||||||
is any polynomial with scalar coefficients, or any matrix function defined by an infinite polynomial series (e.g.,,,, etc. using a Taylor series); is the equivalent scalar function, is its derivative, and is the corresponding matrix function |
X | g'(X) | \left(g'(X)\right)\top | |||||||||||||||
is not a function of | [5]
X | A | A\top | |||||||||||||||
is not a function of |
X | A\top | A | |||||||||||||||
is not a function of |
X | X\top\left(A+A\top\right) | \left(A+A\top\right)X | |||||||||||||||
is not a function of |
X | -X-1AX-1 | -\left(X-1\right)\topA\top\left(X-1\right)\top | |||||||||||||||
, are not functions of |
X | BA |
| |||||||||||||||
,, are not functions of |
X |
+
|
+CAXB | |||||||||||||||
is a positive integer |
n\right)}{\partialX | nXn-1 | n\left(Xn-1\right)\top | |||||||||||||||
is not a function of, is a positive integer |
n\right)}{\partialX |
XiAXn-i-1 |
\left(XiAXn-i-1\right)\top | |||||||||||||||
X\right)}{\partialX | eX | \left(eX\right)\top | ||||||||||||||||
X | \cos(X) | (\cos(X))\top | ||||||||||||||||
[6]
= | \operatorname{cofactor}(X)\top= | \mathbf | \mathbf^ | \operatorname{cofactor}(X)= | \mathbf | \left(\mathbf^\right)^\top | ||||||||||||
is not a function of |
= | X-1 | \left(X-1\right)\top | |||||||||||||||
, are not functions of |
= | \mathbf | \mathbf^ | \mathbf | \left(\mathbf^\right)^\top | |||||||||||||
is a positive integer |
= | n\left | \mathbf^n\right | \mathbf^ | n\left | \mathbf^n\right | \left(\mathbf^\right)^\top | |||||||||||
(see pseudo-inverse) |
= | 2X+ | 2\left(X+\right)\top | |||||||||||||||
(see pseudo-inverse) |
= | -2X | -2X\top | |||||||||||||||
is not a function of, is square and invertible |
= | 2\left | \mathbf\mathbf\mathbf\right | \mathbf^ = 2\left | \mathbf\right | \mathbf | \mathbf | \mathbf^ | 2\left | \mathbf\mathbf\mathbf\right | \left(\mathbf^\right)^\top | |||||||
is not a function of, is non-square, is symmetric |
= | 2\left | \mathbf\mathbf\mathbf\right | \left(\mathbf\right)^\mathbf | 2\left | \mathbf\mathbf\mathbf\right | \mathbf\left(\mathbf\right)^ | |||||||||||
is not a function of, is non-square, is non-symmetric |
= | \begin{align} \left | \mathbf\mathbf\mathbf\right | \Big(&\left(\mathbf\right)^\mathbf + \\ &\left(\mathbf\right)^\mathbf\Big)\end | \begin{align} \left | \mathbf\mathbf\mathbf\right | \Big(&\mathbf\left(\mathbf\right)^ + \\ &\mathbf\left(\mathbf\right)^\Big)\end |
Expression | Numerator layout, i.e. by | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
= |
| |||||||||||||||||||
, are not functions of x, |
= |
B | ||||||||||||||||||
, |
= |
+
| ||||||||||||||||||
, |
= |
+
V | ||||||||||||||||||
, |
= | U ⊗
+
⊗ V | ||||||||||||||||||
, |
= | U\circ
+
\circV | ||||||||||||||||||
= | -U-1
U-1 | |||||||||||||||||||
= | U-1\left(
U-1
-
+
U-1
\right)U-1 | |||||||||||||||||||
is not a function of, is any polynomial with scalar coefficients, or any matrix function defined by an infinite polynomial series (e.g.,,,, etc.); is the equivalent scalar function, is its derivative, and is the corresponding matrix function |
= | Ag'(xA)=g'(xA)A | ||||||||||||||||||
is not a function of |
= | AexA=exAA |
See also: Derivative of the exponential map.
Expression | Any layout (assumes dot product ignores row vs. column layout) | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
= |
⋅
| |||||||||||
, |
= | u ⋅
+
⋅ v |
Expression | Consistent numerator layout, i.e. by and | Mixed layout, i.e. by and | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
= | \mathbf | \operatorname\left(\mathbf^\frac\right) | ||||||||||||||||
= | \operatorname{tr}\left(U-1
\right) | |||||||||||||||||
= | \left | \mathbf\right | \left[\operatorname{tr}\left(\mathbf{U}^{-1}\frac{\partial^2 \mathbf{U}}{\partial x^2}\right) + \operatorname{tr}^2\left(\mathbf{U}^{-1}\frac{\partial \mathbf{U}}{\partial x}\right) - \operatorname{tr}\left(\left(\mathbf{U}^{-1}\frac{\partial \mathbf{U}}{\partial x}\right)^2\right) \right] | |||||||||||||||
= | \operatorname{tr}\left(
\right) | \operatorname{tr}\left(\left(
\right)\top
\right) | ||||||||||||||||
is not a function of, is any polynomial with scalar coefficients, or any matrix function defined by an infinite polynomial series (e.g.,,,, etc.); is the equivalent scalar function, is its derivative, and is the corresponding matrix function. |
x}= | \operatorname{tr}\left(Ag'(xA)\right) | ||||||||||||||||
is not a function of |
xA\right)}{\partialx}= | \operatorname{tr}\left(AexA\right) |
It is often easier to work in differential form and then convert back to normal derivatives. This only works well using the numerator layout. In these rules, is a scalar.
d(\operatorname{tr}(X))= | \operatorname{tr}(dX) | ||||
d( | \mathbf | ) = | \mathbf | \operatorname\left(\mathbf^d\mathbf\right) = \operatorname(\operatorname(\mathbf)d\mathbf) | |
d(ln | \mathbf | ) = | \operatorname{tr}\left(X-1dX\right) |
A is not a function of | d(A)= | 0 | ||||||
a is not a function of | d(aX)= | adX | ||||||
d(X+Y)= | dX+dY | |||||||
d(XY)= | (dX)Y+X(dY) | |||||||
(Kronecker product) | d(X ⊗ Y)= | (dX) ⊗ Y+X ⊗ (dY) | ||||||
(Hadamard product) | d(X\circY)= | (dX)\circY+X\circ(dY) | ||||||
d\left(X\top\right)= | (dX)\top | |||||||
d\left(X-1\right)= | -X-1\left(dX\right)X-1 | |||||||
(conjugate transpose) | d\left(XH\right)= | (dX)H | ||||||
is a positive integer | d\left(Xn\right)= |
Xi(dX)Xn-i-1 | ||||||
d\left(eX\right)= |
eaX(dX)e(1-a)Xda | |||||||
d\left(log{X}\right)= |
(X+zI)-1(dX)(X+zI)-1dz | |||||||
X=\sumiλiPi PiPj=\deltaijPi is differentiable at every eigenvalue λi | d\left(f(X)\right)= | \sumijPi(dX)Pj\begin{cases} f'(λi)&λi=λj\\
&λi ≠ λj \end{cases} |
\deltaij
(Pk)ij=(Q)ik(Q-1)kj
X=Q\boldsymbol{Λ}Q-1
(\boldsymbol{Λ})ii=λi
f(X)
f(x)
To convert to normal derivative form, first convert it to one of the following canonical forms, and then use these identities:
dy=adx |
=a | ||||
dy=a\topdx |
=a\top | ||||
dy=\operatorname{tr}(AdX) |
=A | ||||
dy=adx |
=a | ||||
dy=Adx |
=A | ||||
dY=Adx |
=A |
Matrix differential calculus is used in statistics and econometrics, particularly for the statistical analysis of multivariate distributions, especially the multivariate normal distribution and other elliptical distributions.[10] [11] [12]
It is used in regression analysis to compute, for example, the ordinary least squares regression formula for the case of multiple explanatory variables.[13] It is also used in random matrices, statistical moments, local sensitivity and statistical diagnostics.[14] [15]
0
0
or, also