2
$\begingroup$

Applying the above construction to AND we get the map $(x1,x2,y) \rightarrow (x1,x2,y⊕(x1∧x2))$ for $x1,x2,y \in \{0,1\}$. The unitaryoperator which implements this is then simply the map $|x1〉|x2〉|y> \rightarrow |x1〉|x2〉|y \oplus (x1∧x2)〉$.

Written as a matrix with respect to the computational basis this is

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

How can you just spot what the matrix is with respect to the computational basis?

$\endgroup$
2
$\begingroup$

This is the CCNOT gate, but let's try to derive it. Note that the action of the matrix on $|000\rangle$ is the first colomn of the matrix. Let me use a 2-dimensional case in order to have smaller matrices. So I am going to prove that the first column is the state after applying the matrix to the $|00\rangle$ state:

$$ A |00\rangle = \begin{pmatrix} a_{11}&a_{12}&a_{13}&a_{14}\\ a_{21}&a_{22}&a_{23}&a_{24}\\ a_{31}&a_{32}&a_{33}&a_{34}\\ a_{41}&a_{42}&a_{43}&a_{44} \end{pmatrix} \begin{pmatrix} 1\\0\\0\\0 \end{pmatrix} = \begin{pmatrix} a_{11}\\ a_{21}\\ a_{31}\\ a_{41} \end{pmatrix} $$

Another example for $|10\rangle$:

$$ A |10\rangle = \begin{pmatrix} a_{11}&a_{12}&a_{13}&a_{14}\\ a_{21}&a_{22}&a_{23}&a_{24}\\ a_{31}&a_{32}&a_{33}&a_{34}\\ a_{41}&a_{42}&a_{43}&a_{44} \end{pmatrix} \begin{pmatrix} 0\\0\\1\\0 \end{pmatrix} = \begin{pmatrix} a_{13}\\ a_{23}\\ a_{33}\\ a_{43} \end{pmatrix} $$

This is true also for other computational basis states. Here is the truth table for the transformation described in the question:

$$\begin{array}{c|c} |x_1 x_2 y \rangle & |x_1 x_2 (y \oplus x_1 ∧x_2) \rangle\\ \hline |000 \rangle & |000 \rangle \\ |001 \rangle & |001 \rangle \\ |010 \rangle & |010 \rangle \\ |011 \rangle & |011 \rangle \\ |100 \rangle & |100 \rangle \\ |101 \rangle & |101 \rangle \\ |110 \rangle & |111 \rangle\\ |111 \rangle & |110\rangle \end{array}$$

So we just need to put in the first column the vector that is presented as an output for $|000\rangle$, the second column is the output of the $|001\rangle$, and so on. From truth table one can notice that the first 6 columns will coincide with the input basis vectors, and the 7th column will be equal to $|111\rangle$ and 8th column will be equal to $|110\rangle$. This way we will obtain the matrix presented in the question: the CCNOT gate.

More schematically if we have some $M$ matrix, for which we only know the outputs for basis vectors, then (for our case):

$$M = \big(M|000\rangle \; M|001\rangle \; M|010\rangle \; M|011\rangle \; M|100\rangle \; M|101\rangle \; M|110\rangle \; M|111\rangle \big) = \\ = \big(|000\rangle \; |001\rangle \; |010\rangle \; |011\rangle \; |100\rangle \; |101\rangle \; |111\rangle \; |110\rangle \big) = \\ = \begin{pmatrix} 1&0&0&0&0&0&0&0\\0&1&0&0&0&0&0&0\\0&0&1&0&0&0&0&0\\0&0&0&1&0&0&0&0\\0&0&0&0&1&0&0&0\\0&0&0&0&0&1&0&0\\0&0&0&0&0&0&0&1\\0&0&0&0&0&0&1&0 \end{pmatrix} $$

Also, this might be interesting answer for a different matrix. I have used the approach presented there.

| improve this answer | |
$\endgroup$
  • $\begingroup$ how do you make the leap from the truth table to the matrix? $\endgroup$ – Permian Jun 13 at 16:17
  • $\begingroup$ @Permian the outcome vectors in the truth table are the columns of the matrix. $\endgroup$ – Davit Khachatryan Jun 13 at 16:18
  • $\begingroup$ @Permian I have added some details in the answer about the matrix construction. $\endgroup$ – Davit Khachatryan Jun 13 at 16:37
3
$\begingroup$

Whenever a unitary is a permutation matrix, it corresponds to an operation which can be described using a simple truth table. In other words, it corresponds to a simple reshuffling of computational basis elements.

Once you notice this, you just need to observe that the $i$-th column of the matrix tells you where the $i$-th state is sent (where some ordering of the states has been defined). More precisely, the $i$-th input state is sent to the $j$-th output state with $j$ the row in the $i$-th column that corresponds to a value $1$.

For example, observe in your case how the first column tells you that the first input is sent to the first output. The second column tells you that the second input is sent to the second output. More generally, the $i$-th input is sent to the $i$-th output for all $i=1,...,6$. However, the seventh input goes to the eigth output, and the eight input to the seventh output.

The standard ordering in the computational basis for three qubits is $$|000\rangle, |001\rangle, |010\rangle, |011\rangle, |100\rangle, |101\rangle, |110\rangle, |111\rangle.$$ This means that the matrix corresponds to the following transformation rules: $$ |000\rangle \to |000\rangle, \quad |001\rangle \to |001\rangle, \quad |010\rangle \to |010\rangle, \\ |011\rangle \to |011\rangle, \quad |100\rangle \to |100\rangle, \quad |101\rangle \to |101\rangle, \\ |110\rangle \to |111\rangle, \quad |111\rangle \to |110\rangle, $$ which you can observe corresponds to a CCNOT operation.

| improve this answer | |
$\endgroup$
1
$\begingroup$

Something that might help is that this gate is pretty common - it's the Toffoli! (or CCNOT).

More generally, you can make matrices by considering the action of the unitary on every input; for example, what is Toffoli($|000\rangle$), Toffoli($|001\rangle$), ... etc.

Notice that the first two bits are unaffected, and the third bit is only changed from $|y\rangle$ when $x_1, x_2$ are $1$. So, the only inputs where the transformation isn't the identity is $|110\rangle, |111\rangle$. Running through the computation, Toffoli($|110\rangle$) = $|111\rangle$ and Toffoli($|111\rangle$)=$|110\rangle$, which is shown in the matrix.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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