TITLE: Equivalent definitions of the trace of a Hilbert-Schmidt operator
QUESTION [6 upvotes]: I am currently reading the book Spectral Methods in Automorphic Forms, and Iwaniec defines the trace operator in a different way than I am accustomed to. Throughout, assume that everything converges spectacularly - that's not important here. 
In particular, if $K: F \times F \longrightarrow \mathbb{C}$ is a $C_0^\infty$ (that is, smooth and bounded) function and $L$ is the integral operator having $K$ as its kernel, i.e.
$$ (Lf)(z) = \int_F K(z,w)f(w) d w,$$
then Iwaniec defines the trace of $L$ as the integral across the diagonal, 
$$ \text{Tr} L = \int_F K(z,z)dz. \tag{1}$$
I'm familiar with the trace of a more generic (linear operator $A$ over a Hilbert space by
$$ \text{Tr} A = \sum_j \langle Ae_j, e_j \rangle,\tag{2}$$
where the $e_j$ form an orthonormal basis of functions. Do these definitions agree?  If we suppose in addition that the $e_j$ are eigenfunctions with eigenvalues $\lambda_j$, then I can see the equivalence in the following "wrong" way. Taking the spectral decomposition for $K(z,w)$,
$$K(z,w) = \sum_j \lambda_j e_j(z) \overline{e_j(w)},$$
then since the $e_j$ are orthonormal, we have that
$$\int_F K(z,z)dz = \sum_j \lambda_j \int_F e_j(z)\overline{e_j(z)}dz = \sum_j \lambda_j.$$
And Lidskii's Theorem says that
$$\text{Tr} A = \sum_j \lambda_j,$$
where $\text{Tr} A$ is as in $(2)$. So I can conclude that $(1)$ and $(2)$ should agree, but I would like to see in a more fundamental, less roundabout way that they do actually agree.

REPLY [3 votes]: We have the following:

Theorem. (Mercer) Let $X$ be a locally compact sequential topological space, $\mu$ a strictly positive finite measure on $X$ and $k : X \times X \to \mathbb C$ continuous, bounded and with $k(y,x) = \overline{k(x, y)}$. Then the associated bounded convolution operator $K : L^2(X) \to L^2(X)$ is self-adjoint and compact. Suppose that it is nonnegative. Let $(e_n)_{n \geq 1}$ be a $L^2$-orthonormal basis of eigenfunctions for $K$ with eigenvalues $(\lambda_n)_{n \geq 1}$, so that $e_i \in C_b^0(X, \mathbb C)$ when $\lambda_i > 0$. Then 
  $$k(x, y) = \sum_{n}\lambda_n e_n(x) \overline{e_n(y)}$$
  uniformly on sets of the form $L \times X$ and $X \times L$ with $L$ compact, and absolute for fixed $(x,y)$.

Mercer proved this for $X = [0,1]$: Functions of positive and negative type, and their connection the theory of integral equations, Phil. Trans. Roy. Soc. London (A) 209 (1909) 415–446. http://rsta.royalsocietypublishing.org/content/209/441-458/415 The proof is also in Werner, Funktionalanalysis, 8th edition, 2018, Satz VI.4.2.
The proof in the general case is the same.
In particular:

Corollary. Suppose in addition that $X$ is compact. Then $K$ is trace class and $\DeclareMathOperator{\Tr}{Tr}$
$$\Tr K = \int_X k(x, x) d\mu(x)$$

Proof. By integrating the above equality over the diagonal:
$$\begin{align*}
\infty > \int_{X} k(x, x) d \mu(x) &= \int_X \sum_{n}\lambda_n e_n(x) \overline{e_n(x)} d\mu(x) \\
&= \sum_{n} \lambda_n \int_X e_n(x) \overline{e_n(x)} d\mu(x) \\
&= \sum_n \lambda_n \\
&= \Tr K
\end{align*}$$
because the convergence of the series is uniform, hence $L^1$. $\square$
If $X$ is not compact, the corollary need not hold, c.f. Selberg's trace formula.