# Use of change of phase gates

As explained in this this answer, when we have different (relative) phases between two states, those two states will yield the same probabilities when measured in the same basis but different probabilities when measured in different bases.

My question is why would we need to do measurement in different bases?
I'm asking from a quantum programming point of view. Why would I need to change the (relative) phase of two states when writing a program?

One constraint though: I don't understand how to read a Bloch sphere so the matrix and circuit formalisms are preferred.

My question is why would we need to do measurement in different bases? I'm asking from a quantum programming point of view.

Quantum programs are usually written to implement some quantum algorithm. Depending on the algorithm you might need to change the basis of measurement at some point.

For instance, Bell state measurement is useful in the quantum teleportation protocol.

Strictly, it's never necessary to measure in different bases, because any projective measurement can be decomposed as a unitary followed by a projective measurement in the computational basis. Conversely, there are times when algorithms are described as unitaries followed by measurements in the computational basis, and you might choose to move some of those unitaries into a description of the basis.

The point I'm trying to make here is that the division between measurement and the rest of an algorithm is fairly arbitrary, so to get to the heart of your question, we really have to ask about the importance of relative phases inside a quantum algorithm. These are absolutely crucial, as these are what provide for the constructive and destructive interference that permit outcomes different from classical computation. Take a look at Deutsch's algorithm for the simplest, 1 qubit, example. This is usually described as -prepare $|0\rangle$ state, Hadamard, function evaluation, Hadamard, measure in computational basis- but you could describe it as -prepare $|+\rangle$ state, function evaluation,measure in $|\pm\rangle$ basis-. The function evaluation, the thing you really want to get at, is entirely encoded in the relative phase between the two states.

To give one extreme example, consider measurement-based quantum computation. Here, we produce a standard quantum state, and the computation to be performed is entirely defined by the choice of single-qubit measurements that are performed.

• Allow me to ask: if my understanding is correct, it is because of interference that we get the original qubit by a successive application of a Hadamard gate (2 in a row), correct? – Ntwali B. Jun 25 '18 at 18:33
• Yes, assuming the function evaluation has $f(0)=f(1)$. – DaftWullie Jun 25 '18 at 18:42

The phase mentioned in that question and answer are of the form: $$P = \begin{bmatrix} e^{i\theta} & 0 \\ 0 & e^{i\phi} \end{bmatrix}$$ so, they are not global phases. However, two particular states, aka its eigenstates, are unaffected by this relative phase operator. Because, this operator is diagonal it means the basis we are currently using is their eigenstate.