# Sylvester's formula

In matrix theory, Sylvester's formula or Sylvester's matrix theorem (named after J. J. Sylvester) or Lagrange−Sylvester interpolation expresses an analytic function f(A) of a matrix A as a polynomial in A, in terms of the eigenvalues and eigenvectors of A. It states that
    $f(A)=\sum _{i=1}^{k}f(\lambda _{i})~A_{i}~,$
where the λ$_i$ are the eigenvalues of A, and the matrices
    $A_{i}\equiv \prod _{j=1 \atop j\neq i}^{k}{\frac {1}{\lambda _{i}-\lambda _{j}}}\left(A-\lambda _{j}I\right)$
are the corresponding Frobenius covariants of A, which are (projection) matrix Lagrange polynomials of A.

## Conditions

Sylvester's formula applies for any diagonalizable matrix A with k distinct eigenvalues, λ$_1$, ..., λ$_k$, and any function f defined on some subset of the complex numbers such that f(A) is well defined. The last condition means that every eigenvalue λ$_i$ is in the domain of f, and that every eigenvalue λ$_i$ with multiplicity m$_i$ > 1 is in the interior of the domain, with f being (m$_i$ - 1) times differentiable at λ$_i$.$^{:Def.6.4}$

## Example

Consider the two-by-two matrix:
    $A={\begin{bmatrix}1&3\\4&2\end{bmatrix}}.$
This matrix has two eigenvalues, 5 and −2. Its Frobenius covariants are
    ${\begin{aligned}A_{1}&=c_{1}r_{1}={\begin{bmatrix}3\\4\end{bmatrix}}{\begin{bmatrix}{\frac {1}{7}}&{\frac {1}{7}}\end{bmatrix}}={\begin{bmatrix}{\frac {3}{7}}&{\frac {3}{7}}\\{\frac {4}{7}}&{\frac {4}{7}}\end{bmatrix}}={\frac {A+2I}{5-(-2)}}\\A_{2}&=c_{2}r_{2}={\begin{bmatrix}{\frac {1}{7}}\\-{\frac {1}{7}}\end{bmatrix}}{\begin{bmatrix}4&-3\end{bmatrix}}={\begin{bmatrix}{\frac {4}{7}}&-{\frac {3}{7}}\\-{\frac {4}{7}}&{\frac {3}{7}}\end{bmatrix}}={\frac {A-5I}{-2-5}}.\end{aligned}}$
Sylvester's formula then amounts to
    $f(A)=f(5)A_{1}+f(-2)A_{2}.\,$
For instance, if f is defined by f(x) = x$^{−1}$, then Sylvester's formula expresses the matrix inverse f(A) = A$^{−1}$ as
    ${\frac {1}{5}}{\begin{bmatrix}{\frac {3}{7}}&{\frac {3}{7}}\\{\frac {4}{7}}&{\frac {4}{7}}\end{bmatrix}}-{\frac {1}{2}}{\begin{bmatrix}{\frac {4}{7}}&-{\frac {3}{7}}\\-{\frac {4}{7}}&{\frac {3}{7}}\end{bmatrix}}={\begin{bmatrix}-0.2&0.3\\0.4&-0.1\end{bmatrix}}.$

## Generalization

Sylvester's formula is only valid for diagonalizable matrices; an extension due to Arthur Buchheim, based on Hermite interpolating polynomials, covers the general case:
    $f(A)=\sum _{i=1}^{s}\left[\sum _{j=0}^{n_{i}-1}{\frac {1}{j!}}\phi _{i}^{(j)}(\lambda _{i})\left(A-\lambda _{i}I\right)^{j}\prod _{j=1,j\neq i}^{s}\left(A-\lambda _{j}I\right)^{n_{j}}\right]$,
where $\phi _{i}(t):=f(t)/\prod _{j\neq i}\left(t-\lambda _{j}\right)^{n_{j}}$.
A concise form is further given by Hans Schwerdtfeger,
    $f(A)=\sum _{i=1}^{s}A_{i}\sum _{j=0}^{n_{i}-1}{\frac {f^{(j)}(\lambda _{i})}{j!}}(A-\lambda _{i}I)^{j}$,
where A$_i$ are the corresponding Frobenius covariants of A

## Special case

If a matrix A is both Hermitian and unitary, then it can only have eigenvalues of $\pm 1$, and therefore $A=A_{+}-A_{-}$, where $A_{+}$ is the projector onto the subspace with eigenvalue +1, and $A_{-}$ is the projector onto the subspace with eigenvalue $-1$; By the completeness of the eigenbasis, $A_{+}+A_{-}=I$. Therefore, for any analytic function f,
    ${\begin{aligned}f(\theta A)&=f(\theta )A_{+1}+f(-\theta )A_{-1}\\&=f(\theta ){\frac {I+A}{2}}+f(-\theta ){\frac {I-A}{2}}\\&={\frac {f(\theta )+f(-\theta )}{2}}I+{\frac {f(\theta )-f(-\theta )}{2}}A\\\end{aligned}}.$
In particular, $e^{i\theta A}=(\cos \theta )I+(i\sin \theta )A$ and $A=e^{i{\frac {\pi }{2}}(I-A)}=e^{-i{\frac {\pi }{2}}(I-A)}$.