>[!warning]
>This content has not been peer reviewed.
# Quantization — Code documentation
## Purpose
`rst_quantization.py` derives energy quantization from the $L^n$ norm geometry. The $L^n$ kinetic energy $E = \|p\|^n / (nm^{n-1})$ produces energy levels $E_k \propto k^n$ in a box. At $n = 2$, this recovers the particle-in-a-box spectrum exactly ($R^2 = 1$).
## Key functions
| Function | Description |
|:---|:---|
| `ln_ball_boundary(n)` | 2D unit ball $\|x\|^n + \|y\|^n = 1$ boundary points |
| `ln_ball_area_2d(n)` | Area via $4\Gamma(1+1/n)^2 / \Gamma(1+2/n)$ |
| `lacunarity_2d(n)` | $\mathcal{L} = 4 / A(n)$ |
| `min_uncertainty_product(n)` | $\hbar^2 / 2^{2/n}$ |
| `energy_ratios(n, k_max)` | $E_k/E_1 = k^n$ |
| `fit_power_law(k, ratios)` | Fit $k^n$ to arbitrary energy ratios |
## Modes
| Flag | Description | Output |
|:---|:---|:---|
| `--geometry` | L^n ball shapes + lacunarity spectrum | 2 figures |
| `--uncertainty` | min(dx*dp) vs n, Heisenberg at n=2 | 1 figure |
| `--spectrum` | Energy level bars + log-log power law | 2 figures |
| `--discovery` | Fit n for particle-in-box, harmonic osc., hydrogen | 1 figure |
Running without flags executes all modes.
## Dependencies
- Python 3.8+
- NumPy, SciPy, Matplotlib
## Execution
```bash
cd "about systems"
python "expanded theory applied/further applications/Quantization/rst_quantization.py"
python "expanded theory applied/further applications/Quantization/rst_quantization.py" --discovery
```
## Output
| File | Description |
|:---|:---|
| `quantization_geometry_balls.png` | L^n ball shapes (3x3 grid) |
| `quantization_geometry_lacunarity.png` | Lacunarity spectrum vs n |
| `quantization_uncertainty.png` | Minimum uncertainty product vs n |
| `quantization_spectrum_levels.png` | Energy level bars for six n values |
| `quantization_spectrum_loglog.png` | Log-log energy ratios |
| `quantization_discovery.png` | Discovery: fitted n for QM systems |
## Links
- **Theory:** [[Quantization (RST)]]
- **Results:** [[Quantization Results]]