# Cannot derive probability graph for Hadamard gate given in Qiskit textbook

I am reading the Qiskit textbook(beta) and they have explained Hadamard gate using an amplitude tree. To show how two H-gates on a qubit give the output as 0 everytime they said to consider that it reverses the direction of the qubit when the input and output state of the qubit is 1.(as shown in the image below) Following this, if we apply 2 H-gates on a qubit in state 1, the output they said would similarly always be 1 but when I made that tree, it again came out as 0 as shown below. Edit: My conclusion about the H-gate stated as "it reverses the direction of the qubit when the input and output state of the qubit is 1" was the wrong idea that led to the incorrect amplitude tree. You can find the correction pointed out in the answer marked correct.

• In the future, please include a link to the page you are referencing so that anyone trying to help does not have to go search it out for themselves! I have included the link in my response by putting [square brackets around the words that will be the link](with the website in round brackets beside it). Hope this helps! Oct 6, 2022 at 15:03
• Got it. And thanks!
– Rai
Oct 6, 2022 at 15:12

Edit: Starting with $$|1\rangle$$ The mistake is in the bottom right of your diagram. After your first Hadamard gate, the structure of the diagram leaving the $$|1\rangle$$ must be identical to what you did in the first Hadamard of your diagram. (Hadamard acts on $$|1\rangle$$ the same every time, so the diagram is the same.) With this change you should get the amplitude 1 for $$|1\rangle$$ and 0 for $$|0\rangle$$ If you make the bottom right red box identical to the first red box, your answers will work out!

• What I understood is that the amplitude of state |1> is coming out to be 0. But shouldn't it be 1 because the final state will always be |1> if we started with |1>?
– Rai
Oct 6, 2022 at 15:09
• When you applied the second Hadamard you were not in a pure |1> state, you were in a superposition of |0> and |1>. Oct 6, 2022 at 15:13
• I confess, I may have lost my mind. I thought you had started with the |0> state for some reason. Will ammend answer shortly. Oct 6, 2022 at 15:21
• Ok got it! Now that you pointed it out, it makes sense . Thanks!
– Rai
Oct 6, 2022 at 15:40