This is one in a series of posts working through the exercises in the Quantum Country online introduction to quantum computing and related topics. The exercises in the original document are not numbered; I have added my own numbers for convenience in referring to them.
Exercise 16. Show that the inverse of the Toffoli gate is the Toffoli gate itself.
Answer: With input states , , and the output states of the Toffoli gate are , , and .
If those output states are used as the input states to a second Toffoli gate, the first two output states will again be and . The third output state will be . We have
The expression will have either the value 0 or the value 1. If it has the value 0 then we have
If it has the value 1 then we have
We therefore have
so that the third output state from the second Toffoli gate is simply . Since the first and second output states from the second Toffoli gate were and , the output states of the second Toffoli gate are the same as the input states of the first Toffoli gate. The Toffoli gate therefore acts as its own inverse.