# Wolfram Mathematica

## Spectral Density of a Matrix

The joint spectral density of many matrix distributions has a corresponding universal limiting form. For Hermitian random matrices with independent entries, this is the Wigner semicircle law.

For Gaussian ensembles, the scaled spectral density of the matrices has a closed form for finite matrix dimension, related to the eigenfunctions of the quantum harmonic oscillator.

Use MatrixPropertyDistribution to represent the scaled spectrum of the Gaussian unitary ensemble and provide the closed-form expression of its joint spectral density.

In:= ```scaledSpectrum\[ScriptCapitalD][n_] := MatrixPropertyDistribution[ Eigenvalues[\[Lambda]]/(2 Sqrt[n]), \[Lambda] \[Distributed] GaussianUnitaryMatrixDistribution[n]];```
In:= ```spectralPDF[n_Integer, \[Lambda]_] := Sqrt[2/(\[Pi] n)] Exp[-2 n \[Lambda]^2] \!\( \*UnderoverscriptBox[\(\[Sum]\), \(j = 0\), \(n - 1\)] \*FractionBox[ SuperscriptBox[\(HermiteH[j, \*SqrtBox[\(2\ n\)]\ \[Lambda]]\), \(2\)], \( \*SuperscriptBox[\(2\), \(j\)]\ \(j!\)\)]\)```

For small matrix dimension, there is a characteristic oscillatory pattern, whose number of density maxima equals the matrix size.

In:= ```scaledSpectra = Flatten[RandomVariate[scaledSpectrum\[ScriptCapitalD][#], 10^5]] & /@ {3, 4, 5};```
show complete Wolfram Language input
In:= ```Row@MapThread[ Show[Plot[spectralPDF[#1, x], {x, -1.5, 1.5}, PlotTheme -> "Scientific", PlotStyle -> ColorData[97, 1], PlotLegends -> Placed["n = " <> ToString@#1, Above]], Histogram[#2, {0.05}, PDF]] &, {{3, 4, 5}, scaledSpectra}]```
Out= In the limit of large dimension, the density converges to WignerSemicircleDistribution.

In:= ```n = 250; scaledSpectrum = Flatten[RandomVariate[scaledSpectrum\[ScriptCapitalD][n], 10^2]];```
show complete Wolfram Language input
In:= ```Show[Histogram[scaledSpectrum, {0.05}, PDF, PlotTheme -> "Detailed"], Plot[PDF[WignerSemicircleDistribution, x], {x, -1.5, 1.5}, Exclusions -> None, PlotTheme -> "Scientific", PlotLegends -> None, PlotStyle -> ColorData[97, 1]], ImageSize -> Medium]```
Out= 