# Vector form of Pauli operators and the generator matrix#

It is getting quite tedious to write down multi-qubit Pauli operators like $X \otimes X \otimes I$. Here we are going to discuss a compact form for Pauli operators, that will make it very easy to do computations.

## Vector form of Pauli operators#

We are going to map operators in the Pauli group $\group{P}_n$ to binary vectors of length $2n$.

The elements of $\group{P}_1$ are \begin{align} I \equiv (0|0), \\ X \equiv (1|0), \\ Y \equiv (1|1), \\ Z \equiv (0|1). \end{align}

For larger $n$ we have a similar formula of operators getting mapped to the vector $v = (a|b)$ where

- $a$ is the "$X$ part", and is of length $n$, and
- $b$ is the "$Z$ part", and is also of length $n$.

Let $P = \otimes_i P_i$, where $P_i \in \{I_i, X_i, Y_i, Z_i\}$. Then, \begin{align} a_i &= 0, b_i = 0 \text{ if } P_i = I_i, \\ a_i &= 1, b_i = 0 \text{ if } P_i = X_i, \\ a_i &= 1, b_i = 1 \text{ if } P_i = Y_i, \\ a_i &= 0, b_i = 1 \text{ if } P_i = Z_i. \end{align} For example if $n=4$, then $X_0I_1Z_2Y_3$ is associated with the vector $v=(1 0 0 1|0 0 1 1)$.

Important to note in this formulation is that we will completely ignore the phase of the operators. Meaning if $P \equiv v$, then so are $-P \equiv v$ and $\pm \iu P \equiv v$.

#### Task 1 (On paper)#

Determine the vector form of the following operators

- $X_0Z_0X_1Z_1$
- $Y_0Y_1Y_2$
- $Z_0Z_1X_2$

### Multiplying operators#

One of the immediate benefits of the binary vector form is that multiplying two Paulis corresponds to adding their vectors mod 2 (up to an overall phase).

For the simplest example, note that $X = (1|0)$ and $Z = (0|1)$ and their product is $XZ = (1|0) + (0|1) = (1|1) = Y$. Quite ingenius! Please note that we will ignore the overall phase here as $XZ = -\iu Y$, but as you delve more into error-correcting codes you will realize that such phases are not very important.

*Question:* Use the binary vector form to compute $XX$.

### Commutation relations#

One of the best advantages of writing Pauli operators as binary vectors is that commutation relations become very easy to compute.

First, we define the *symplectic inner product* between binary vectors of length $2n$

Let $P_1 = (a|b)$ and $P_2 = (c|d)$. Then, the

symplectic inner productbetween $P_1$ and $P_2$ is \begin{equation} P_1 \cdot P_2 = a\cdot d + b\cdot c\mod 2, \end{equation} where on the right hand side, the $\cdot$ is the regular dot product between vectors. Be very careful about how we are multiplying the $X$-part of $P_1$ with the $Z$-part of $P_2$ and vice versa.

**Example:** The symplectic inner product of $(10|01)$ and $(01|00)$ is
\begin{equation}
(10|01) \cdot (01|00) = (10)\cdot (00) + (01)\cdot (01) = 0 + 1 = 1.
\end{equation}

#### Task 2 (On paper)#

Let $P_1 = (101|110)$ and $P_2 = (011|111)$. Determine $P_1\cdot P_2$.

#### Task 3#

Complete the function `symplectic_inner_product`

that computes the symplectic product of two input vectors.

- Parameters:

`P1`

: a`list`

, guaranteed to only contain 0 or 1, and length divisible by 2.

`P2`

: a`list`

, guaranteed to only contain 0 or 1, and length divisible by 2. - Returns:

An`int`

that is symplectic inner product of`P1`

and`P2`

```
def symplectic_inner_product(P1, P2):
pass
```

Now we state the following theorem about the commutation relations of Pauli operators.

**Lemma:** Let $P_1 = (a|b)$ and $P_2 = (c|d)$ be two Pauli operators. Then,

- $P_1$ and $P_2$ commute if and only if $P_1 \cdot P_2 = 0$,
- $P_1$ and $P_2$ anti-commute if and only if $P_1 \cdot P_2 = 1$.

*Question:* Use the commutation relations of $I_i,X_i,Y_i,Z_i$ to prove this theorem.

#### Task 4#

In Task 1 in stabilizer codes we computed everything by hand. Now use the `symplectic_inner_product`

function to recompute the table with code.

## Generator matrix#

To compactly represent the stabilizer group, and its associated code, we usually write the generators of the stabilizer code as rows of a matrix. This matrix is called sometimes called the generator matrix (because it contains the generators of the code) or the check-matrix (because it is actually analogous to the classical parity-check matrix rather than the classical generator matrix). This is unfortunate and confusing terminology.

Example: For the repetition code for phase flips, the generators are \begin{align} X \otimes X \otimes I &= (110|000), \\ I \otimes X \otimes X &= (011|000). \end{align} Hence, the generator matrix is \begin{equation} G = \left(\begin{array}{ccc|ccc} 1 & 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 1 & 0 & 0 & 0 \end{array}\right). \end{equation}

#### Task 5 (On paper)#

Write down the generator matrix for the repetition code for bit-flips.