Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Understanding Hadamard Gates on Quantum Circuits

  1. Jun 17, 2011 #1
    Lets say I have the following quantum state:

    [itex]\frac{1}{\sqrt{2}}[/itex][itex]\left| 000\right\rangle[/itex] + [itex]\frac{1}{\sqrt{2}}[/itex][itex]\left| 111\right\rangle[/itex]

    And that I apply a Hadamard gate to each of these qubits (H[1,2,3]).
    The math shows that the resulting state will be:

    [itex]\frac{1}{2}[/itex][itex]\left| 000\right\rangle[/itex] + [itex]\frac{1}{2}[/itex][itex]\left| 010\right\rangle[/itex] + [itex]\frac{1}{2}[/itex][itex]\left| 101\right\rangle[/itex] + [itex]\frac{1}{2}[/itex][itex]\left| 111\right\rangle[/itex]

    I know how to do the math to get to the result, but i don't understand the logical reason why a [itex]\left| 000\right\rangle[/itex] and [itex]\left| 111\right\rangle[/itex] combined state generate that result. If anyone could help me understand why this happens i would appreciate it.

    Thanks in advance :smile:
  2. jcsd
  3. Jun 17, 2011 #2
    Does a qubit have 3 quantum numbers?
  4. Jun 17, 2011 #3
    It's a system with 3 qubits, hence the operator H[1,2,3].

    When I have 1 qubit, lets say a [itex]\left| 0\right\rangle[/itex], I understand that a Hadamar gate will create an equally probable quantum state that mixes [itex]\left| 0\right\rangle[/itex] and [itex]\left| 1\right\rangle[/itex], cause a Hadamar gate combines states.

    I also understand that when I have a quantum state like [itex]\left| 000\right\rangle[/itex], a Hadamar gate applied to all qubits (a H[1,2,3] operator) will generate mixed states on all qubits and produce an equally probable mix of all 8 combinations (000 001 010 011 100 101 110 111).

    But when i have the state described on the first post, i can't understand why the generated state has those apparently random combinations.
  5. Jun 17, 2011 #4
    I am not familiar with the operation, however I think there is a flaw in the math, because your not conserving probability.

    Also why are you starting with a state of two (out of eight) possibilities and why did you pick those two?
  6. Jun 17, 2011 #5
    Forgive my lack of formalism, but when i say a mix of 0 and 1, im actually refering to the state:
    [itex]\left| \psi\right\rangle = \frac{1}{\sqrt{2}} \left( \left| 0\right\rangle + \left| 1\right\rangle \right)[/itex]

    The same applies to the state of all 8 combinations with 3 qubits i mentioned, i just didnt type the probabilities cause they are equally weighted.

    There is no flaw in the math, the states in the first post are valid quantum states. You can start with whatever state you want, as long as it's a valid quantum state. I chose those two because they give a result (after applying the Hadamard gate to each qubit) that doesn't seem obvious to me and I can't understand why does the math give such a result.
  7. Jun 17, 2011 #6


    User Avatar
    Science Advisor

    Well, the short answer to your question is "quantum interference". Remember that the Hadamard transforms of |0> and |1> have different phases, so the operation of the 3-bit H-matrix on |000> and |111> will add those phases together in a well-defined way. As far as an intuitive reason why the symmetric superposition of |000> and |111> would transform that way, I don't have an answer. The only thing that jumps out is that the basis states that survive the transform are the symmetric ones .. where by symmetric I mean the ones where the bit-sequences read the same forward and backward. What happens when you apply that H-matrix to the antisymmetric superposition of |000> and |111> (i.e. [itex]\frac{1}{\sqrt{2}}\left[\left|000\right\rangle - \left|111\right\rangle\right][/itex])? I am guessing that you get the combination of the other 4 possible bit sequences?

    I am not sure what significance might be attached to this symmetry (if it is even correct) .. it could just be coincidence. It's interesting though .. I haven't thought about quantum computing for a while .. I bought a book on it once upon a time, but didn't get very far into it. Maybe I'll dig it out again.
    Last edited: Jun 17, 2011
  8. Jun 17, 2011 #7
    Thanks a lot for your reply SpectraCat. Yeah I thought it should be due to interference, but I can't really understand why it works that way. I'm studying some error correction schemes for quantum circuits and there are some 4 qubit circuits to produce certain mixture of states. I wan't to understand how does it work cause I'm sure there must be a logical way to explain it, I don't think the people that made those 4 qubit circuits started multiplying ALL possible operators hoping that by chance they would mathematically get the answer, they should have a deeper understanding so they can predict what operators will produce which combination of states (which can be seen as a sum of bit sequences in some way). I have tried using other initial states and i couldn't find a pattern that could explain the results.

    The idea was to create a circuit that would produce this state:

    [itex]\frac{1}{\sqrt{8}}\sum\left| v\right\rangle[/itex]

    where [itex]v[/itex] is a 4 bit sequence with even number of 1's (fex 0000, 0101, 1111, etc)

    How did Shor (the guy who created a circuit to do this) know that starting with [itex]\frac{1}{\sqrt{2}} \left(\left| 1111\right\rangle + \left| 0000\right\rangle \right)[/itex] and just doing a Hadamard operation to each qubit he could produce the state mentioned above. I don't think he tried all possible combinations of operators, he somehow knows how the Hadamard gate works with mixed states.
    Last edited: Jun 17, 2011
  9. Jun 18, 2011 #8


    User Avatar
    Science Advisor

    Hmm ... I did the Hadamard transform of your problem, and I got different results:

    I used the following definition of the 3-bit Hadamard matrix (ignoring normalization):

    Code (Text):

    1  1  1  1  1  1  1  1
    1 -1  1 -1  1 -1  1 -1
    1  1 -1 -1  1  1 -1 -1
    1 -1 -1  1  1 -1 -1  1
    1  1  1  1 -1 -1 -1 -1
    1 -1  1 -1 -1  1 -1  1
    1  1 -1 -1 -1 -1  1  1
    1 -1 -1  1 -1  1  1 -1
    In that basis, the vector representing your initial |000> + |111> state is just the transpose of:
    Code (Text):

    1 0 0 0 0 0 0 1
    When I carry through the multiplication, I get
    Code (Text):

    2 0 0 2 0 2 2 0
    indicating the the result of the transform should be:


    assuming I have the basis correct. I have been assuming the that indices of the column vector are ordered such that the q-bits represent binary numbers 0-7, i.e.

    Code (Text):

    If that is not correct, then perhaps I have drawn the wrong conclusion, but I still don't see how to get the answer you gave. Am I making a mistake somewhere?

    One thing I do see however, is a likely way to predict the results of the transforms .. at least for equally weighted superpositions like the ones we have been considering. The bits in the column vector select columns of the matrix, which are just added together to get the final result. In other words, if you want to get the result you initially indicated (i.e. |000> + |010> + |101> + |111>) using the indexing scheme I laid out, you would apply the transform to |000> + |101>. I imagine that if you spend some time thinking about this, you can develop a deeper intuition that allows you to predict more complicated results, like the one you mentioned in your last post.

    For that specific example with 4-bits, I understand the logic. It works like this: The Hadamard gate on each bit transforms a |0> into the symmetric linear combination, |0> + |1>, while it transforms |1> into the antisymmetric linear transform, |0> - |1>. Thus, for any even bit sequence, adding the transforms of "all bits off" (i.e. |0000> in your example) and "all bits on" (|1111> in your example) will mean that only the sequences with an even number of "on" bits can survive, because the other ones will have their phases flipped in the "all on" transform, and thus get cancelled out.
  10. Jun 18, 2011 #9
    You are right, I didn't really check my H[1,2,3] matrix and I did a careless mistake writing it down, that's why my 3 qubit examples were wrong and I could not see any logic in them :tongue:

    The last paragraph explains it very well and I now understand why |0000>+|1111> generates a mix of even bit sequences. Thanks a lot SpectraCat for taking the time to answer this, I'm eternally grateful :biggrin:
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook