Accepted into the Qubit x Qubit quantum computing course and two weeks into the lectures, we learned about quantum computing in the abstract, and how quantum gates affect qubits. I think it’s important to talk about why applying two hadamard gates to a qubit returns the qubit back to its initial state.
The reason why this occurrence with 2 hadamard gates occurs is because a quantum gate is applied to each individual state separately, or in parallel. For example, if a qubit was in a 90–10 superposition and then an X-Gate was applied to that qubit, then the qubit would be in a 10–90 superposition with a 10% chance of falling into |0⟩ and a 90% chance of falling into |1⟩.
Now, let’s investigate what happens to a qubit initialized in the |0⟩ and two hadamard gates are applied to the qubit. When the qubit has one hadamard gate applied to it, the qubit is initiated into a superposition of √0.5|0⟩ + √0.5|1⟩ also known as (|0⟩ + |1⟩) / √2. Then, when the second hadamard gate is applied to the qubit the gate is applied to both gates separately, meaning that now the qubit it in a state of (|0⟩ + |1⟩) / √2 = [(√0.5|0⟩ + √0.5|1⟩) + (√0.5|0⟩ — √0.5|1⟩)] / √2. Then, when this equation is simplified, both of the |1⟩ states are cancelled out, leaving the equation of (√0.5|0⟩ + √0.5|0⟩) / √2 = 2√0.5|0⟩ / √2 = |0⟩.
There, the 1 states cancel out as well, which results in the qubit being restored to its initial state. Additionally, basically the same thing happens when the qubit is initialized into |1⟩. The only difference in this situation is that instead of the |1⟩ state cancelling out, the |0⟩ state ends up cancelling out instead, leaving the qubit to be restored to its initial state yet again.
The above description is why applying 2 hadamard gates to a qubit will return it to its initial state. This phenomenon of the states cancelling each other out is called quantum interference, which is one of the core components of quantum computing.