# Why is an X gate a quantum coin flip?

I am reading this page of Qiskit's textbook. I noticed that it extends coin games to quantum computers by defining an $$X$$ gate to be a classical coin flip. However, I do not understand this. For example, a coin flip in the classical world can start in $$\psi = \{ \left | 0 \right >, \left | 1 \right > \}$$, and end in $$\psi^\prime = \{ \left | 0 \right >, \left | 1 \right > \}$$.

However, in the quantum case, we can still start with $$\psi = \{ \left | 0 \right >, \left | 1 \right > \}$$, but $$X\psi$$ only flips the state of the coin. For example, if $$\psi = \left | 0 \right >$$, then $$\psi^\prime = \left | 1 \right >$$.

The $$X$$ operator is not random, unless the coin is already in superposition ($$\left | + \right >$$, in specific). Is there a reason that this is allowed? Why can we assume that the coin will already be $$\left | + \right >$$?

• It sounds like the author of that page mistakenly wrote "flip the coin" (which implies a random result) when they should have written "turn over the coin." Sep 28, 2022 at 13:05
• I think that is due to the common description of the $X$ gate as a bit-flip gate. That's why I suggested the term "coin toss" for the random result generator in that case which is the $H$ gate. But I am not an english expert though.
Sep 28, 2022 at 13:44
• I see, this was only a semantics issue in that case. Thank you all. Sep 28, 2022 at 15:43

$$X$$ gate is like a coin flip (= take a coin laying on a table. flip it from heads to tails or vice versa. no air time). $$H$$ gate is like a coin toss (= take a coin laying on a table and throw it up in the air).

$$X|0\rangle = |1\rangle$$ and $$X|1\rangle = |0\rangle$$. It works also for superposition input states - the $$X$$ gate flips their amplitudes: Let $$|\psi\rangle = \alpha|0\rangle + \beta|1\rangle$$, then $$X|\psi\rangle = \beta|0\rangle + \alpha|1\rangle$$. We are not assuming anything about the initial state $$|\psi\rangle$$, the $$X$$ gate (and any other unitary gate) treats every input state in the same way - in the case of the $$X$$ gate is flipping the state’s amplitudes.

The $$H$$ gate can be thought like a coin tossing - $$H|0\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}}$$ and $$H|1\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}}$$ - I.e a quantum state which is in one of the computational basis state (= heads or tails) transforms to a quantum state with 50% chance to measure $$|0\rangle$$ and 50% chance to measue $$|1\rangle$$ (= a coin in the air). If the initial quantum state, before applying the $$H$$ gate, was a some superpostion state, let it be $$|\psi\rangle = \alpha|0\rangle + \beta|1\rangle$$ - Then:

$$H|\psi\rangle = \alpha \left(\frac{|0\rangle + |1\rangle}{\sqrt{2}}\right) + \beta \left(\frac{|0\rangle - |1\rangle}{\sqrt{2}}\right) = \left(\frac{\alpha + \beta}{\sqrt{2}} \right)|0\rangle + \left(\frac{\alpha - \beta}{\sqrt{2}} \right)|1\rangle$$

And if one insists to find classical metaphores, then it can be thought of as an attempt to toss a coin while already in tha air. Again, quantum unitary gates don't care about the input states - their functionality is defined by their matrix operators, and they treat every input state in the same manner.

I think the whole point of the experiment is just to show that your opponent (the quantum computer) can win the problem with probability 1.

That is, applying the Hadamard gate to the computational basis state $$|0>$$ the coin flipping of the human player becomes irrelevant.

• Hi, thank you for your answer. I understand that much, however I think that the idea of using an X gate when the state is not already Hadamarded doesn’t work. I don’t get why this does this not matter. What if we instead had a game where the non-quantum player (the human) went first— we wouldn’t be able to implement a coin flip with just X in that case. Sep 28, 2022 at 4:36
• You could play the opposite game: start with the state |+>, and use a Z to do the coin flip. The game is only an example, and I have the feeling you are complicating your life! Either that, or I am missing something in your question :D Sep 28, 2022 at 8:59