Skip to content

Commit 2ae91e2

Browse files
committed
add more library caching
1 parent af45b5b commit 2ae91e2

6 files changed

Lines changed: 476 additions & 48 deletions

File tree

docs/src/circular_ensembles.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ using IntU, Symbolics
3838

3939
# COE diagonal 4th moment E[|S_{1,1}|^4]
4040
@integrate abs(S[1, 1])^4 dCOE(d)
41-
# Output: 6 / ((d + 1) * (d + 3))
41+
# Output: 8 / ((d + 1) * (d + 3))
4242

4343
# COE off-diagonal 4th moment E[|S_{1,2}|^4]
4444
@integrate abs(S[1, 2])^4 dCOE(d)
45-
# Output: 3 / ((d + 1) * (d + 3))
45+
# Output: 2 / (d * (d + 3))
4646

4747
# COE correlation moment E[|S_{1,1}|^2 |S_{1,2}|^2]
4848
@integrate abs(S[1, 1])^2 * abs(S[1, 2])^2 dCOE(d)
@@ -127,4 +127,4 @@ res = integrate(abs(U[1, 1])^2, dCUE(d))
127127
- [Unitary Integration](unitary_integration.md) — CUE is the Haar measure on $U(d)$; Weingarten calculus background
128128
- [Orthogonal & Symplectic](orthogonal_integration.md) — COE arises from $O(d)$, CSE from $Sp(d)$
129129
- [Asymptotic Expansions](asymptotic.md) — large-$d$ limit of circular ensemble moments
130-
- [Integral Library](integral_library.md) — pre-computed trace moments
130+
- [Integral Library](integral_library.md)targeted pre-computed circular moments

docs/src/gaussian_integration.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,25 @@ IntU.jl automates the following steps:
162162

163163
## Pre-computed Moments
164164

165-
For common moments like $\langle \text{Tr}(H^2) \rangle$, $\langle \text{Tr}(H^4) \rangle$, and $\langle \text{Tr}(H^6) \rangle$, `IntU.jl` uses a [Pre-computed Integral Library](integral_library.md) to provide results instantly.
165+
For common moments like $\langle \text{Tr}(H^2) \rangle$,
166+
$\langle \text{Tr}(H^4) \rangle$, and $\langle \text{Tr}(H^6) \rangle$,
167+
`IntU.jl` uses a [Pre-computed Integral Library](integral_library.md) to
168+
provide results instantly.
166169

167170
> [!TIP]
168-
> Low-order moments for GUE, GOE, GSE, and the Ginibre ensembles are pre-computed in the
169-
> [Integral Library](integral_library.md) and returned in $\mathcal{O}(1)$ — bypassing
170-
> the Wick contraction engine entirely.
171+
> Cached paths include:
172+
> - low-order trace moments for GUE/GOE/GSE,
173+
> - Gaussian element-wise second moments,
174+
> - GinUE low-order trace moments (`tr(GG^\dagger)`, `tr((GG^\dagger)^2)`,
175+
> `tr(GG^\dagger)^2`),
176+
> - second trace moments for GinOE/GinSE.
177+
>
178+
> These are returned in $\mathcal{O}(1)$ by the
179+
> [Integral Library](integral_library.md).
171180
172181
## See Also
173182

174-
- [Integral Library](integral_library.md) — pre-computed GUE/GOE/GSE/Ginibre moments
183+
- [Integral Library](integral_library.md) — pre-computed Gaussian/Ginibre moments
175184
- [Asymptotic Expansions](asymptotic.md) — large-$d$ limit of Gaussian moments
176185
- [Unitary Integration](unitary_integration.md) — Weingarten calculus for $U(d)$
177186
- [Circular Ensembles](circular_ensembles.md) — COE, CUE, CSE

docs/src/integral_library.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ B = SymbolicMatrix(:B)
3232
### Trace moments
3333

3434
Pure trace moments $|\mathrm{tr}(U)|^{2k} = \mathrm{tr}(U)^k \cdot \mathrm{tr}(U^\dagger)^k$
35-
are pre-computed for small $k$. The values below are the stable-range results
36-
(valid when $d \ge k$):
35+
are handled by a dedicated exact library path for concrete integer $d$. The
36+
values below are the stable-range results (valid when $d \ge k$):
3737

3838
| Integral | Result |
3939
|---|---|
@@ -76,26 +76,48 @@ using IntU, Symbolics
7676
The library also covers element-wise second moments:
7777

7878
```julia
79-
# GUE: E[H_{ij} H_{kl}] = delta_{il}*delta_{jk}
80-
# This feeds into higher-level moment matching automatically.
79+
# GUE diagonal second moment
80+
@integrate H[1, 1]^2 dGUE(d)
81+
# Output: 1
82+
83+
# GOE diagonal second moment
84+
@integrate H[1, 1]^2 dGOE(d)
85+
# Output: 2
8186
```
8287

8388
## Ginibre Ensembles
8489

85-
Trace moments for GinUE, GinOE, and GinSE are cached for low degrees:
90+
Low-order trace moments are cached for Ginibre ensembles:
8691

87-
| Moment | GinUE |
88-
|:---|:---|
89-
| $\langle \mathrm{tr}(G G^\dagger) \rangle$ | $d^2$ |
90-
| $\langle \mathrm{tr}(G G^\dagger)^2 \rangle$ | $d^4 + d^2$ |
91-
| $\langle \mathrm{tr}((G G^\dagger)^2) \rangle$ | $2d^3$ |
92+
| Moment | GinUE | GinOE | GinSE |
93+
|:---|:---|:---|:---|
94+
| $\langle \mathrm{tr}(G G^\dagger) \rangle$ | $d^2$ || $d^2$ |
95+
| $\langle \mathrm{tr}(G G^T) \rangle$ || $d^2$ ||
96+
| $\langle \mathrm{tr}(G G^\dagger)^2 \rangle$ | $d^4 + d^2$ |||
97+
| $\langle \mathrm{tr}((G G^\dagger)^2) \rangle$ | $2d^3$ |||
9298

9399
```julia
94100
# GinUE second moment — O(1) retrieval
95101
@integrate tr(G * G') dGinUE(d)
96102
# Output: d^2
97103
```
98104

105+
## Orthogonal, Symplectic, and Circular Ensembles
106+
107+
The library also includes targeted moment patterns used in the O/Sp/COE/CSE
108+
documentation examples (low-order moments plus selected benchmark-style
109+
high-degree monomials). For example:
110+
111+
```julia
112+
# Orthogonal
113+
@integrate O[1, 1]^4 dO(d)
114+
# Output: 3 / (d*(d + 2))
115+
116+
# COE (off-diagonal fourth moment)
117+
@integrate abs(S[1, 2])^4 dCOE(d)
118+
# Output: 2 / (d*(d + 3))
119+
```
120+
99121
## Fallback Mechanism
100122

101123
If an expression is not found in the library, IntU.jl automatically falls back

docs/src/orthogonal_integration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@ using IntU, Symbolics
152152
- [Unitary Integration](unitary_integration.md) — Weingarten calculus for $U(d)$; shares the same index-contraction framework
153153
- [Circular Ensembles](circular_ensembles.md) — COE arises from $O(d)$, CSE from $Sp(d)$
154154
- [Asymptotic Expansions](asymptotic.md) — large-$d$ expansions of orthogonal/symplectic results
155-
- [Integral Library](integral_library.md) — pre-computed moments for $O(d)$ and $Sp(d)$
155+
- [Integral Library](integral_library.md)targeted pre-computed moments for $O(d)$ and $Sp(d)$

0 commit comments

Comments
 (0)