# Toffoli Gate Matrices

Here are the different toffolis (or maybe one of them is toffoli and the others are very similar to toffoli gates)

My question is:

1. we know the matrix of the number 1 Toffoli:

What are the matrices for other two toffoli gates?

• I would recommend to write down a map how three-qubit basis states (000, 001, 010, 011, 100, 101, 110, 111) are changed with the gates. Then convert the resulting basis states to vector representation and put them into a matrix (as columns) in the same order as the input states in the bracket above. Nov 28, 2022 at 7:10
• An answer to a very similar question which will show you how to answer your own question :) quantumcomputing.stackexchange.com/questions/28315/… Nov 28, 2022 at 12:49
• very helpful, thanks :) Nov 28, 2022 at 23:15

The problem is much easier to think about in turns of permutations. You can see that the matrix you created simply swaps the last two elements of the statevector: $$[a_{000}, a_{001}, a_{010}, a_{011}, a_{100}, a_{101}, a_{110}, a_{111}]$$ becomes $$[a_{000}, a_{001}, a_{010}, a_{011}, a_{100}, a_{101}, a_{111}, a_{110}]$$

The middle gate above swaps $$a_{010}$$ and $$a_{011}$$. The right gate swaps $$a_{100}$$ and $$a_{101}$$. The matrix is the identity matrix, but the two $$1$$s corresponding to these two rows are moved to the opposite corners of the square they are corners of.

And yes, the two gates, together, make an odd parity check.

• From the three examples you have, you should be able to understand the pattern of which two states swap on a CNOT. I really think you should figure this out for yourself, to show you understood my answer. Nov 28, 2022 at 17:46
                             -----UPDATED------


Thanks to @Rajiv Krishnakumar, I solved the problem by this link Here are my toffolis:

The other two toffoli was already found yesterday: