Skip to content

tools/states.py

GHZ

Construct an n-partite qudit GHZ state.

Returns i=0d1|in (unnormalized).

py
def GHZ(n: int, d: int) -> State
Implementation
python
def GHZ(n: int, d: int) -> State:
    Ket = Basis(d)
    vals = sum([Ket(f'{i}' * n) for i in range(d)])
    return State(vals)

W

Construct the n-qubit W state (single-excitation symmetric state).

Returns i=0n1|01i0 (unnormalized).

py
def W(n: int) -> State
Implementation
python
def W(n: int) -> State:
    Ket = Basis(2)
    vals = ['0' * i + '1' + '0' * (n - i - 1) for i in range(n)]
    vals = sum([Ket(v) for v in vals])
    return State(vals)

NOON

Construct a two-mode NOON-like state.

Returns |n,0+einθ|0,n (unnormalized) in a local dimension n+1.

py
def NOON(n: int, theta: float) -> State
Implementation
python
def NOON(n: int, theta: float=0.0) -> State:
    Ket = Basis(n + 1)
    kets = [Ket(0, n), Ket(n, 0)]
    kets = kets[0] + np.exp(1j * n * theta) * kets[1]
    return State(kets)

Dicke

Construct an n-qubit Dicke state with k zeros (and nk ones).

Returns the uniform (unnormalized) superposition over all distinct permutations of k symbols 0 and nk symbols 1.

py
def Dicke(n: int, k: int) -> State
Implementation
python
def Dicke(n: int, k: int) -> State:
    Ket = Basis(2)
    vals = ['0'] * k + ['1'] * (n - k)
    vals = set([''.join(p) for p in permutations(vals)])
    vals = sum([Ket(v) for v in vals])
    return State(vals)

Coherent

Truncated coherent state in a finite (N+1)-dimensional Fock space.

Builds n=0Nαn/n!|n with a normalization correction from the incomplete gamma function.

Reference at arxiv:1402.1487

py
def Coherent(N: int, alpha: complex) -> State
Implementation
python
def Coherent(N: int, alpha: complex=1.0) -> State:
    Ket = Basis(N + 1)
    a2 = abs(alpha) ** 2
    norm = np.exp(a2) * (1 - g(N + 1, a2) / F(N))
    norm = 1 / np.sqrt(norm)
    vec = sum((alpha ** n / np.sqrt(F(n)) * Ket(n) for n in range(N + 1)))
    return State(norm * vec)