# Rotational Complexity of Matrices — Theory and Experimental Results

## Executive conclusion

The proposed idea is mathematically valid when a “rotating circle” is defined as one real conjugate pair of two-dimensional Fourier coefficients. Every finite real matrix can be reconstructed exactly by a finite collection of these rotors. The number needed is a useful, computable **basis-dependent complexity measure**, but it is not a universal measure of pattern or randomness.

The strongest experimental findings are:

1. The implementation reconstructed every benchmark matrix with maximum relative Frobenius error **3.188e-16**.
2. The exact one-rotor and four-rotor controls were correctly recovered as **1** and **4** active rotors.
3. Smooth and periodic structure concentrated energy into few rotors.
4. A spatial impulse required **98.9%** of the rotor groups to retain 99% energy, demonstrating that a simple object can be Fourier-expensive.
5. A rank-one matrix needed only **1 SVD component**, yet needed **69.5%** of Fourier rotor groups for 99% energy.
6. The short-rule LCG pseudorandom matrix needed **86.0%** of rotors for 99% energy, so high rotor complexity does not prove algorithmic randomness.

The theory therefore succeeds as **rotational/Fourier complexity**, and fails if interpreted as basis-independent complexity or as proof of true randomness.

## Formal model

For an `m × n` real matrix `M`, one rotor is

```text
R_k(i,j) = A_k cos(2π(u_k i/m + v_k j/n) + φ_k).
```

The exact representation is

```text
M(i,j) = Σ_k R_k(i,j),
```

with DC and Nyquist terms treated as degenerate self-conjugate rotors. The implementation groups each Fourier coordinate `(u,v)` with `(-u mod m,-v mod n)`, ensuring that every truncated reconstruction remains real.

For retained-energy target `q`, rotational complexity is

```text
K_q(M) = min K such that ||M - M_K||²_F / ||M||²_F ≤ 1 - q,
```

where `M_K` keeps the `K` highest-energy conjugate rotor groups. Parseval’s identity makes ranking in Fourier space exactly equivalent to ranking reconstruction energy.

## Benchmark design

- Matrix size: **64 × 64** (4,096 values).
- Available conjugate rotor groups: **2,050**.
- Energy targets: 50%, 90%, 95%, 99%, and 99.9%.
- Controls: constant, one sinusoid, four sinusoids, checkerboard, and square-wave stripes.
- Geometry: Gaussian blob, binary disk, and binary square.
- Counterexamples: random rank-one outer product and single spatial impulse.
- Randomness: Gaussian noise, random signs, and a short-rule 32-bit LCG.
- Random trials: **40** seeds for each distribution at 16², 32², 64², and 128².
- Comparator: SVD components needed for the same retained-energy targets.

## Main benchmark results

| Matrix | Class | Active rotors | Rotors for 99% | SVD for 99% | Spectral entropy | Exact error |
|---|---|---:|---:|---:|---:|---:|
| constant | structured | 1 | 1 (0.0%) | 1 (1.6%) | 0.000 | 0.00e+00 |
| single sinusoid | structured | 1 | 1 (0.0%) | 2 (3.1%) | 0.000 | 3.19e-16 |
| four sinusoids | structured | 4 | 4 (0.2%) | 7 (10.9%) | 0.107 | 2.29e-16 |
| checkerboard | structured | 1 | 1 (0.0%) | 1 (1.6%) | 0.000 | 0.00e+00 |
| square wave stripes | structured | 16 | 12 (0.6%) | 1 (1.6%) | 0.108 | 1.63e-16 |
| gaussian blob | geometric | 851 | 19 (0.9%) | 1 (1.6%) | 0.324 | 2.97e-16 |
| binary disk | geometric | 1,985 | 669 (32.6%) | 7 (10.9%) | 0.380 | 2.06e-16 |
| binary square | geometric | 1,985 | 140 (6.8%) | 1 (1.6%) | 0.336 | 1.82e-16 |
| rank1 outer product | relational | 2,050 | 1,425 (69.5%) | 1 (1.6%) | 0.866 | 2.94e-16 |
| single impulse | spatially_sparse | 2,050 | 2,028 (98.9%) | 1 (1.6%) | 1.000 | 1.02e-16 |
| modular multiplication | algorithmic | 1,850 | 1,606 (78.3%) | 36 (56.2%) | 0.919 | 2.27e-16 |
| white gaussian | random | 2,050 | 1,770 (86.3%) | 50 (78.1%) | 0.944 | 2.83e-16 |
| random signs | random | 2,050 | 1,762 (86.0%) | 50 (78.1%) | 0.943 | 2.46e-16 |
| lcg pseudorandom | algorithmic | 2,050 | 1,764 (86.0%) | 50 (78.1%) | 0.943 | 2.62e-16 |

