# Method to derive Matrix description of a circuit [duplicate]

This question is about finding a matrix description of a specific circuit. I am learning quantum computing through edX's Quantum Information Science lecture series. The question below is the one I am stuck on Could someone please explain a systematic way to go about finding the matrix representation of a 2-qubit circuit (so that I can apply it to this)

• Do you know what the truth-table is for the above circuit? May 6 at 18:13

You have to multiply the matrices associated with gates. When matrix is applied at only one qubit, you have to do tensor product with identity matrix n-1 times, where n is number of qubit of your circuit. In your case: $$\begin{bmatrix} 0&1\\ 1&0\\ \end{bmatrix} \otimes \begin{bmatrix} 1&0\\ 0&1\\ \end{bmatrix}=\begin{bmatrix} 0&0&1&0\\ 0&0&0&1\\ 1&0&0&0\\ 0&1&0&0\\ \end{bmatrix}$$

$$\begin{bmatrix} 0&0&1&0\\ 0&0&0&1\\ 1&0&0&0\\ 0&1&0&0\\ \end{bmatrix} \begin{bmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&0&1\\ 0&0&1&0\\ \end{bmatrix} \begin{bmatrix} 0&0&1&0\\ 0&0&0&1\\ 1&0&0&0\\ 0&1&0&0\\ \end{bmatrix}=\begin{bmatrix} 0&1&0&0\\ 1&0&0&0\\ 0&0&1&0\\ 0&0&0&1\\ \end{bmatrix}$$

• Thank you for the explanation May 6 at 19:18

An alternative method, as compared to the existing answer, is perhaps better suited to this specific case where you already know some of the structure of the output matrix.

Label each of the columns in binary in numerical order: 00, 01, 10, 11. Label the rows the same. Now, columns correspond to inputs, and rows correspond to outputs.

So, let's say you want to know the matrix element in the first row and second column. In effect, you are asking "what is the probability amplitude for a state that starts in $$|01\rangle$$ to end in $$|00\rangle$$?".

Thus, make the input $$|01\rangle$$. You can run through the action of the circuit $$|01\rangle\rightarrow|11\rangle\rightarrow |10\rangle\rightarrow |00\rangle.$$ So, the probability amplitude for arriving in state $$|00\rangle$$ is 1. Hence, that matrix element is 1.

There's an extra trick you can use here. You evolution is unitary (there's no measurement). Unitary matrices have rows and columns that have sum-mod-square of 1. Hence, if you know one element is 1, every other element in that row and column must be 0.