The Clifford group $C_n$ on $n$ qubits is defined as $$C_n = \left\{ U \in U(2^n) \mid \sigma \in P_n \rightarrow U\sigma U^\dagger \in P_n \right\}/U(1),$$ where $$P_n = \left\{ \sigma_1 \otimes \dots \otimes \sigma_n \mid \sigma_i \in \{I,X,Y,Z\} \right\},$$ and $X,Y,Z$ are the Pauli matrices. Also $C_n$ may be generated as $$<H_i,P_i,CNOT_{ij}>/U(1).$$

How exactly could one produce a matrix representation of $C_n$ for use in a program? I understand the abstract representation, however it seems quite difficult to obtain an explicit list of the elements.

  • $\begingroup$ not sure you realize the difficulty of the question you are asking, but this arxiv.org/pdf/1310.6813.pdf (and references therein) might give you a starting point. Even for a single qubit the Clifford group contains something like 192 elements so anything beyond the generators is usually abstract. $\endgroup$ May 14, 2017 at 21:30
  • $\begingroup$ Why here (home.lu.lv/~sd20008/papers/essays/…) does it say the Clifford group $C_1$ contains 24 elements. If I consider $C_1$, how can I construct the list of elements via a matrix representation? $\endgroup$
    – A15234B
    May 15, 2017 at 0:15
  • $\begingroup$ There is a factor of $8$ difference, probably due to some equivalence. Either way... in the case of ${\cal C}(1)$, start with the generators and systematically multiply them together. Basically since $H^2=1$ and $S^4=1$, you will have all "words" of the type $H$, $S$, $SH$, $HS$ etc never containing $H^2$ or $S^4$. It's a process by exhaustion and it can be quite long. $\endgroup$ May 15, 2017 at 7:30
  • $\begingroup$ Any idea how long it would need to be for $C_1$? Seems to me this algorithm would be at least $O(n^2)$ where $n$ is potentially much larger than $\lvert C_n \rvert$? So constructing the clifford group beyond $C_1$ or $C_2$ would take very long. $\endgroup$
    – A15234B
    May 15, 2017 at 17:06
  • 2
    $\begingroup$ You shouldn't use a matrix representation in a computer. You loose all the advantage of the stabilizer formalism (being a concise description) immediately! $\endgroup$ May 15, 2017 at 22:25

1 Answer 1


There are algorithms to generate all elements of the Clifford group for a specified number of qubits. Here are a few implementations:

  • Algorithms that can enumerate an arbitrary Clifford operator without having to generate all possible tableaux (which makes it exponentially more efficient if all you need is just a random sample of the Clifford group). See https://arxiv.org/pdf/1406.2170.pdf. Implemented in QuantumClifford.jl

  • A very inefficient algorithm: http://www.cgranade.com/python-quaec/ (see qecc.clifford_group). The code implementing this can be seen here. It basically generates all possible mappings and then filters out those that do not fulfill the commutation and anticommutation relations. The section "Number of Elements" of this goes in a bit more depth.

In the QuantumClifford.jl library you can also convert these Clifford operations represented as tableaux into unitary matrices.

julia> using QuantumOptics, QuantumClifford

julia> a = first(enumerate_cliffords(2))
X₁ ⟼ + X_
X₂ ⟼ + _Z
Z₁ ⟼ + Z_
Z₂ ⟼ + _X

julia> Operator(a)
  basis: [Spin(1/2) ⊗ Spin(1/2)]
 0.353553+0.0im       0.0+0.0im   0.353553+0.0im        0.0+0.0im
      0.0+0.0im  0.353553+0.0im        0.0+0.0im   0.353553+0.0im
 0.353553+0.0im       0.0+0.0im  -0.353553+0.0im        0.0+0.0im
      0.0+0.0im  0.353553+0.0im        0.0+0.0im  -0.353553+0.0im

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.