“Active rotors” ignores only coefficients at floating-point roundoff scale. Spectral entropy is normalized to `[0,1]`; higher values mean energy is more evenly distributed over rotor groups.

## Random and pseudorandom trials

| Distribution | Size | Trials | Mean rotor fraction for 99% | Observed range | Mean entropy |
|---|---:|---:|---:|---:|---:|
| gaussian | 16×16 | 40 | 85.81% ± 1.60% | 83.08%–89.23% | 0.911 |
| gaussian | 32×32 | 40 | 86.10% ± 0.75% | 84.63%–87.74% | 0.931 |
| gaussian | 64×64 | 40 | 86.14% ± 0.44% | 85.17%–87.02% | 0.944 |
| gaussian | 128×128 | 40 | 86.17% ± 0.21% | 85.81%–86.56% | 0.953 |
| lcg | 16×16 | 40 | 86.19% ± 1.78% | 81.54%–89.23% | 0.912 |
| lcg | 32×32 | 40 | 85.96% ± 0.94% | 83.46%–87.94% | 0.932 |
| lcg | 64×64 | 40 | 86.15% ± 0.41% | 85.56%–87.07% | 0.944 |
| lcg | 128×128 | 40 | 86.20% ± 0.21% | 85.75%–86.56% | 0.953 |
| random signs | 16×16 | 40 | 85.56% ± 1.70% | 81.54%–89.23% | 0.911 |
| random signs | 32×32 | 40 | 86.35% ± 0.86% | 84.24%–88.33% | 0.932 |
| random signs | 64×64 | 40 | 86.19% ± 0.44% | 85.37%–87.27% | 0.944 |
| random signs | 128×128 | 40 | 86.20% ± 0.22% | 85.72%–86.65% | 0.953 |

For ideal complex-Gaussian Fourier energies, the asymptotic ordered-exponential model predicts that approximately **86.20%** of modes are needed to retain 99% energy. The Gaussian trials approach this value as matrix size increases. This is more precise than saying noise energy is perfectly uniform: sorting lets the largest random coefficients capture disproportionate energy.

## What the experiments establish

### Confirmed

- Every finite real matrix admits an exact finite rotor decomposition.
- The minimal count within the fixed discrete Fourier dictionary is directly computable.
- Periodicity and smoothness often produce strong rotor compression.
- Circular phase and frequency provide a valid geometric interpretation of Fourier coefficients.
- Translation changes Fourier phase but preserves rotor energies and therefore preserves the complexity curve.

### Falsified or limited

- **Rotor count is not universal complexity.** The rank-one and impulse controls are deliberately simple in other languages but expensive in the Fourier language.
- **High rotor count does not prove randomness.** The LCG is specified by a tiny recurrence and seed while appearing spectrally noise-like.
- **A matrix is not intrinsically a geometric surface.** It becomes a sampled field only after row/column adjacency and boundary conditions are chosen.
- **Boundary choice matters.** The DFT assumes periodic wraparound; nonperiodic edges distribute energy into additional frequencies.
- **Exact compression of continuous random data is generally absent.** Almost every rotor coefficient is nonzero; useful compression requires an error tolerance.

## Interpretation for the Theory of Reality

The useful general principle is not “everything is secretly circles.” It is:

> Choose a vocabulary of elementary motions, decompose the observation into that vocabulary, and measure how many elements are required to reconstruct it within a declared error.

Fourier rotors are one vocabulary. SVD modes, wavelets, geometric primitives, graph eigenmodes, and short generating programs are other vocabularies. A genuine decoder should compare them and include the cost of describing the vocabulary itself; otherwise a custom dictionary could hide the entire matrix in one arbitrarily complicated “primitive.”

The next scientifically meaningful quantity is therefore a two-part description length:

```text
total cost = cost(dictionary or law) + cost(coefficients/residual).
```

That prevents dictionary cheating and connects the rotor experiment to minimum-description-length and algorithmic-complexity ideas without claiming that either has been solved.

## Reproducibility

Run:

```bash
python run_benchmarks.py
python -m unittest discover -s tests -v
python -m rotorlab analyze path/to/matrix.csv --energy 0.99
```

The JSON and CSV outputs contain the full measurements. Figures show compression curves, Fourier-versus-SVD dependence, and reconstruction quality as rotors are added.
