This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts

demoAINumerics

The eigenvalues of a random matrix fill Wigner's semicircle

Fill a symmetric matrix with independent random numbers, divide by , and look at its eigenvalues. They do not scatter. They fill the semicircle , whatever distribution the entries came from.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Only the entries' variance matters; these are uniform on , which has variance 1 and looks nothing like a Gaussian. The even moments of the semicircle are the Catalan numbers because counts closed walks that never cross themselves. The tests check the second, fourth and sixth moments (1, 2 and 5), and that no eigenvalue lies beyond .

At the program runs in your browser in about a tenth of a second. The post also shows a recorded run of the same program at (the large setting), compiled to C and run natively; the Jacobi eigensolver costs per sweep, so that run takes minutes. Its histogram is smoother, and its largest eigenvalue in absolute value is .

Printed

second: 1.00724
fourth: 2.02344
edge: 1.98733
Eigenvalues of one N x N random symmetric matrix
histogramsemicircle
00.10.20.3−2−1012eigenvaluedensity

Tests 4 of 4 pass

  • the second moment is 1: the first Catalan number (passes)
  • the fourth moment is 2: the second (passes)
  • the sixth moment is 5: the third (passes)
  • nothing escapes the edge at 2 by more than a tenth (passes)

The large run, recorded by the author

N = 2000 · compiled Viv -> C (viv build), one core of an Apple M2 Pro, 269 s, 2026-10-16 · viv run --set N=2000 posts/2026-09-21-wigner-semicircle.viv

Eigenvalues of one N x N random symmetric matrix
histogramsemicircle
00.10.20.3−2−1012eigenvaluedensity
  • ✓ the second moment is 1: the first Catalan number
  • ✓ the fourth moment is 2: the second
  • ✓ the sixth moment is 5: the third
  • ✓ nothing escapes the edge at 2 by more than a tenth

Checked when the site was built: 4 of 4 tests passed, in 0.13 s. Download 2026-09-21-wigner-semicircle.viv