# Spectral Hamiltonian Neuron

- ID: 536
- Canonical URL: https://synthcore.org/idea/536/spectral-hamiltonian-neuron
- API JSON: https://synthcore.org/api/idea/536.json
- API Markdown: https://synthcore.org/api/idea/536.md
- Verification status: mech_ok_no_baseline
- Source: [arXiv:2607.05000](https://arxiv.org/abs/2607.05000)
- Category: architecture
- Solves: accuracy, sample-efficiency
- ML areas: embedding, optimizer
- Math tags: linear-algebra, spectral-theory, algebra
- Ratings: usefulness 6/10; difficulty 6/10; novelty 7/10

## Idea description

Replace a scalar neuron activation with a matrix function of a learned Hamiltonian. Fixed Hermitian interaction operators are combined as a trainable linear Hamiltonian, the activation is applied to its eigenvalues, and the resulting observable is measured on an input quantum state. Noncommuting interaction terms provide a controlled source of expressivity beyond an ordinary scalar neuron.

## Mathematical statement

The canonical quantization construction defines the Hamiltonian H_theta = sum over j of theta_j H_j, where theta_j are trainable real coefficients and H_j are fixed Hermitian interaction operators. If H_theta = U diag(lambda_1,...,lambda_d) U^dagger, matrix functional calculus defines phi(H_theta) = U diag(phi(lambda_1),...,phi(lambda_d)) U^dagger for a scalar activation phi. For an input density matrix rho, the prediction is f_theta(rho) = Tr(rho phi(H_theta)). Noncommutativity means that [H_i,H_j] = H_i H_j - H_j H_i is nonzero for at least one pair, so the terms cannot be simultaneously diagonalized. To train the layer without incorrectly using an elementwise derivative, use the Frechet derivative. In the eigenbasis of H_theta, the derivative with respect to theta_j is D phi at H_theta applied to H_j = U (G^(j) elementwise-multiplied by U^dagger H_j U) U^dagger. The divided-difference matrix has entries G^(j)_ab = (phi(lambda_a)-phi(lambda_b))/(lambda_a-lambda_b) when lambda_a is not equal to lambda_b, and G^(j)_aa = phi'(lambda_a) otherwise. For squared loss L = B^(-1) sum_b (f_theta(rho_b)-y_b)^2, the parameter gradient is dL/dtheta_j = 2 B^(-1) sum_b (f_theta(rho_b)-y_b) Tr(rho_b D phi at H_theta applied to H_j).

## Key formulas

- $$H_{\theta}\coloneqq\sum_{j\in[J]}\theta_jH_j$$
- $$H_\theta=U\operatorname{diag}(\lambda_1,\ldots,\lambda_d)U^\dagger,\qquad \varphi(H_\theta)=U\operatorname{diag}(\varphi(\lambda_1),\ldots,\varphi(\lambda_d))U^\dagger$$
- $$f_\theta(\rho)=\operatorname{Tr}\!\left(\rho\,\varphi(H_\theta)\right)$$
- $$\frac{\partial f_\theta(\rho)}{\partial\theta_j}=\operatorname{Tr}\!\left(\rho\,U\left[G^{(j)}\odot(U^\dagger H_jU)\right]U^\dagger\right),\quad G^{(j)}_{ab}=\begin{cases}\frac{\varphi(\lambda_a)-\varphi(\lambda_b)}{\lambda_a-\lambda_b},&\lambda_a\ne\lambda_b,\\\varphi'(\lambda_a),&\lambda_a=\lambda_b.\end{cases}$$

## Implementation notes

Integrate the construction as the first layer that maps a quantum state to a scalar feature, or as one channel in a hybrid quantum-classical model. Store fixed Hermitian matrices H[1:J], trainable coefficients theta[1:J], input density matrices rho[b], and scalar labels y[b]. For each minibatch, first construct H = sum_j theta[j] * H[j]. Rescale it by H <- H / max(1, spectral_norm(H)) so that its eigenvalues remain in a stable interval. Eigensolve H = U diag(lambda) U^dagger, compute A = U diag(phi(lambda)) U^dagger, and predict yhat[b] = real(trace(rho[b] @ A)). Compute the squared minibatch loss. For every j, transform H[j] into the eigenbasis, construct G[j] using the divided-difference formula, form dA[j] = U @ (G[j] elementwise-multiplied by U^dagger @ H[j] @ U) @ U^dagger, and set grad_theta[j] = 2 times the batch average of (yhat[b]-y[b]) times real(trace(rho[b] @ dA[j])). Update theta with Adam or SGD. A hardware version can estimate trace(rho A) by repeated observable measurements and approximate phi(H) with a truncated polynomial p_K(H) = sum_k c_k H^k implemented through Hamiltonian simulation. The eigendecomposition, divided differences, and gradients are exact in the simulator; shot noise and polynomial truncation are empirical approximations on hardware. Begin with 4 to 8 qubits, random shallow-circuit states, and labels generated by a target observable containing two noncommuting Pauli strings. Compare equal-parameter commuting H_j, noncommuting H_j, and a classical linear-energy neuron. Success is lower test MSE or fewer training examples at the same parameter count, with an ablation confirming that the gain disappears when all H_j commute.

## Verification

- Status: mech_ok_no_baseline
- Mechanism evidence: yes
- Mechanism confirmed: yes
- Practical verdict: harms
- Verdict: Built a NumPy spectral Hamiltonian neuron using matrix functional calculus and divided-difference Fréchet derivatives. The derivative check matched finite differences with relative error 8.3e-11. On the synthetic target, the noncommuting spectral model achieved test MSE 3.35e-31, versus 0.0603 for the commuting spectral control and 0.00137 for the classical linear-energy control, showing a clear expressivity signal, though the teacher used the same noncommuting operator family.

### Mechanism check

- Verdict: Built a NumPy spectral Hamiltonian neuron using matrix functional calculus and divided-difference Fréchet derivatives. The derivative check matched finite differences with relative error 8.3e-11. On the synthetic target, the noncommuting spectral model achieved test MSE 3.35e-31, versus 0.0603 for the commuting spectral control and 0.00137 for the classical linear-energy control, showing a clear expressivity signal, though the teacher used the same noncommuting operator family.
- Confidence: 8/10
- Limitations: Small noiseless d=4 simulator, one seed, exact eigendecomposition, and a synthetic teacher sharing the noncommuting operator family. Shot noise, polynomial Hamiltonian simulation, larger systems, multiple seeds, speed/FLOPs, and spectral-norm rescaling were not tested.

### Practical benchmark

- Paired seeds: 8
- Baseline mean: 0
- Idea mean: 0
- p-value: 0.0081
- Paired wins: 0/8
- Benchmark verdict: idea worse (significant)

## Artifacts

- [bench_report.json](https://synthcore.org/code/1377/bench_report.json)
- [report.md](https://synthcore.org/code/1377/report.md)
- [report_bench_2026-09-04T174833.md](https://synthcore.org/code/1377/report_bench_2026-09-04T174833.md)
- [spectral_neuron_experiment.py](https://synthcore.org/code/1377/spectral_neuron_experiment.py)
- [stage2_bench.py](https://synthcore.org/code/1377/stage2_bench.py)
- [Download all files as ZIP](https://synthcore.org/download/1377)

## Disclaimer

AI-generated research hypothesis, automatically tested. Not peer-reviewed.
