```python
import numpy as np
import sympy
import itertools
from sympy import *

init_printing(use_latex="mathjax")
```

Let $d:=\dim (H)$


```python
d = 3
```

Insert a frame $f$

Cube


```python
f_1 = Matrix([[1], [1], [1]])
f_2 = Matrix([[-1], [1], [1]])
f_3 = Matrix([[1], [-1], [1]])
f_4 = Matrix([[1], [1], [-1]])
f_5 = Matrix([[-1], [-1], [1]])
f_6 = Matrix([[1], [-1], [-1]])
f_7 = Matrix([[-1], [1], [-1]])
f_8 = Matrix([[-1], [-1], [-1]])

f = [f_1, f_2, f_3, f_4, f_5, f_6,f_7,f_8]
f
```




$$\left [ \left[\begin{matrix}1\\1\\1\end{matrix}\right], \quad \left[\begin{matrix}-1\\1\\1\end{matrix}\right], \quad \left[\begin{matrix}1\\-1\\1\end{matrix}\right], \quad \left[\begin{matrix}1\\1\\-1\end{matrix}\right], \quad \left[\begin{matrix}-1\\-1\\1\end{matrix}\right], \quad \left[\begin{matrix}1\\-1\\-1\end{matrix}\right], \quad \left[\begin{matrix}-1\\1\\-1\end{matrix}\right], \quad \left[\begin{matrix}-1\\-1\\-1\end{matrix}\right]\right ]$$



Calculating the frame bound $A$ (Proposition 2.1. p 12 in Waldron): Let $S =VV^∗ = AI_H ,\ V := [f_j]_j$


```python
V = Matrix([v.T for v in f]).T
V
```




$$\left[\begin{matrix}1 & -1 & 1 & 1 & -1 & 1 & -1 & -1\\1 & 1 & -1 & 1 & -1 & -1 & 1 & -1\\1 & 1 & 1 & -1 & 1 & -1 & -1 & -1\end{matrix}\right]$$




```python
S = V * V.T.conjugate()
S
```




$$\left[\begin{matrix}8 & 0 & 0\\0 & 8 & 0\\0 & 0 & 8\end{matrix}\right]$$



Insert  the frame bound $A$


```python
A = S[0,0]
A
```




$$8$$




```python
def prj(u):
    return u * u.T.conjugate()
```

POVM $W_i = \frac{1}{A}f_i f_i^*$


```python
W = [sympy.Rational(1/A) * prj(u) for u in f]
W
```




$$\left [ \left[\begin{matrix}\frac{1}{8} & \frac{1}{8} & \frac{1}{8}\\\frac{1}{8} & \frac{1}{8} & \frac{1}{8}\\\frac{1}{8} & \frac{1}{8} & \frac{1}{8}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{8} & - \frac{1}{8} & - \frac{1}{8}\\- \frac{1}{8} & \frac{1}{8} & \frac{1}{8}\\- \frac{1}{8} & \frac{1}{8} & \frac{1}{8}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{8} & - \frac{1}{8} & \frac{1}{8}\\- \frac{1}{8} & \frac{1}{8} & - \frac{1}{8}\\\frac{1}{8} & - \frac{1}{8} & \frac{1}{8}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{8} & \frac{1}{8} & - \frac{1}{8}\\\frac{1}{8} & \frac{1}{8} & - \frac{1}{8}\\- \frac{1}{8} & - \frac{1}{8} & \frac{1}{8}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{8} & \frac{1}{8} & - \frac{1}{8}\\\frac{1}{8} & \frac{1}{8} & - \frac{1}{8}\\- \frac{1}{8} & - \frac{1}{8} & \frac{1}{8}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{8} & - \frac{1}{8} & - \frac{1}{8}\\- \frac{1}{8} & \frac{1}{8} & \frac{1}{8}\\- \frac{1}{8} & \frac{1}{8} & \frac{1}{8}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{8} & - \frac{1}{8} & \frac{1}{8}\\- \frac{1}{8} & \frac{1}{8} & - \frac{1}{8}\\\frac{1}{8} & - \frac{1}{8} & \frac{1}{8}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{8} & \frac{1}{8} & \frac{1}{8}\\\frac{1}{8} & \frac{1}{8} & \frac{1}{8}\\\frac{1}{8} & \frac{1}{8} & \frac{1}{8}\end{matrix}\right]\right ]$$



