\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}
\usepackage{algorithm,algpseudocode}
\usepackage{bm}
\usepackage{hyperref}
\usepackage{float}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage{xcolor}
\definecolor{darkgreen}{rgb}{0.0, 0.5, 0.0}
\definecolor{aaltoBlue}{RGB}{0, 51, 102}
\definecolor{pinegreen}{cmyk}{0.92,0,0.59,0.25}
\definecolor{royalblue}{cmyk}{1,0.50,0,0}
\definecolor{lavander}{cmyk}{0,0.48,0,0}
\definecolor{violet}{cmyk}{0.79,0.88,0,0}
\definecolor{lightblue}{RGB}{173, 216, 230}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc,arrows.meta,positioning,fit,shapes.geometric,shapes.misc,intersections,patterns,decorations.pathreplacing,backgrounds,matrix}
\usepgfplotslibrary{fillbetween,groupplots}
\setcounter{secnumdepth}{-\maxdimen}
% Long unbreakable tokens (the ISO/IEC author names in citations, term names
% in the title) otherwise overflow the margin by a few points; a modest
% emergency stretch lets TeX loosen the paragraph instead.
\emergencystretch=2em
\usepackage{mleftright}
% Project macros used by this entry (auto-extracted).
\newcommand{\eigval}[1]{\lambda_{#1}}
\newcommand{\featuredim}{d}
\newcommand{\featureidx}{j}
\newcommand{\featuremtx}{\mX}
\newcommand{\mA}[0]{{\bf A}}
\newcommand{\mB}[0]{{\bf B}}
\newcommand{\mM}[0]{{\bf M}}
\newcommand{\mN}[0]{{\bf N}}
\newcommand{\mQ}{\mathbf{Q}}
\newcommand{\mS}{\mathbf{S}}
\newcommand{\mU}{\mathbf{U}}
\newcommand{\mX}[0]{{\bf X}}
\newcommand{\norm}[1]{\Vert  {#1} \Vert}
\newcommand{\reals}{\mathbb{R}}
\newcommand{\samplesize}{m}
\newcommand{\sphere}[1]{\mathbb{S}^{(#1)}}
\newcommand{\tr}[1]{{\rm tr} \left(#1\right)}
\newcommand{\vu}[0]{{\bf u}}
\newcommand{\vv}[0]{{\bf v}}
\newcommand{\vw}[0]{{\bf w}}
\newcommand{\vx}[0]{{\bf x}}

\begin{document}

\section{spectral decomposition}

\subsection*{Author and editors}
Alexander Jung\textsuperscript{*}, Department of Computer Science, Aalto University, Espoo, Finland (ORCID \mbox{\href{https://orcid.org/0000-0001-7538-0990}{0000-0001-7538-0990}}) \\
Editors: Konstantina Olioumtsevits (ORCID \mbox{\href{https://orcid.org/0000-0003-2697-8659}{0000-0003-2697-8659}}), Ekkehard Schnoor (ORCID \mbox{\href{https://orcid.org/0000-0001-8252-1499}{0000-0001-8252-1499}}), Aalto University, Espoo, Finland \\
\textsuperscript{*}Corresponding author: \href{mailto:alex.jung@aalto.fi}{alex.jung@aalto.fi}



\subsection{Abstract}
A spectral decomposition writes a symmetric matrix as a
		sum of orthogonal projections onto perpendicular lines, each
		scaled by a real eigenvalue. It is an eigenvalue decomposition (EVD) whose
		eigenvectors form an orthonormal basis, so the
		matrix is diagonal in a rotated coordinate system. A real
		matrix admits one exactly when it is symmetric, and over the
		complex numbers the corresponding class is the normal matrices.
		The decomposition follows from maximizing the quadratic form
		$\vx^{\top} \mA \vx$ over the unit sphere: a maximizer exists
		because the sphere is compact, symmetry makes it an
		eigenvector, and symmetry again makes the vectors
		orthogonal to it an invariant subspace, so the argument
		repeats one size down. The positive semi-definite (psd) property enters only at the
		end, where it amounts to every eigenvalue being nonnegative.
		The decomposition yields the spectral norm, the rank and
		the square root of a matrix, and it underlies
		principal component analysis (PCA), kernel methods and the convergence analysis of
		gradient descent (GD).

\subsection{Definition}
Stretching the plane by a
		factor $3$ along one line, and leaving a perpendicular line
		untouched, turns a circle into an ellipse with its axes along
		those two lines. One matrix that acts this way is
		\[
		\mA = \begin{pmatrix} 5/2 & \sqrt{3}/2 \\ \sqrt{3}/2 & 3/2
		\end{pmatrix} \text{,}
		\]
		whose two lines sit at $30^{\circ}$ and $120^{\circ}$
		(see Fig.~\ref{fig_spectraldecomp_ellipse}). A spectral
		decomposition states that every symmetric matrix acts this
		way, scaling each of $\featuredim$ perpendicular directions by
		its own real factor.
\par
		A spectral decomposition is an eigenvalue decomposition (EVD) whose eigenvectors
		are orthonormal. For a real symmetric matrix $\mA \in
		\reals^{\featuredim \times \featuredim}$ it reads
		\begin{equation}
		\label{eq:spectraldecomp}
		\mA = \mU {\bm \Lambda} \mU^{\top} =
		\sum_{\featureidx=1}^{\featuredim} \eigval{\featureidx}
		\vu^{(\featureidx)} \big( \vu^{(\featureidx)} \big)^{\top}
		\text{,}
		\end{equation}
		with an orthogonal matrix $\mU = \big( \vu^{(1)},
		\ldots, \vu^{(\featuredim)} \big)$ of eigenvectors and real
		eigenvalues $\eigval{1} \geq \cdots \geq
		\eigval{\featuredim}$ on the diagonal of ${\bm \Lambda}$. The
		converse holds as well, since $\mU {\bm \Lambda} \mU^{\top}$ equals
		its own transpose: a real matrix with an
		orthonormal basis of eigenvectors is symmetric.
		That equivalence is known as the spectral theorem
		(Axler, 2024, 7.29). Over the complex numbers the same
		statement holds for a normal matrix, with the
		conjugate transpose in place of the transpose and a
		unitary matrix in place of an orthogonal matrix, and
		the eigenvalues are real exactly when $\mA$ is
		Hermitian.
		\begin{figure}[H]
			\begin{center}
			\begin{tikzpicture}[scale=0.95, font=\small, >=Latex]
				\draw[black!30] (-3.4,0) -- (3.4,0);
				\draw[black!30] (0,-2.1) -- (0,2.1);
				\draw[dotted, black!55] (210:3.3) -- (30:3.3);
				\draw[dotted, black!55] (300:1.7) -- (120:1.7);
				\draw[dashed, black!60] (0,0) circle [radius=1];
				\draw[line width=1pt, rotate=30] (0,0)
					ellipse [x radius=3, y radius=1];
				\draw[->, line width=1.3pt] (0,0) -- (30:1);
				\draw[->, line width=1pt, black!55] (30:1.08) -- (30:2.96);
				\draw[->, line width=1.3pt] (0,0) -- (120:1);
				\node[font=\scriptsize] at (0.30,0.62) {$\vu^{(1)}$};
				\node[font=\scriptsize, anchor=south west] at (30:2.98)
					{$\mA \vu^{(1)} = 3 \vu^{(1)}$};
				\node[font=\scriptsize, anchor=south east] at (120:1.02)
					{$\vu^{(2)} = \mA \vu^{(2)}$};
				\fill (0,0) circle (1.5pt);
			\end{tikzpicture}
			\end{center}
		\caption{The matrix $\mA$ of the display above maps the
			dashed unit circle onto the solid ellipse. The dotted lines
			carry the two eigenvectors $\vu^{(1)}$ and
			$\vu^{(2)}$, at $30^{\circ}$ and $120^{\circ}$, and the
			ellipse has its axes along them with half-lengths
			$\eigval{1} = 3$ and $\eigval{2} = 1$. Neither direction is
			turned into another: $\mA$ stretches along $\vu^{(1)}$ and
			leaves $\vu^{(2)}$ where it is
			\label{fig_spectraldecomp_ellipse}}
		\end{figure}
		One derivation of the symmetric case rests on a single analytic
		fact and produces the eigenvectors instead of assuming that
		they exist. It starts from the quadratic form
		$\vx^{\top} \mA \vx$ restricted to the unit sphere
		$\sphere{\featuredim-1} = \big\{ \vx \in \reals^{\featuredim} :
		\norm{\vx} = 1 \big\}$, where it coincides with the Rayleigh
		quotient $\vx^{\top} \mA \vx / \vx^{\top} \vx$
		(Meyer, 2000, Sect.~7.5, Eq.~(7.5.4)). The sphere is
		closed and bounded, hence compact, and the quadratic form is
		continuous, so it attains a maximum on the sphere at
		some $\vu^{(1)}$ (Rudin, 1976, Thm.~4.16).
		Write $\eigval{1}$ for that maximum. This is the whole
		analytic input, and the remaining steps are algebra.
\par
		The maximizer is an eigenvector. Take a vector $\vv$ of
		unit norm orthogonal to $\vu^{(1)}$, so that the curve
		$\vx(t) = \big( \vu^{(1)} + t \vv \big) / \sqrt{1+t^{2}}$ stays on
		the sphere, and abbreviate $c = \big( \vu^{(1)} \big)^{\top} \mA
		\vv$ and $e = \vv^{\top} \mA \vv$. Along that curve the
		quadratic form is $f(t) = \big( \eigval{1} + 2tc + t^{2} e
		\big) / \big( 1 + t^{2} \big)$, a differentiable function with a
		maximum at $t = 0$, so $f'(0) = 2c = 0$. Symmetry enters
		here: $c = \big( \mA \vu^{(1)} \big)^{\top} \vv$, so the
		vector $\mA \vu^{(1)}$ is orthogonal to every vector
		orthogonal to $\vu^{(1)}$, and is therefore a multiple of
		$\vu^{(1)}$. Multiplying $\mA \vu^{(1)} = \lambda \vu^{(1)}$ by
		$\big( \vu^{(1)} \big)^{\top}$ identifies $\lambda = \eigval{1}$.
\par
		The argument then repeats on a smaller matrix. The
		subspace $\mathcal{W}$ of vectors orthogonal to
		$\vu^{(1)}$ is invariant under $\mA$, because $\big( \vu^{(1)}
		\big)^{\top} \mA \vw = \big( \mA \vu^{(1)} \big)^{\top} \vw =
		\eigval{1} \big( \vu^{(1)} \big)^{\top} \vw = 0$ for every $\vw
		\in \mathcal{W}$. Symmetry is used a second time, and this is where
		a general matrix fails: for $\mN = \big(
		\begin{smallmatrix} 0 & 1 \\ 0 & 0 \end{smallmatrix} \big)$ the
		eigenvector $(1,0)^{\top}$ spans an invariant line, yet
		$\mN (0,1)^{\top} = (1,0)^{\top}$ leaves the orthogonal
		complement, which is why a general matrix need not be
		diagonalizable at all. Collecting an orthonormal
		basis of $\mathcal{W}$ into a matrix $\mQ \in
		\reals^{\featuredim \times (\featuredim-1)}$ and setting $\mM =
		\mQ^{\top} \mA \mQ$ gives a symmetric matrix one size
		smaller, so induction supplies an orthonormal basis of
		its eigenvectors, and $\mQ$ lifts them back to
		eigenvectors of $\mA$ orthogonal to $\vu^{(1)}$. Each later
		maximum is taken over a smaller set, so the eigenvalues
		arrive in decreasing order.
\par
		Nonnegativity of the eigenvalues is a separate matter, and
		it is where the positive semi-definite (psd) property enters. Symmetry is an
		assumption rather than a consequence of $\vx^{\top} \mA \vx \geq
		0$: a skew-symmetric matrix $\mS$ with $\mS^{\top} = -\mS$
		satisfies $\vx^{\top} \mS \vx = 0$ for every $\vx$, so the
		quadratic form cannot see any skew part. For a
		symmetric matrix, expanding a vector in the
		eigenvector basis gives $\vx^{\top} \mA \vx =
		\sum_{\featureidx=1}^{\featuredim} \eigval{\featureidx} \big(
		\big( \vu^{(\featureidx)} \big)^{\top} \vx \big)^{2}$, which is
		nonnegative for every $\vx$ exactly when every eigenvalue
		is. Each $\vu^{(\featureidx)} \big( \vu^{(\featureidx)}
		\big)^{\top}$ in \eqref{eq:spectraldecomp} is the
		orthogonal projection onto a line, and these projections
		annihilate each other and sum to the identity, so a
		symmetric matrix resolves a vector along $\featuredim$
		perpendicular axes, scales each component, and adds the pieces
		back. The eigenvalues are determined by $\mA$, while
		individual eigenvectors are not when an eigenvalue
		repeats: any orthonormal basis of the corresponding
		subspace serves, and what is determined is the
		orthogonal projection onto that subspace.
\par
		Several quantities are immediate from
		\eqref{eq:spectraldecomp}. The spectral norm is
		$\eigval{1}$, by the same maximization the derivation started
		from, while $\tr{\mA}$ and $\det \mA$ are the sum and the product
		of the eigenvalues. The rank of $\mA$ counts the
		nonzero eigenvalues, and the eigenvectors belonging
		to the zero ones span the nullspace. A psd
		matrix has the square root
		$\mA^{1/2} = \sum_{\featureidx=1}^{\featuredim}
		\sqrt{\eigval{\featureidx}} \vu^{(\featureidx)} \big(
		\vu^{(\featureidx)} \big)^{\top}$, which is the one psd
		matrix squaring to $\mA$, so $\mA = \mB^{\top} \mB$ for
		$\mB = \mA^{1/2}$ (Axler, 2024, 7.39). Running
		the maximization over subspaces rather than one deflation
		at a time characterizes every eigenvalue the same
		variational way
		(Meyer, 2000, Sect.~7.5, Eq.~(7.5.5)).
\par
		Machine learning (ML) meets symmetric matrices wherever a
		quadratic form appears. The sample covariance matrix of a
		dataset is symmetric and psd, and principal component analysis (PCA) keeps the
		eigenvectors of its largest eigenvalues, so the
		variational step above is what makes the first principal direction
		the direction of largest variance. A kernel matrix
		is psd by construction, and its square root
		exhibits it as a Gram matrix of feature vectors, which is what
		lets a kernel method work without those feature vectors. The
		training objective of linear regression has the constant Hessian
		$(2/\samplesize) \featuremtx^{\top} \featuremtx$, whose
		eigenvalues decide how fast gradient descent (GD) converges, and the
		Laplacian matrix of an undirected graph is symmetric and psd,
		which is what spectral clustering decomposes.
\par
		Two remarks on scope. Replacing the transpose by the
		conjugate transpose carries the derivation verbatim to a
		Hermitian matrix, for which the quadratic form
		$\vx^{H} \mA \vx$ is real. In infinite dimensions the argument breaks at exactly
		one point, the existence of the maximizer, because the unit sphere
		of an infinite-dimensional Hilbert space is not compact;
		assuming instead that the operator is compact and self-adjoint
		restores that step and the rest of the derivation runs unchanged
		(Young, 1988).

\subsection{Cross References}
EVD, normal matrix, symmetric matrix, eigenvector, eigenvalue, psd, orthonormal, orthogonal, orthogonal projection, spectrum, spectral norm, PCA, sample covariance matrix, spectral clustering

\subsection{References}
\begin{enumerate}
  \item Axler (2024). Linear Algebra Done Right. 4th ed., Springer, Cham, Switzerland.
  \item Meyer (2000). Matrix Analysis and Applied Linear Algebra. SIAM, Philadelphia, PA, USA.
  \item Rudin (1976). Principles of Mathematical Analysis. 3rd ed., McGraw-Hill, New York, NY, USA.
  \item Young (1988). An Introduction to Hilbert Space. Cambridge Univ. Press, New York, NY, USA.
\end{enumerate}

\end{document}
