Post · 20 min read· pp. 167–177

The Cauchy residue trick: spectral analysis made “easy”

In many areas of machine learning, statistics and signal processing, eigenvalue decompositions are commonly used, e.g., in principal component analysis, spectral clustering, convergence analysis of Markov chains, convergence analysis of optimization algorithms, low-rank inducing regularizers, community detection, seriation, etc.

Understanding how the spectral decomposition of a matrix changes as a function of a matrix is thus of primary importance, both algorithmically and theoretically. We thus need a perturbation analysis or more generally some differentiability properties for eigenvalues or eigenvectors [1], or any spectral function [2]. These properties can be obtained from many angles, but a generic tool can be used for all of these: it is a surprising and elegant application of Cauchy’s residue formula, which is due to Kato [3].

Before diving into spectral analysis, I will first present the Cauchy residue theorem and some nice applications in computing integrals that are needed in machine learning and kernel methods.

Cauchy residue formula

A function f:C→Cf : \mathbb{C} \to \mathbb{C} is said holomorphic in λ∈C\lambda \in \mathbb{C} with derivative f′(λ)∈Cf'(\lambda) \in \mathbb{C}, if is differentiable in λ\lambda, that is if f(z)−f(λ)z−λ\displaystyle \frac{f(z)-f(\lambda)}{z-\lambda} tends to f′(λ)f'(\lambda) when zz tends to λ\lambda. Many classical functions are holomorphic on C\mathbb{C} or portions thereof, such as the exponential, sines, cosines and their hyperbolic counterparts, rational functions, portions of the logarithm.

We consider a function which is holomorphic in a region of C\mathbb{C} except in mm values λ1,…,λm∈C\lambda_1,\dots,\lambda_m \in \mathbb{C}, which are usually referred to as poles. We also consider a simple closed directed contour γ\gamma in C\mathbb{C} that goes strictly around the mm values above.

The Cauchy residue formula gives an explicit formula for the contour integral along γ\gamma:

∮γf(z)dz=2iπ∑j=1mRes(f,λj),(1)\oint_\gamma f(z) dz = 2 i \pi \sum_{j=1}^m {\rm Res}(f,\lambda_j), \tag{1}
where Res(f,λ){\rm Res}(f,\lambda) is called the residue of ff at λ\lambda . If around λ\lambda, f(z)f(z) has a series expansions in powers of (z−λ)(z − \lambda), that is, f(z)=∑k=−∞+∞ak(z−λ)k\displaystyle f(z) = \sum_{k=-\infty}^{+\infty}a_k (z −\lambda)^k, then Res(f,λ)=a−1{\rm Res}(f,\lambda)=a_{-1}.

For example, if f(z)=g(z)z−λ\displaystyle f(z) = \frac{g(z)}{z-\lambda} with gg holomorphic around λ\lambda, then Res(f,λ)=g(λ){\rm Res}(f,\lambda) = g(\lambda), and more generally, if f(z)=g(z)(z−λ)k\displaystyle f(z) = \frac{g(z)}{(z-\lambda)^k} for k⩾1k \geqslant 1, then Res(f,λ)=g(k−1)(λ)(k−1)!\displaystyle {\rm Res}(f,\lambda) = \frac{g^{(k-1)}(\lambda) }{(k-1)!}. For more details on complex analysis, see [4].

The result above can be naturally extended to vector-valued functions (and thus to any matrix-valued function), by applying the identity to all components of the vector.

This result is due to Cauchy [10] in 1825. The original paper where this is presented is a nice read in French where you can find some pepits like “la fonction s’évanouit pour x=∞x = \infty”.

If you are already familiar with complex residues, you can skip the next section.

Where does it come from?

At first, the formula in Eq. (1) seems unsettling. Why doesn’t the result depend more explicitly on the contour γ\gamma? Where does the multiplicative term 2iπ{2i\pi} come from? Here is a very partial and non rigorous account (go to the experts for more rigor!).

Complex-valued functions on C\mathbb{C} can be seen as functions from R2\mathbb{R}^2 to itself, by writing

f(x+iy)=u(x,y)+iv(x,y),f(x+iy) = u(x,y) + i v(x,y),
where uu and vv are real-valued functions. We have thus a function (x,y)↦(u(x,y),v(x,y))(x,y) \mapsto (u(x,y),v(x,y)) from R2\mathbb{R}^2 to R2\mathbb{R}^2. Expanding f(z+dz)=f(z)+f′(z)dzf(z+dz) = f(z) + f'(z) dz, which is the definition of complex differentiability, into real and imaginary parts, we get (using i2=−1i^2 = -1):
{u(x+dx,y+dy)=u(x,y)+Re(f′(z))dx –Im(f′(z))dyv(x+dx,y+dy)=v(x,y)+Re(f′(z))dy+Im(f′(z))dx.\left\{ \begin{array}{l} u(x+dx,y+dy) = u(x,y) + {\rm Re}(f'(z)) dx\ – {\rm Im}(f'(z)) dy \\ v(x+dx,y+dy) = v(x,y) + {\rm Re}(f'(z)) dy + {\rm Im}(f'(z)) dx. \end{array}\right.
This leads to
{∂u∂x(x,y)=Re(f′(z))∂u∂y(x,y)= –Im(f′(z))∂v∂x(x,y)=Im(f′(z))∂v∂y(x,y)=Re(f′(z)).\left\{ \begin{array}{l} \displaystyle \frac{\partial u}{\partial x}(x,y) = {\rm Re}(f'(z)) \\ \displaystyle \frac{\partial u}{\partial y}(x,y) = \ – {\rm Im}(f'(z)) \\ \displaystyle \frac{\partial v}{\partial x}(x,y) = {\rm Im}(f'(z)) \\ \displaystyle \frac{\partial v}{\partial y}(x,y) = {\rm Re}(f'(z)). \end{array}\right.

This in turn leads to the Cauchy-Riemann equations ∂u∂x=∂v∂y\displaystyle \frac{\partial u}{\partial x} = \frac{\partial v}{\partial y} and ∂u∂y=−∂v∂x\displaystyle \frac{\partial u}{\partial y} = -\frac{\partial v}{\partial x}, which are essentially necessary and sufficient conditions to be holomorphic. Thus holomorphic functions correspond to differentiable functions on R2\mathbb{R}^2 with some equal partial derivatives. These equations are key to obtaining the Cauchy residue formula.

Contour integral with no poles. We first consider a contour integral over a contour γ\gamma enclosing a region D\mathcal{D} where the function ff is holomorphic everywhere. The contour γ\gamma is defined as a differentiable function γ:[0,1]→C\gamma: [0,1] \to \mathbb{C}, and the integral is equal to

∮γf(z)dz=∫01 ⁣ ⁣f(γ(t))γ′(t)dt=∫01 ⁣ ⁣[u(x(t),y(t))+iv(x(t),y(t))][x′(t)+iy′(t)]dt,\oint_\gamma f(z) dz = \int_0^1 \!\!f(\gamma(t)) \gamma'(t) dt = \int_0^1 \!\![u(x(t),y(t)) +i v(x(t),y(t))] [ x'(t) + i y'(t)] dt,
where x(t)=Re(γ(t))x(t) = {\rm Re}(\gamma(t)) and y(t)=Im(γ(t))y(t) = {\rm Im}(\gamma(t)). By expanding the product of complex numbers, it is thus equal to
∫01[u(x(t),y(t))x′(t) –v(x(t),y(t))y′(t)]dt+i∫01[v(x(t),y(t))x′(t)+u(x(t),y(t))y′(t)]dt,\int_0^1 [ u(x(t),y(t)) x'(t) \ – v(x(t),y(t))y'(t)] dt +i \int_0^1 [ v(x(t),y(t)) x'(t) +u (x(t),y(t))y'(t)] dt,
which we can rewrite in compact form as (with dx=x′(t)dtdx = x'(t) dt and dy=y′(t)dtdy = y'(t)dt):
∮γ(u dx –v dy)+i∮γ(v dx+u dy).\oint_\gamma ( u \, dx\ – v \, dy ) + i \oint_\gamma ( v \, dx + u \, dy ).
We can then use Green’s theorem because our functions are differentiable on the entire region D\mathcal{D} (the set “inside” the contour), to get
∮γ(u dx –v dy)+i∮γ(v dx+u dy)= –∫ ⁣ ⁣ ⁣ ⁣∫D ⁣(∂v∂x+∂u∂y)dxdy –i ⁣ ⁣∫ ⁣ ⁣ ⁣ ⁣∫D ⁣(∂u∂x–∂v∂y)dxdy.\oint_\gamma ( u \, dx\ – v \, dy ) + i \oint_\gamma ( v \, dx + u \, dy ) =\ – \int\!\!\!\!\int_\mathcal{D} \! \Big( \frac{\partial v}{\partial x} + \frac{\partial u}{\partial y} \Big) dx dy \ – i \!\! \int\!\!\!\!\int_\mathcal{D} \!\Big( \frac{\partial u}{\partial x} – \frac{\partial v}{\partial y} \Big) dx dy.
Thus, because of the Cauchy-Riemann equations, the contour integral is always zero within the domain of differentiability of ff. Note that this extends to piecewise smooth contours γ\gamma.

Circle and rational functions. For a circle contour of center λ∈C\lambda \in \mathbb{C} and radius rr, we have, with γ(t)=λ+re2iπt\gamma(t) = \lambda + re^{ 2i \pi t}:

∮γdz(z−λ)k=∫012riπe2iπtrke2iπktdt=∫01r1−kie2iπ(1−k)tdt,\oint_{\gamma} \frac{dz}{(z-\lambda)^k} =\int_0^{1} \frac{ 2r i \pi e^{2i\pi t}}{ r^k e^{2i\pi kt}}dt= \int_0^{1} r^{1-k} i e^{2i\pi (1-k)t} dt,
which is equal to zero if k≠1k \neq 1, and to ∫012iπdt=2iπ\int_0^{1} 2i\pi dt = 2 i \pi for k=1k =1. Thus, for a function with a series expansion, the Cauchy residue formula is true for the circle around a single pole, because only the term in 1z−λ\frac{1}{z-\lambda} contributes.

No dependence on the contour. Now that the Cauchy formula is true for the circle around a single pole, we can “deform” the contour below to a circle.

This can be done considering two contours γ1\gamma_1 and γ2\gamma_2 below with no poles inside, and thus with zero contour integrals, and for which the integrals along the added lines cancel.

This “shows” that the integral does not depend on the contour, and so in applications we can be quite liberal in the choice of contour. Note that similar constructions can be used to take into account several poles.

Before going to the spectral analysis of matrices, let us explore some cool choices of contours and integrands, and (again!) some positive definite kernels.

Classical examples

The Cauchy residue theorem can be used to compute integrals, by choosing the appropriate contour, looking for poles and computing the associated residues. Here are classical examples, before I show applications to kernel methods. See more examples in http://residuetheorem.com/, and many in [11].

Fourier transforms. For ω>0\omega>0, we can compute ∫−∞∞ ⁣ ⁣f(x)eiωxdx\displaystyle \int_{-\infty}^\infty \!\! f(x) e^{ i \omega x} dx for holomorphic functions ff by integrating on the real line and a big upper circle as shown below, with RR tending to infinity (so that the contribution of the half-circle goes to zero because of the exponential term). This leads to 2iπ2i \pi times the sum of all residues of the function z↦f(z)eiωzz \mapsto f(z) e^{ i \omega z} in the upper half plane. See an example below related to kernel methods.

Trigonometric integrals. For holomorphic functions QQ, we can compute the integral ∫02π ⁣ ⁣ ⁣Q(cos⁡θ,sin⁡θ)dθ\displaystyle \int_0^{2\pi} \!\!\! Q(\cos \theta, \sin \theta) d\theta. Indeed, letting f(z)=1izQ(z+z−12,z−z−12i)f(z) = \frac{1}{iz} Q\big( \frac{z+z^{-1}}{2}, \frac{z-z^{-1}}{2i} \big), it is exactly equal to the integral on the unit circle. The desired integral is then equal to 2iπ2i\pi times the sum of all residues of ff within the unit disk.

For example, when Q(cos⁡θ,sin⁡θ)=12+sin⁡θQ(\cos \theta, \sin \theta) = \frac{1}{2 + \sin \theta}, we have f(z)=2z2+4iz−1f(z) = \frac{2}{z^2+4iz-1}, with a single pole inside the unit circle, namely λ=i(3−2)\lambda = i ( \sqrt{3}-2), and residue equal to −i/3-i / \sqrt{3}, leading to ∫02πdθ2+sin⁡θ=2π3\int_0^{2\pi} \frac{d\theta}{2+\sin \theta} = \frac{2\pi}{\sqrt{3}}.

Series. If the function ff is holomorphic and has no poles at integer real values, and satisfies some basic boundedness conditions, then

∑n∈Zf(n)= – ⁣ ⁣ ⁣∑λ∈poles(f)Res(f(z)πcos⁡πzsin⁡πz,λ).\sum_{n \in \mathbb{Z}} f(n) = \ – \!\!\! \sum_{ \lambda \in {\rm poles}(f)} {\rm Res}\big( f(z) \pi \frac{\cos \pi z}{\sin \pi z} ,\lambda\big).
This is a simple consequence of the fact that the function z↦πcos⁡πzsin⁡πzz \mapsto \pi \frac{\cos \pi z}{\sin \pi z} has all integers n∈Zn \in \mathbb{Z} as poles, with corresponding residue equal to 11. This is obtained from the contour below with mm tending to infinity.

The same trick can be applied to ∑n∈Z(−1)nf(n)= – ⁣ ⁣ ⁣∑λ∈poles(f)Res(f(z)π1sin⁡πz,λ).\displaystyle \sum_{n \in \mathbb{Z}} (-1)^n f(n) =\ – \!\!\! \sum_{ \lambda \in {\rm poles}(f)} {\rm Res}\big( f(z) \pi \frac{1}{\sin \pi z} ,\lambda\big). See [7, Section 11.2] for more details. Experts will see an interesting link with the Euler-MacLaurin formula and Bernoulli polynomials.

Applications to kernel methods. In non-parametric estimation, regularization penalties are used to constrain real-values functions to be smooth. One such examples are combinations of squared L2L_2 norms of derivatives. For functions ff defined on an interval II of the real line, penalties are typically of the form ∫I∑k=0sαk∣f(k)(x)∣2dx\int_I \sum_{k=0}^s \alpha_k | f^{(k)}(x)|^2 dx, for non-negative weights α0,…,αk\alpha_0,\dots,\alpha_k. For these Sobolev space norms, a positive definite kernel KK can be used for estimation (see, e.g., last month blog post).

A classical question is: given the norm defined above, how to compute KK? For I=RI = \mathbb{R}, then this can be done using Fourier transforms as:

K(x,y)=12π∫Reiω(x−y)∑k=0sαkω2kdω.K(x,y) = \frac{1}{2\pi} \int_\mathbb{R} \frac{e^{i\omega(x-y)}}{\sum_{k=0}^s \alpha_k \omega^{2k}} d\omega.
This is exactly an integral of the form above, for which we can use the contour integration technique. For example, for α0=1\alpha_0=1 and α1=a2\alpha_1=a^2, we get for x−y>0x-y>0, one pole i/ai/a in the upper half plane for the function 11+a2z2=1(1+iaz)(1−iaz)\frac{1}{1+a^2 z^2} = \frac{1}{(1+iaz)(1-iaz)}, with residue −i2ae−(x−y)/a-\frac{i}{2a} e^{-(x-y)/a}, leading to the familiar exponential kernel K(x,y)=12ae−∣x−y∣/aK(x,y) = \frac{1}{2a} e^{-|x-y|/a}. More complex kernels can be considered (see, e.g., [8, page 277], for ∑k=0sαkω2k=1+ω2s\sum_{k=0}^s \alpha_k \omega^{2k} = 1 + \omega^{2s}).

We can also consider the same penalty on the unit interval [0,1][0,1] with periodic functions, leading to the kernel (see [9] for more details):

K(x,y)=∑n∈Ze2inπ(x−y)∑k=0sαk(2nπ)s.K(x,y) = \sum_{n \in \mathbb{Z}} \frac{ e^{2in\pi(x-y)}}{\sum_{k=0}^s \alpha_k( 2n\pi)^s}.
For the same example as above, that is, α0=1\alpha_0=1 and α1=a2\alpha_1=a^2, this leads to an infinite series on which we can apply the Cauchy residue formula as explained above. This leads to, for x−y∈[0,1/2]x-y \in [0,1/2], K(x,y)=12acosh⁡(1−2(x−y)2a)sinh⁡(12a)K(x,y) = \frac{1}{2a} \frac{ \cosh (\frac{1-2(x-y)}{2a})}{\sinh (\frac{1}{2a})}. We can then extend by 11-periodicity and parity to all x−yx-y. See the detailed computation at the end of the post.

Now that you are all experts in residue calculus, we can move on to spectral analysis.

Spectral analysis of symmetric matrices

We consider a symmetric matrix A∈Rn×nA \in \mathbb{R}^{n \times n}, with its nn ordered real eigenvalues λ1⩾⋯⩾λn\lambda_1 \geqslant \cdots \geqslant \lambda_n, counted with their orders of multiplicity, and an orthonormal basis of their eigenvectors uj∈Rnu_j \in \mathbb{R}^n, j=1,…,nj=1,\dots,n. We have A=∑j=1nλjujuj⊤A = \sum_{j=1}^n \lambda_j u_j u_j^\top. When we consider eigenvalues as functions of AA, we use the notation λj(A)\lambda_j(A), j=1,…,nj=1,\dots,n. These functions are always well-defined even when eigenvalues are multiple (this is not the case for eigenvectors because of the invariance by orthogonal transformations).

The key property that we will use below is that we can express the so-called resolvent matrix (zI–A)−1∈Cn×n(z I – A)^{-1} \in \mathbb{C}^{n \times n}, for z∈Cz \in \mathbb{C}, as:

(zI−A)−1=∑j=1n1z−λjujuj⊤.(z I- A)^{-1} = \sum_{j=1}^n \frac{1}{z-\lambda_j} u_j u_j^\top.
The dependence on zz of the form 1z−λj\displaystyle \frac{1}{z- \lambda_j} leads to a nice application of Cauchy residue formula.

Assuming the kk-th eigenvalue λk\lambda_k is simple, we consider the contour γ\gamma going strictly around λk\lambda_k like below (for k=5k=5).

We consider integrating the matrix above, which leads to:

∮γ(zI−A)−1dz=∑j=1m(∮γ1z–λjdz)ujuj⊤=2iπ ukuk⊤\oint_\gamma (z I- A)^{-1} dz = \sum_{j=1}^m \Big( \oint_\gamma \frac{1}{z – \lambda_j} dz \Big) u_j u_j^\top = 2 i \pi \ u_k u_k^\top
using the identity ∮γ1z–λjdz=1\displaystyle \oint_\gamma \frac{1}{z – \lambda_j} dz = 1 if j=kj=k and 00 otherwise (because the pole is outside of γ\gamma). We thus obtain an expression for projectors on the one-dimensional eigen-subspace associated with the eigenvalue λk\lambda_k.

With simple manipulations, we can also access the eigenvalues. Indeed, we have:

∮γ(zI−A)−1zdz=∑j=1m(∮γzz–λjdz)ujuj⊤=2iπλkukuk⊤,\oint_\gamma (z I- A)^{-1} z dz = \sum_{j=1}^m \Big( \oint_\gamma \frac{z}{z – \lambda_j} dz \Big) u_j u_j^\top = 2 i \pi \lambda_k u_k u_k^\top,
and by taking the trace, we obtain
∮γtr[z(zI−A)−1]dz=λk.\oint_\gamma {\rm tr} \big[ z (z I- A)^{-1} \big] dz = \lambda_k.
The key benefit of these representations is that when the matrix AA is slightly perturbed, then the same contour γ\gamma can be used to enclose the corresponding eigenvalues of the perturbed matrix, and perturbation results are simply obtained by taking gradients within the contour integral. Note that several eigenvalues may be summed up by selecting a contour englobing more than one eigenvalues.

Gradients of eigenvalues

The expression with contour integrals allows to derive simple formulas for gradients of eigenvalues. These can be obtained by other means [5], but using contour integrals shows that this is simply done by looking at the differential of (zI–A)−1(z I – A)^{-1} and integrating it. The central component is the following expansion, which is a classical result in matrix differentiable calculus, with ∥Δ∥2\|\Delta\|_2 the operator norm of Δ\Delta (i.e., its largest singular value):

(zI−A–Δ)−1=(zI–A)−1+(zI−A)−1Δ(zI−A)−1+o(∥Δ∥2).(z I- A – \Delta)^{-1} = (z I – A)^{-1} + (z I- A)^{-1} \Delta (z I- A)^{-1} + o(\| \Delta\|_2).
Note here that the asymptotic remainder o(∥Δ∥2)o(\| \Delta\|_2) can be made explicit.

By expanding the expression on the basis of eigenvectors of AA, we get

z(zI−A–Δ)−1–z(zI−A)−1=∑j=1n∑ℓ=1nujuℓ⊤z⋅uj⊤Δuℓ(z−λj)(z−λℓ)+o(∥Δ∥2).z (z I- A – \Delta)^{-1} – z (z I- A)^{-1} = \sum_{j=1}^n \sum_{\ell=1}^n u_j u_\ell^\top \frac{ z \cdot u_j^\top \Delta u_\ell}{(z-\lambda_j)(z-\lambda_\ell)} + o(\| \Delta \|_2).
Taking the trace, the cross-product terms tr(ujuℓ⊤)=uℓ⊤uj{\rm tr}(u_j u_\ell^\top) = u_\ell^\top u_j disappear for j≠ℓj \neq \ell, and we get:
tr[z(zI–A–Δ)−1]–tr[z(zI–A)−1]=∑j=1nz⋅uj⊤Δuj(z−λj)2+o(∥Δ∥2).{\rm tr} \big[ z (z I – A – \Delta)^{-1} \big] – {\rm tr} \big[ z (z I – A)^{-1} \big]= \sum_{j=1}^n \frac{ z \cdot u_j^\top \Delta u_j}{(z-\lambda_j)^2} + o(\| \Delta \|_2).
This leads to, by contour integration:
λk(A+Δ)−λk(A)=12iπ∮γ[∑j=1nz⋅uj⊤Δuj(z−λj)2]dz+o(∥Δ∥2).\lambda_{k}(A+\Delta) -\lambda_k(A) = \frac{1}{2i \pi} \oint_\gamma \Big[ \sum_{j=1}^n \frac{ z \cdot u_j^\top \Delta u_j}{(z-\lambda_j)^2} \Big] dz + o(\| \Delta \|_2).
By keeping only the pole λk\lambda_k which is inside the contour γ\gamma, we get
λk(A+Δ)−λk(A)=12iπ∮γ[z⋅uk⊤Δuk(z−λk)2]dz+o(∣Δ∣2) =uk⊤Δuk+o(∥Δ∥2),\lambda_{k}(A+\Delta) -\lambda_k(A) = \frac{1}{2i \pi} \oint_\gamma \Big[ \frac{ z \cdot u_k^\top \Delta u_k}{(z-\lambda_k)^2} \Big] dz + o(| \Delta |_2) \ = u_k^\top \Delta u_k + o(\| \Delta \|_2),
using the identity ∮γzdz(z–λk)2dz=∮γ(λk(z–λk)2+1z–λk)dz=1\displaystyle \oint_\gamma \frac{z dz}{(z – \lambda_k)^2} dz = \oint_\gamma \Big( \frac{\lambda_k}{(z – \lambda_k)^2} + \frac{1}{z – \lambda_k} \Big) dz = 1.

Thus the gradient of λk\lambda_k at a matrix AA where the kk-th eigenvalue is simple is simply ukuk⊤u_k u_k^\top, where uku_k is a corresponding eigenvector. Note that this result can be simply obtained by the simple (rough) calculation: if xx is a unit eigenvector of AA, then Ax=λxAx =\lambda x, and x⊤x=1x^\top x = 1, leading to x⊤dx=0x^\top dx = 0 and dA x+Adx=dλ x+λdxdA\ x + A dx = d\lambda \ x + \lambda dx, and by taking the dot product with xx, dλ=x⊤dA x+x⊤Adx=x⊤dA x+λx⊤dx=x⊤dA xd\lambda = x^\top dA\ x + x^\top A dx = x^\top dA \ x + \lambda x^\top dx = x^\top dA \ x, which is the same result. However, this reasoning is more cumbersome, and does not lead to neat approximation guarantees, in particular in the extensions below.

Other perturbation results

Given the gradient, other more classical perturbation results could de derived, such as Hessians of eigenvalues, or gradient of the projectors ukuk⊤u_k u_k^\top. Here I derive a perturbation result for the projector Πk(A)=ukuk⊤\Pi_k(A)=u_k u_k^\top, when λk\lambda_k is a simple eigenvalue. Using the same technique as above, we get:

Πk(A+Δ) –Πk(A)=12iπ∮γ(zI−A)−1Δ(zI–A)−1dz +o(∥Δ∥2),\Pi_k(A+\Delta )\ – \Pi_k(A) = \frac{1}{2i \pi} \oint_\gamma (z I- A)^{-1} \Delta (z I – A)^{-1}dz  + o(\| \Delta\|_2),
which we can expand to the basis of eigenvectors as
12iπ∮γ∑j=1n∑ℓ=1nujuj⊤Δuℓuℓ⊤  dz(z−λℓ)(z−λj) +o(∥Δ∥2).\frac{1}{2i \pi} \oint_\gamma \sum_{j=1}^n \sum_{\ell=1}^n u_j u_j^\top \Delta u_\ell u_\ell^\top \frac{  dz}{(z-\lambda_\ell) (z-\lambda_j)  } + o(\| \Delta\|_2).
We can then split in two, with the two terms (all others are equal to zero by lack of poles within γ\gamma):
12iπ∮γ∑j≠k uj⊤Δuk (ujuk⊤+ukuj⊤)  dz(z−λk)(z−λj) =∑j≠k uj⊤Δuk (ujuk⊤+ukuj⊤)1λk–λj\frac{1}{2i \pi} \oint_\gamma \sum_{j \neq k}  u_j^\top \Delta u_k  ( u_j u_k^\top + u_k u_j^\top)   \frac{  dz}{(z-\lambda_k) (z-\lambda_j)  }= \sum_{j \neq k}  u_j^\top \Delta u_k  ( u_j u_k^\top + u_k u_j^\top) \frac{1}{\lambda_k – \lambda_j}
and
12iπ∮γ uk⊤Δuk ukuk⊤  dz(z−λk)2  =0,\frac{1}{2i \pi} \oint_\gamma   u_k^\top \Delta u_k   u_k u_k^\top  \frac{  dz}{(z-\lambda_k)^2  } = 0 ,
finally leading to
Πk(A+Δ) –Πk(A)=∑j≠k uj⊤Δukλk–λj  (ujuk⊤+ukuj⊤)  +o(∥Δ∥2),\Pi_k(A+\Delta ) \ – \Pi_k(A) = \sum_{j \neq k}  \frac{u_j^\top \Delta u_k}{\lambda_k – \lambda_j}    ( u_j u_k^\top + u_k u_j^\top)    + o(\| \Delta\|_2),
from which we can compute the Jacobian of Πk\Pi_k.

Spectral functions

Spectral functions are functions on symmetric matrices defined as F(A)=∑k=1nf(λk(A))F(A) = \sum_{k=1}^n f(\lambda_k(A)), for any real-valued function ff. For f(x)=xf(x) = x, we get back the trace, for f(x)=log⁡xf(x) = \log x we get back the log determinant, and so on. The function FF can be represented as

F(A)=∑k=1nf(λk(A))=12iπ∮γf(z)tr[(zI–A)−1]dz,F(A) = \sum_{k=1}^n f(\lambda_k(A)) = \frac{1}{2i \pi} \oint_\gamma f(z) {\rm tr} \big[ (z I – A)^{-1} \big] dz,
where the contour γ\gamma encloses all eigenvalues (as shown below).

This representation can be used to compute derivatives of FF, by simple derivations, to obtain the same result as [12].

Singular values of rectangular matrices

Singular value decompositions are also often used, for a rectangular matrix W∈Rn×dW \in \mathbb{R}^{n \times d}. It consists in finding rr pairs (uj,vj)∈Rn×Rd(u_j,v_j) \in \mathbb{R}^{n} \times \mathbb{R}^d, j=1,…,rj=1,\dots,r, of singular vectors and rr positive singular values σ1⩾⋯⩾σr>0\sigma_1 \geqslant \cdots \geqslant \sigma_r > 0 such that W=∑j=1rσjujvj⊤W = \sum_{j=1}^r \sigma_j u_j v_j^\top and (u1,…,ur)(u_1,\dots,u_r) and (v1,…,vr)(v_1,\dots,v_r) are orthonormal families.

There are two natural ways to relate the singular value decomposition to the classical eigenvalue decomposition of a symmetric matrix, first through WW⊤WW^\top (or similarly W⊤WW^\top W). Here it is more direct to consider the so-called Jordan-Wielandt matrix, defined by blocks as

Wˉ=(0WW⊤0).\bar{W} = \left( \begin{array}{cc} 0 & W \\ W^\top & 0 \end{array} \right).
The matrix Wˉ\bar{W} is symmetric, and its non zero eigenvalues are +σi+\sigma_i and −σi-\sigma_i, i=1,…,ri=1,\dots,r, associated with the eigenvectors 12(uivi)\frac{1}{\sqrt{2}} \left( \begin{array}{cc}u_i \\ v_i \end{array} \right) and 12(ui−vi)\frac{1}{\sqrt{2}} \left( \begin{array}{cc}u_i \\ -v_i \end{array} \right).

All necessary results (derivatives of singular values σj\sigma_j, or projectors ujvj⊤u_j v_j^\top can be obtained from there); see more details, in, e.g., the appendix of [6].

Going beyond

In this post, I have shown various applications of the Cauchy residue formula, for computing integrals and for the spectral analysis of matrices. I have just scratched the surface of spectral analysis, and what I presented extends to many interesting situations, for example, to more general linear operators in infinite-dimensional spaces [3], or to the analysis fo the eigenvalue distribution of random matrices (see a nice and reasonably simple derivation of the semi-circular law from Terry Tao’s blog).

References

[1] Gilbert W. Stewart and Sun Ji-Huang. Matrix Perturbation Theory. Academic Press, 1990. [2] Adrian Stephen Lewis. Derivatives of spectral functions. Mathematics of Operations Research, 21(3):576–588, 1996. [3] Tosio Kato. Perturbation Theory for Linear Operators, volume 132. Springer, 2013. [4] Serge Lang. Complex Analysis, volume 103. Springer, 2013. [5] Jan R. Magnus. On differentiating eigenvalues and eigenvectors. Econometric Theory, 1(2):179–191, 1985. [6] Francis Bach. Consistency of trace norm minimization. Journal of Machine Learning Research, 9:1019-1048, 2008. [7] Joseph Bak, Donald J. Newman. Complex analysis. New York: Springer, 2010. [8] Alain Berlinet, and Christine Thomas-Agnan. Reproducing kernel Hilbert spaces in probability and statistics. Springer Science & Business Media, 2011. [9] Grace Wahba. Spline models for observational data. Society for Industrial and Applied Mathematics, 1990. [10] Augustin Louis Cauchy, Mémoire sur les intégrales définies, prises entre des limites imaginaires, 1825, re-published in Bulletin des Sciences Mathématiques et Astronomiques, Tome 7, 265-304, 1874. [11] Dragoslav S. Mitrinovic, and Jovan D. Keckic. The Cauchy method of residues: theory and applications. Vol. 9. Springer Science & Business Media, 1984. [12] Adrian S. Lewis, and Hristo S. Sendov. Twice differentiable spectral functions. SIAM Journal on Matrix Analysis and Applications 23.2: 368-386, 2001.

Computing the Sobolev kernel

The goal is to compute the infinite sum

∑n∈Ze2iπq⋅n1+(2aπn)2\sum_{n \in \mathbb{Z}} \frac{e^{2i\pi q \cdot n}}{1+(2a \pi n)^2}
for q∈(0,1/2)q \in (0,1/2). We consider the function
f(z)=eiπ(2q−1)z1+(2aπz)2πsin⁡(πz).f(z) = \frac{e^{i\pi (2q-1) z}}{1+(2a \pi z)^2} \frac{\pi}{\sin (\pi z)}.
It is holomorphic on C\mathbb{C} except at all integers n∈Zn \in \mathbb{Z}, where it has a simple pole with residue eiπ(2q−1)n1+(2aπn)2(−1)n=eiπ2qn1+(2aπn)2\displaystyle \frac{e^{i\pi (2q-1) n}}{1+(2a \pi n)^2} (-1)^n = \frac{e^{i\pi 2q n}}{1+(2a \pi n)^2}, at z=i/(2aπ)z = i/(2a\pi) where it has a residue equal to e–(2q−1)/(2a)4iaππsin⁡(i/(2a))= –e–(2q−1)/(2a)4a1sinh⁡(1/(2a))\displaystyle \frac{e^{ – (2q-1)/(2a)}}{4ia\pi} \frac{\pi}{\sin (i/(2a))} = \ – \frac{e^{ – (2q-1)/(2a)}}{4a} \frac{1}{\sinh (1/(2a))}, and at z=−i/(2aπ)z = -i/(2a\pi) where it has a residue equal to e(2q−1)/(2a)4iaππsin⁡(i/(2a))= –e(2q−1)/(2a)4a1sinh⁡(1/(2a))\displaystyle \frac{e^{ (2q-1)/(2a)}}{4ia\pi} \frac{\pi}{\sin (i/(2a))} =\ – \frac{e^{ (2q-1)/(2a)}}{4a} \frac{1}{\sinh (1/(2a))}. With all residues summing to zero (note that this fact requires a precise analysis of limits when mm tends to infinity for the contour defined in the main text), we get:
∑n∈Ze2iπq⋅n1+(2aπn)2=e–(2q−1)/(2a)4a1sinh⁡(1/(2a))+e(2q−1)/(2a)4a1sinh⁡(1/(2a))=12acosh⁡(2q−12a)sinh⁡(12a).\sum_{n \in \mathbb{Z}} \frac{e^{2i\pi q \cdot n}}{1+(2a \pi n)^2} =\frac{e^{ – (2q-1)/(2a)}}{4a} \frac{1}{\sinh (1/(2a))}+ \frac{e^{ (2q-1)/(2a)}}{4a} \frac{1}{\sinh (1/(2a))} = \frac{1}{2a} \frac{ \cosh (\frac{2q-1}{2a})}{\sinh (\frac{1}{2a})}.