## Quantum Country exercise 16

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 $\vert x \rangle$, $\vert y \rangle$, and $\vert z \rangle$ the output states of the Toffoli gate are $\vert x \rangle$, $\vert y \rangle$, and $\vert z \oplus \left( x \wedge y \right) \rangle$.

If those output states are used as the input states to a second Toffoli gate, the first two output states will again be $\vert x \rangle$ and $\vert y \rangle$. The third output state will be $\vert \left[ z \oplus \left( x \wedge y \right) \right] \oplus \left( x \wedge y \right) \rangle$. We have $\left[ z \oplus \left( x \wedge y \right) \right] \oplus \left( x \wedge y \right) = z \oplus \left[ \left( x \wedge y \right) \oplus \left( x \wedge y \right) \right]$

The expression $x \wedge y$ will have either the value 0 or the value 1. If it has the value 0 then we have $z \oplus \left[ \left( x \wedge y \right) \oplus \left( x \wedge y \right) \right] = z \oplus \left( 0 \oplus 0 \right) = z \oplus 0 = z$

If it has the value 1 then we have $z \oplus \left[ \left( x \wedge y \right) \oplus \left( x \wedge y \right) \right] = z \oplus \left( 1 \oplus 1 \right) = z \oplus 0 = z$

We therefore have $\left[ z \oplus \left( x \wedge y \right) \right] \oplus \left( x \wedge y \right) = z$

so that the third output state from the second Toffoli gate is simply $\vert z \rangle$. Since the first and second output states from the second Toffoli gate were $\vert x \rangle$ and $\vert y \rangle$, 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.

This entry was posted in quantum country. Bookmark the permalink.