# Why do computer scientists care about the phase of qubits?

When I design some classical register, flip-flop, binary counter, small byte of RAM, etc from scratch with classical logic gate, I never deal with such binary direction because classical bit doesn't have direction.

I only care about whether its state currently in 0 or 1. Yes in classical gate, the magnitude amplitude is always deterministic (magnitude=1 or magnitude=0).

I accept the notion of this magnitude because it's useful for superposition state therefore it's useful for parallel computation. But why we need to know its phase angle too? What is the simple example of phase application? When I was designing full-adder that was discovered by Feynman as a simple example with just using Toffoli (CCNOT) and CNOT, I still don't have business with direction (phase angle).

So why should we care about phase angle (direction) in qubit state?

Update:

As far as I understand from average answers, the most simple example of phase application is for distinguish superposition state from previous state.

For example: To make a superposition state from a qubit, we put Hadamard gate H.

If the previous state was |0>, then it became superposition state |+>.

If the previous state was |1>, then it became superposition state too, but with rotating phase (π). Hence the superposition state is |->.

So if we put the Hadamard gate again, If the superposition state is |+>, then it will became |0> again. If the superposition state is |->, then it will became |1> again.

I'm as a computer engineer (not computer scientist), from explanation above I think in another word the phase is useful for storing previous state (memory) in case of Hadamard gate.

What I mean with storing is, |+> and |-> are both superposition state with carrying information about its previous state (we can think it act as memory). |+> the previous state was |0>, while |-> the previous state was |1>.

So when someone say hey, it's in superposition state., If we care about its previous state, we wouldn't know unless that someone write it mathematically with|+> or |->. Or tells explicitly like hey, it's in superposition state with phase angle π. then we know that the previous state was |1>.

But Hadamard gate is playing with rotating phase to the π. How about rotating phase to the π/2?. What case can I do for rotating phase to the π/2.

• Phase could be global or relative. Global phase could be ignored mathematically. I found nice write up here: when computing the dynamics of a physical system, only energy differences, not absolute values, are important. Oct 18, 2022 at 3:08

The phase component is what makes quantum computing different from classical probabilistic computing. If your quantum computer was not able to implement a phase on your qubit, you could perform everything as efficiently on a classical computer. When you allow for phases, you can cause interference (where for example you can "nullify" wrong answer and "boost" correct answers) which can lead to more efficient algorithms (although this isn't always so obvious!).

1. For a simple example of how phases can lead to interference, I would recommend this small discussion: https://quantumcomputing.stackexchange.com/a/27693/14597.
2. For a simple example showcasing how quantum algorithms can use interference to be more efficient than a classical computer, I would recommend looking at the wikipedia page on the Deutsch-Jozsa algorithm: https://en.wikipedia.org/wiki/Deutsch%E2%80%93Jozsa_algorithm.
3. For a less contrived but more complicated example, I will shamelessly plug my blog post on Shor's algorithm :) https://rajkk1.medium.com/finding-the-prime-factors-of-a-large-number-efficiently-with-the-help-of-shors-algorithm-e731f0aadff5.
• "If your quantum computer was not able to implement a phase on your qubit, you could perform everything as efficiently on a classical computer", are you sure this is true, since Toffoli + H is a universal gate set? Oct 18, 2022 at 14:14
• That's a subtle one! I believe you are referring to the work by Yaoyun Shi (arxiv.org/abs/quant-ph/0205115) and Dorit Aharonov (arxiv.org/abs/quant-ph/0301040). To be mores specific, they talk about the notion of "computational universality". This is where you have a universal gate set where "the set of gates can be used to perform general quantum computation, without too much overhead." In the case of the {Toffoli, H} set, the overhead is actually a few (polylogarithmic) ancilla qubits that are themselves already prepared in a superposition state with a relative phase. Oct 19, 2022 at 15:48
• Interesting! I thought H + Toffoli was universal, I did not know about this requirement, thanks! Oct 19, 2022 at 16:13
• On a separate note, you can implement phases with just the Toffoli + H gates without any special qubits. E.g. in $H_3CCNOTH_2H_1|000\rangle$ (where the subscripts indicate which qubit to act the gate on) the $|111\rangle$ term will have a negative amplitude (or phase of $\pi$). But this doesn't make it a general quantum computer - being able to create a phase is a necessary but not sufficient condition for general quantum computation. In this case you can hand-wave the reason as not being able to create complex amplitudes, but I believe there are more general theorems about this. Oct 19, 2022 at 19:06
• Hi @TristanNemoz! I somehow came across this topic again and I realised I might have been slightly wrong in my previous conclusions! I was correct that a gate set needs to be able to implement a phase on your quantum computer for it to be universal (which Toffoli + H can as explained above). And it is also true that you could need an additional poylogarithmic number of Toffoli+H gates and ancilla qubits to implement an arbitrary circuit. But I think where I was mistaken was that those ancilla qubits can also be prepared using only Toffioli+H gates. I'm not 100% sure, but I think that's it! Aug 10 at 7:15

The phase of a qubit state matters partially defines superposition states. For a simple example, the Hadamard gate is a basic logic gate that maps $$|0\rangle \leftrightarrow |+\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$ and $$|1\rangle \leftrightarrow |-\rangle = \frac{1}{\sqrt{2}}(|0\rangle - |1\rangle)$$. In words, the Hadamard gate maps computational basis states to superposition states with different phases, and vice versa.

For a more powerful case, there's also the Quantum Fourier Transform which is the key step in Shor's algorithm, among others. It works by generating different phases on different basis states such that the resulting state's superposition cancels out the "wrong" answers' probability amplitudes while amplifying those for the "correct" answers. I realize this a little bit of a hand-wavey explanation, but hopefully it helps.

At a very practical level, the phase tells you about the outcome probabilities in some other measurement basis.

For example, $$|0\rangle+|1\rangle$$ and $$|0\rangle-|1\rangle$$ might appear identical when measured in the computational basis, but measure in the $$X$$ basis (or equivalently, perform an $$H$$ rotation and then measure in the computational basis) and you'll find they give completely different results.

• The $|0\rangle\pm|1\rangle$ is not valid state vector, CMIIW. Oct 17, 2022 at 7:55
• the normalisation factor is not really important for these discussions. You can assume every vector is used to represent its normalised counterparts if you prefer
– glS
Oct 17, 2022 at 10:44
• So far I understand your answer. Also most answer talking about Hadamard gate which basically rotating the phase to the $\pi$ if the state is $|1\rangle$, otherwise ($|0\rangle$) it will not rotate the phase. That's why it will give different result in the X-basis measurement. How about the other phase rotation? like $\pi/2$? I mean why should I rotate it? Oct 18, 2022 at 0:06

Let

$$|\pm\rangle = \frac{1}{\sqrt{2}}(|0\rangle \pm |1\rangle)$$

If we don't distinguish phase then $$|+\rangle$$ and $$|-\rangle$$ would look like the same state.

Let

$$H = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1 \\ 1 & -1\end{pmatrix}$$

We can see that $$H|+\rangle = |0\rangle$$ and $$H|-\rangle = |1\rangle$$. We see that $$|+\rangle$$ and $$|-\rangle$$ result in different states when acted on by the same operation $$H$$. This therefore leads us to conclude that $$|+\rangle$$ and $$|-\rangle$$ are in fact different and can't be considered to be the same, despite having the same amplitudes for $$|0\rangle$$ and $$|1\rangle$$.