calculate the traces $tr W_i$


```python
trW = [sympy.trace(w) for w in W ]
trW
```




$$\left [ \frac{3}{8}, \quad \frac{3}{8}, \quad \frac{3}{8}, \quad \frac{3}{8}, \quad \frac{3}{8}, \quad \frac{3}{8}, \quad \frac{3}{8}, \quad \frac{3}{8}\right ]$$



chеcking that $\sum W_i = Id$


```python
sumPOVM = W[0]
for w in W[1:]:
    sumPOVM += w
sumPOVM
```




$$\left[\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right]$$



Let $F:=(\dots, F_i,\dots)$, $F_i = \frac{W_i}{tr(W_i)}$


```python
F = [w/(sympy.trace(w)) for w in W]
F
```




$$\left [ \left[\begin{matrix}\frac{1}{3} & \frac{1}{3} & \frac{1}{3}\\\frac{1}{3} & \frac{1}{3} & \frac{1}{3}\\\frac{1}{3} & \frac{1}{3} & \frac{1}{3}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{3} & - \frac{1}{3} & - \frac{1}{3}\\- \frac{1}{3} & \frac{1}{3} & \frac{1}{3}\\- \frac{1}{3} & \frac{1}{3} & \frac{1}{3}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{3} & - \frac{1}{3} & \frac{1}{3}\\- \frac{1}{3} & \frac{1}{3} & - \frac{1}{3}\\\frac{1}{3} & - \frac{1}{3} & \frac{1}{3}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{3} & \frac{1}{3} & - \frac{1}{3}\\\frac{1}{3} & \frac{1}{3} & - \frac{1}{3}\\- \frac{1}{3} & - \frac{1}{3} & \frac{1}{3}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{3} & \frac{1}{3} & - \frac{1}{3}\\\frac{1}{3} & \frac{1}{3} & - \frac{1}{3}\\- \frac{1}{3} & - \frac{1}{3} & \frac{1}{3}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{3} & - \frac{1}{3} & - \frac{1}{3}\\- \frac{1}{3} & \frac{1}{3} & \frac{1}{3}\\- \frac{1}{3} & \frac{1}{3} & \frac{1}{3}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{3} & - \frac{1}{3} & \frac{1}{3}\\- \frac{1}{3} & \frac{1}{3} & - \frac{1}{3}\\\frac{1}{3} & - \frac{1}{3} & \frac{1}{3}\end{matrix}\right], \quad \left[\begin{matrix}\frac{1}{3} & \frac{1}{3} & \frac{1}{3}\\\frac{1}{3} & \frac{1}{3} & \frac{1}{3}\\\frac{1}{3} & \frac{1}{3} & \frac{1}{3}\end{matrix}\right]\right ]$$



$\alpha = \{\alpha_i\}_i = \{\frac{1}{d} trW_i\}_i$


```python
alpha = [Rational(1,d) * u for u in trW]
alpha
```




$$\left [ \frac{1}{8}, \quad \frac{1}{8}, \quad \frac{1}{8}, \quad \frac{1}{8}, \quad \frac{1}{8}, \quad \frac{1}{8}, \quad \frac{1}{8}, \quad \frac{1}{8}\right ]$$



$\mathcal{E}(A):=d\int_{\Omega} ((F(s),A))F(s)d\alpha(s)=d\sum_{\Omega} ((F_i,A))F_i\alpha_i$

for matrix $d \times d$  this is the basis matrix $E_{kl}$:


```python
def basismatrix_kl(d,k,l):
    return Matrix(d,d,lambda i,j: Integer(i == k and j == l))
```

