This document realises, in a single live page, the complete four-stage pipeline of Quantum Singular Value Transformation: Singular Value Decomposition, Block Encoding, Quantum Signal Processing (including explicit phase-angle determination), and the QSVT theorem. Each stage is recomputed in real time as the user edits the input matrix or selects a different polynomial.
The framework supports any real matrix of dimensions $m\times n$ with $m,n\in\{2,3\}$, covering both square and rectangular cases.
The Singular Value Decomposition expresses an arbitrary $m\times n$ matrix as the composition of an input rotation, a diagonal stretch, and an output rotation. QSVT preserves the unitary factors $U$ and $V^{\dagger}$ identically and acts only on the singular values arranged along $\Sigma$; this isolation of the non-unitary content is what makes the entire construction implementable on a quantum register.
A non-unitary operator cannot be implemented directly on a quantum register. We therefore embed $A$, after sub-normalisation by a constant $\alpha \ge \lVert A\rVert_2$, as the upper-left block of a larger unitary operator $U_A$ acting on the system together with one or more ancillary qubits. The original matrix is recovered by projecting the ancilla onto $|0\rangle$: $$\bigl(\langle 0^{a}|\otimes I\bigr)\,U_A\,\bigl(|0^{a}\rangle\otimes I\bigr) \;=\; A/\alpha.$$ For an $m\times n$ block $B = A/\alpha$ with $\lVert B\rVert\le 1$, the canonical cosine–sine dilation is $$U_A=\begin{bmatrix} B & \sqrt{I_m - B B^{\dagger}}\\[2pt] \sqrt{I_n - B^{\dagger} B} & -B^{\dagger}\end{bmatrix}\in\mathbb{R}^{(m+n)\times(m+n)}.$$ This construction is exactly unitary whenever $\lVert B\rVert\le 1$.
Quantum Signal Processing realises a polynomial transformation of a scalar variable $x\in[-1,1]$ via an alternating sequence of two single-qubit rotations: $$U_{\vec\phi}(x)=S(\phi_0)\,W(x)\,S(\phi_1)\,W(x)\cdots W(x)\,S(\phi_d),$$ where
$W(x) = e^{i\arccos(x)\,\sigma_x}$. The signal $x$ is the only non-tunable input; it will later play the role of a singular value $\sigma_i/\alpha$.
$S(\phi) = e^{i\phi\sigma_z}$. The angles $\phi_0,\dots,\phi_d$ are the programmable degrees of freedom that determine which polynomial is realised.
For any real polynomial $P$ of degree $d$, parity matching $d$, and $|P(x)|\le 1$ on $[-1,1]$, there exist real phases $\vec\phi=(\phi_0,\dots,\phi_d)$ such that the upper-left entry of the alternating product equals $P(x)$.
Determining $\vec\phi$ from $P$ is a classical optimisation problem. In production codes one uses the Wilson decomposition, the algorithm of Haah (2019), or the symmetric solver of Dong–Meng–Whaley–Lin (2021). Below we use a simple gradient-descent (Adam) optimiser to find $\vec\phi$ directly from $P$, sufficient for pedagogical illustration.
The optimiser minimises the empirical $L^{2}$ loss $$\mathcal{L}(\vec\phi)\;=\;\frac{1}{N}\sum_{k=1}^{N}\Bigl|\;\bigl[U_{\vec\phi}(x_k)\bigr]_{1,1}\;-\;P(x_k)\Bigr|^{2}$$ on a uniform grid $\{x_k\}\subset[-1,1]$. The optimisation is performed entirely in the browser; click the button below to (re)run it.
Having obtained $\vec\phi$, we now construct the matrix $U_{\vec\phi}(x)$ explicitly for a sample value of $x$ and check that its $(1,1)$ entry equals $P(x)$ across the entire interval.
The boxed entry is the $(1,1)$ position; the QSP theorem asserts that this entry equals $P(x)$.
Replacing the scalar oracle $W(x)$ with the block encoding $U_A$, and replacing each $Z$-rotation with a projector-controlled phase that acts only when the ancilla register is in $|0^a\rangle$, yields the QSVT circuit. The fundamental identity satisfied by this circuit is $$\bigl(\langle 0^{a}|\otimes I\bigr)\,U_{\rm QSVT}\,\bigl(|0^{a}\rangle\otimes I\bigr) \;=\; U\,P\!\bigl(\Sigma/\alpha\bigr)\,V^{\dagger}.$$ Operationally the pipeline reduces to applying $P$ entry by entry to the diagonal of the sub-normalised singular value matrix and re-applying $U$ and $V^{\dagger}$; the same phase angles $\vec\phi$ obtained in Stage III drive the matrix-valued circuit.
Three structural invariants are checked on every refresh: orthogonality of $U$ and $V$, non-negativity of $\sigma_i$, and the unitarity of the dilation $U_A$.