# What is the unitary matrix for this two qubit circuit with $H$ and $I$?

Above is a circuit I am provided. I am asked to write down the matrix representation of a $$4 \times 4$$ matrix representation of a unitary matrix for this circuit.

Using small endian notation (left to right):

The initial state is $$|\psi\rangle = |x\rangle |y \rangle$$

Then, $$(H \otimes I) |x \otimes y \rangle = H|x\rangle \otimes I|y\rangle$$ for the post - gate state.

The matrix representation for the unitary matrix $$(H \otimes I)$$ is

$$\frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 & 0 & 0 \\ 1 & -1 & 0 & 0 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & -1 \end{bmatrix}$$

Am I correct?

• Whether this is correct depends on the endian-ness convention you are using. Is H on the top qubit and I on the bottom qubit $H \otimes I$ or is it $I \otimes H$. You've correctly computed $I \otimes H$. I think that's the less common convention, but it is used e.g. in Quirk. Commented Oct 7, 2023 at 16:18

$$H \otimes I = \frac{1}{\sqrt{2}} \begin{pmatrix} 1\times I & 1 \times I \\ 1 \times I & -1 \times I \end{pmatrix} = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ 1 & 0 & -1 & 0 \\ 0 & 1 & 0 & -1 \end{pmatrix}.$$