$G_{kl}$ basis matricies for $\mathcal{L}(H)$ 


```python
def G_kl(d,k,l):
    if k==l :
        return  basismatrix_kl(d,k,l)
    if k<l :
        return basismatrix_kl(d,k,l) + basismatrix_kl(d,l,k)
    else :
        return 1j * basismatrix_kl(d,k,l) - 1j * basismatrix_kl(d,l,k)
```

$tr(F_i G_{kl})$


```python
def trWiEkl(F_i,G_kl):
    return (F_i * G_kl(d,k,l)).trace() 
```

$tr(F_i A)F_i$


```python
def inthesum(F_i,A):
    return (F_i * A).trace() * F_i
```

$\mathcal{E}(G_{kl})=d\sum_{\Omega} tr(F_i G_{kl})F_i\alpha_i$

$\sum_{\Omega} tr(F_i G_{kl})F_i\alpha_i$:


```python
def cE_of_Gkl(F,A,alpha):
    B = inthesum(F[0],A)*alpha[0]
    for i in range(1, len(F)):
            B +=  inthesum(F[i],A)*alpha[i]
    return B
```

CHECK THE SUM ABOVE: range(1,len[F]) should it be range(1,len[F] + 1)?????????????????????????????

$\frac{1}{d}\mathcal{E}(G_{kl})=\sum_{m,n}\beta_{mn}G_{mn}$ , if $k\leq l$  then  $ \beta_{mn} = (\frac{A+A^t}{2})_{mn}$ else $\beta_{mn} = (\frac{A-A^t}{2i})_{mn}$


```python

def beta_mn(d,k,l,m,n) :
    A = G_kl(d,k,l)
    B = cE_of_Gkl(F,A,alpha)
    if m<=n :
        return  (B+B.T)[m,n]/2
    else :
        return (B-B.T)[m,n]/(2j)

```


```python

def cE(d,k,l):
    return Matrix(d,d, lambda m,n: beta_mn(d, k, l, m, n)).reshape(1,(d)**2)
cE(3,0,0)
```




$$\left[\begin{matrix}\frac{1}{9} & 0 & 0 & 0 & \frac{1}{9} & 0 & 0 & 0 & \frac{1}{9}\end{matrix}\right]$$



$\text{matrix with rows }cE(d,k,l)^T$ i.e. $\frac{1}{d}\mathcal{E}(A)$ in the basis $G_{kl}$ of $\mathcal{L}(H)$


```python
M = Integer (d) * Matrix([cE(d,k,l) for k,l in itertools.product(range(0,d), range(0,d))]).T
M
```




$$\left[\begin{matrix}\frac{1}{3} & 0 & 0 & 0 & \frac{1}{3} & 0 & 0 & 0 & \frac{1}{3}\\0 & \frac{2}{3} & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & \frac{2}{3} & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{3} & 0 & 0 & 0 & \frac{1}{3} & 0 & 0 & 0 & \frac{1}{3}\\0 & 0 & 0 & 0 & 0 & \frac{2}{3} & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\frac{1}{3} & 0 & 0 & 0 & \frac{1}{3} & 0 & 0 & 0 & \frac{1}{3}\end{matrix}\right]$$



eigenvalues of $\mathcal{E}(A)$


```python
M.eigenvals()
```




$$\left \{ 0 : 5, \quad \frac{2}{3} : 3, \quad 1 : 1\right \}$$



6c39645f09ed2b9d6366a3a30296d52fd9cd50d0
ipynb
Jupyter Notebook
Gap of a frame - for example a cube.ipynb
vika999/spectral_gap
3d8b26439eb19685a2b5de4300e54b2576430bfc
MIT
Gap of a frame - for example a cube.ipynb
vika999/spectral_gap
3d8b26439eb19685a2b5de4300e54b2576430bfc
MIT
Gap of a frame - for example a cube.ipynb
vika999/spectral_gap
3d8b26439eb19685a2b5de4300e54b2576430bfc
MIT
Qwen/Qwen-72B
1. YES
2. YES