# Jacobi's formula

In matrix calculus, Jacobi's formula expresses the derivative of the determinant of a matrix A in terms of the adjugate of A and the derivative of A.
If A is a differentiable map from the real numbers to n × n matrices, then
    ${\frac {d}{dt}}\det A(t)=\operatorname {tr} \left(\operatorname {adj} (A(t))\,{\frac {dA(t)}{dt}}\right)=\left(\det A(t)\right)\cdot \operatorname {tr} \left(A(t)^{-1}\cdot \,{\frac {dA(t)}{dt}}\right)$
where tr(X) is the trace of the matrix X and $\operatorname {adj} (X)$ is its adjugate matrix. (The latter equality only holds if A(t) is invertible.)
As a special case,
    ${\partial \det(A) \over \partial A_{ij}}=\operatorname {adj} (A)_{ji}.$
Equivalently, if dA stands for the differential of A, the general formula is
    $d\det(A)=\operatorname {tr} (\operatorname {adj} (A)\,dA)=\det(A)\operatorname {tr} \left(A^{-1}dA\right)$
The formula is named after the mathematician Carl Gustav Jacob Jacobi.

## Derivation
### Via matrix computation

Theorem. (Jacobi's formula) For any differentiable map A from the real numbers to n × n matrices,
    $d\det(A)=\operatorname {tr} (\operatorname {adj} (A)\,dA).$
Proof. Laplace's formula for the determinant of a matrix A can be stated as
    $\det(A)=\sum _{j}A_{ij}\operatorname {adj} ^{\rm {T}}(A)_{ij}.$
Notice that the summation is performed over some arbitrary row i of the matrix.
The determinant of A can be considered to be a function of the elements of A:
    $\det(A)=F\,(A_{11},A_{12},\ldots ,A_{21},A_{22},\ldots ,A_{nn})$
so that, by the chain rule, its differential is
    $d\det(A)=\sum _{i}\sum _{j}{\partial F \over \partial A_{ij}}\,dA_{ij}.$
This summation is performed over all n×n elements of the matrix.
To find ∂F/∂A$_{ij}$ consider that on the right hand side of Laplace's formula, the index i can be chosen at will. (In order to optimize calculations: Any other choice would eventually yield the same result, but it could be much harder). In particular, it can be chosen to match the first index of ∂ / ∂A$_{ij}$:
    ${\partial \det(A) \over \partial A_{ij}}={\partial \sum _{k}A_{ik}\operatorname {adj} ^{\rm {T}}(A)_{ik} \over \partial A_{ij}}=\sum _{k}{\partial (A_{ik}\operatorname {adj} ^{\rm {T}}(A)_{ik}) \over \partial A_{ij}}$
Thus, by the product rule,
    ${\partial \det(A) \over \partial A_{ij}}=\sum _{k}{\partial A_{ik} \over \partial A_{ij}}\operatorname {adj} ^{\rm {T}}(A)_{ik}+\sum _{k}A_{ik}{\partial \operatorname {adj} ^{\rm {T}}(A)_{ik} \over \partial A_{ij}}.$
Now, if an element of a matrix A$_{ij}$ and a cofactor adj$^T$(A)$_{ik}$ of element A$_{ik}$ lie on the same row (or column), then the cofactor will not be a function of A$_{ij}$, because the cofactor of A$_{ik}$ is expressed in terms of elements not in its own row (nor column). Thus,
    ${\partial \operatorname {adj} ^{\rm {T}}(A)_{ik} \over \partial A_{ij}}=0,$
so
    ${\partial \det(A) \over \partial A_{ij}}=\sum _{k}\operatorname {adj} ^{\rm {T}}(A)_{ik}{\partial A_{ik} \over \partial A_{ij}}.$
All the elements of A are independent of each other, i.e.
    ${\partial A_{ik} \over \partial A_{ij}}=\delta _{jk},$
where δ is the Kronecker delta, so
    ${\partial \det(A) \over \partial A_{ij}}=\sum _{k}\operatorname {adj} ^{\rm {T}}(A)_{ik}\delta _{jk}=\operatorname {adj} ^{\rm {T}}(A)_{ij}.$
Therefore,
    $d(\det(A))=\sum _{i}\sum _{j}\operatorname {adj} ^{\rm {T}}(A)_{ij}\,dA_{ij}=\sum _{j}\sum _{i}\operatorname {adj} (A)_{ji}\,dA_{ij}=\sum _{j}(\operatorname {adj} (A)\,dA)_{jj}=\operatorname {tr} (\operatorname {adj} (A)\,dA).\ \square$

### Via chain rule

Lemma 1. $\det '(I)=\mathrm {tr}$, where $\det '$ is the differential of $\det$.
This equation means that the differential of $\det$, evaluated at the identity matrix, is equal to the trace. The differential $\det '(I)$ is a linear operator that maps an n × n matrix to a real number.
Proof. Using the definition of a directional derivative together with one of its basic properties for differentiable functions, we have
    $\det '(I)(T)=\nabla _{T}\det(I)=\lim _{\varepsilon \to 0}{\frac {\det(I+\varepsilon T)-\det I}{\varepsilon }}$
$\det(I+\varepsilon T)$ is a polynomial in $\varepsilon$ of order n. It is closely related to the characteristic polynomial of $T$. The constant term in that polynomial (the term with $\varepsilon =0$) is 1, while the linear term in $\varepsilon$ is $\mathrm {tr} \ T$.
Lemma 2. For an invertible matrix A, we have: $\det '(A)(T)=\det A\;\mathrm {tr} (A^{-1}T)$.
Proof. Consider the following function of X:
    $\det X=\det(AA^{-1}X)=\det(A)\ \det(A^{-1}X)$
We calculate the differential of $\det X$ and evaluate it at $X=A$ using Lemma 1, the equation above, and the chain rule:
    $\det '(A)(T)=\det A\ \det '(I)(A^{-1}T)=\det A\ \mathrm {tr} (A^{-1}T)$
Theorem. (Jacobi's formula) ${\frac {d}{dt}}\det A=\mathrm {tr} \left(\mathrm {adj} \ A{\frac {dA}{dt}}\right)$
Proof. If $A$ is invertible, by Lemma 2, with $T=dA/dt$
    ${\frac {d}{dt}}\det A=\det A\;\mathrm {tr} \left(A^{-1}{\frac {dA}{dt}}\right)=\mathrm {tr} \left(\mathrm {adj} \ A\;{\frac {dA}{dt}}\right)$
using the equation relating the adjugate of $A$ to $A^{-1}$. Now, the formula holds for all matrices, since the set of invertible linear matrices is dense in the space of matrices.

### Via diagonalization

Both sides of the Jacobi formula are polynomials in the matrix coefficients of A and A'. It is therefore sufficient to verify the polynomial identity on the dense subset where the eigenvalues of A are distinct and nonzero.
If A factors differentiably as $A=BC$, then
    $\mathrm {tr} (A^{-1}A')=\mathrm {tr} ((BC)^{-1}(BC)')=\mathrm {tr} (B^{-1}B')+\mathrm {tr} (C^{-1}C').$
In particular, if L is invertible, then $I=L^{-1}L$ and
    $0=\mathrm {tr} (I^{-1}I')=\mathrm {tr} (L(L^{-1})')+\mathrm {tr} (L^{-1}L').$
Since A has distinct eigenvalues, there exists a differentiable complex invertible matrix L such that $A=L^{-1}DL$ and D is diagonal. Then
    $\mathrm {tr} (A^{-1}A')=\mathrm {tr} (L(L^{-1})')+\mathrm {tr} (D^{-1}D')+\mathrm {tr} (L^{-1}L')=\mathrm {tr} (D^{-1}D').$
Let $\lambda _{i}$, $i=1,\ldots ,n$ be the eigenvalues of A. Then
    ${\frac {\det(A)'}{\det(A)}}=\sum _{i=1}^{n}\lambda _{i}'/\lambda _{i}=\mathrm {tr} (D^{-1}D')=\mathrm {tr} (A^{-1}A'),$
which is the Jacobi formula for matrices A with distinct nonzero eigenvalues.

## Corollary

The following is a useful relation connecting the trace to the determinant of the associated matrix exponential:
$\det e^{B}=e^{\operatorname {tr} \left(B\right)}$
This statement is clear for diagonal matrices, and a proof of the general claim follows.
For any invertible matrix $A(t)$, in the previous section "Via Chain Rule", we showed that
    ${\frac {d}{dt}}\det A(t)=\det A(t)\;\operatorname {tr} \left(A(t)^{-1}\,{\frac {d}{dt}}A(t)\right)$
Considering $A(t)=\exp(tB)$ in this equation yields:
    ${\frac {d}{dt}}\det e^{tB}=\operatorname {tr} (B)\det e^{tB}$
The desired result follows as the solution to this ordinary differential equation.

## Applications

Several forms of the formula underlie the Faddeev–LeVerrier algorithm for computing the characteristic polynomial, and explicit applications of the Cayley–Hamilton theorem. For example, starting from the following equation, which was proved above:
    ${\frac {d}{dt}}\det A(t)=\det A(t)\ \operatorname {tr} \left(A(t)^{-1}\,{\frac {d}{dt}}A(t)\right)$
and using $A(t)=tI-B$, we get:
    ${\frac {d}{dt}}\det(tI-B)=\det(tI-B)\operatorname {tr} [(tI-B)^{-1}]=\operatorname {tr} [\operatorname {adj} (tI-B)]$
where adj denotes the adjugate matrix.

## Remarks

* ↑ Magnus & Neudecker (1999, pp. 149–150), Part Three, Section 8.3