Why can I apply $HS^\dagger$ and then measure in the computational basis to measure $Y$?



I come from a CS background

I was reading Neven and Farhi's paper ("Classification with Quantum Neural Networks on near Term Processors"), and I am trying to implement the subset parity problem using Qiskit, and solve it using a quantum Neural Network.

There is one thing that doesn't make sense to me though. In the paper, they measure "the Pauli Y gate on the readout qubit" (perhaps this phrasing is wrong, as I have to admit that whenever one does not measure in the computational basis, the whole thing doesn't make sense to me anymore). In one of the questions I already asked on this site, I was told that measuring in a basis other than the computational basis is simply the same as applying a matrix to the qubit and then measuring it in a computational basis.

Through various research, I was able to determine that, for this problem "to measure the Pauli Y gate the readout qubit", I had to apply $HS^{\dagger}$ and then measure in the computational basis in order to obtain the same result. It works, but I don't understand why it has to be this matrix in particular (is there any mathematical proof that shows that this is indeed this matrix ?)


Posted 2020-05-01T00:24:31.153

Reputation: 223



Your normal measurement is a pauli-$Z$ measurement. If you apply a unitary $U$ just before measurement, this transforms the $Z$ measurement into $U^\dagger ZU$. So, any $U$ that transforms $U^\dagger ZU=Y$ will do the job. One convenient way of doing this is $$ \frac{Y+Z}{\sqrt{2}}, $$ but your choice will also work: $$ SHZHS^\dagger=SXS^\dagger=-iS^2X=-iZX=Y $$

If you want to know why it's the transformation $U^\dagger ZU$, well think about a circuit with input $|\psi\rangle$ that has a unitary $U$ enacted upon it, and then it's measured in the standard basis. The probability of getting the 0 answer is $$ |\langle 0|U|\psi\rangle|^2, $$ which is the same as the probability that $|\psi\rangle$ is in the state $U^\dagger|0\rangle$. This corresponds to a measurement projector $U^\dagger |0\rangle\langle 0|U$, so you can see that transformation starting to come out.


Posted 2020-05-01T00:24:31.153

Reputation: 35 722

Got it, thank you – Skyris – 2020-05-01T08:18:27.690

Just a question though. Why is the normal measurement a Pauli Z mesurement – Skyris – 2020-05-27T13:27:54.813

The Pauli Z matrix is diagonal in the standard measurement basis. – DaftWullie – 2020-05-27T13:50:47.153


Measurement in $Y$ basis means that we want to measure is the qubit in $|+i\rangle$ state or $|-i\rangle$ state which are eigenbasis vectors for $Y$ gate. Because they are eigenbasis vectors we can express any $|\psi_1 \rangle$ state in this form:

$$| \psi_1 \rangle = \alpha_{+i} |+i\rangle + \alpha_{-i} |-i\rangle$$

where $|\alpha_{+i}|^2$ is the probability of measuring $|+i\rangle$ state and $|\alpha_{-i}|^2$ is the probability of measuring $|-i\rangle$. And

\begin{equation} |+i\rangle = |0\rangle + i |1\rangle \qquad |-i\rangle = |0\rangle - i |1\rangle \end{equation}

Now when we apply $HS^{\dagger}$ to $|\psi_1 \rangle$ state, we will obtain:

$$| \psi_2 \rangle = \alpha_{+i} |0\rangle + \alpha_{-i} |1\rangle$$

Then, with $|\alpha_{+i}|^2$ we will measure $|0\rangle$ (the same probability that we had for $|+i \rangle$ measurment in the initial $|\psi_1\rangle$), and with with $|\alpha_{-i}|^2$ we will measure $|1\rangle$ (the same probability that we had for $| -i \rangle$ measurment in the initial $|\psi_1\rangle$). For any gate that will do $U |+i\rangle = e^{i \varphi_1} |0\rangle$ and $U |-i\rangle = e^{i \varphi_2}|1\rangle$ mapping (where $\varphi_1$ and $\varphi_2$ are some phases that will not have any influence on probabilities), we will have this correspondence. For example, if I understand this Riggeti's code right, they are doing $Y$ basis measurement by applying firstly $U = R_x(\pi /2)$ gate that maps $R_x(\pi /2) |+i\rangle = |0\rangle$ and $R_x(\pi /2) |-i\rangle = -i|1\rangle$.

The other thing is to measure the expectation value of $Y$ operator:

$$\langle \psi_1 | Y | \psi_1 \rangle = |\alpha_{+i}|^2 - |\alpha_{-i}|^2$$

that can easily be calculated after enough measurements in the $Y$ basis. Here we took into accout that $Y|+i\rangle = (+1)|+i\rangle$ and $Y|-i\rangle = (-1)|-i\rangle$. $|\alpha_{+i}|^2 = \frac{N_{+i}}{N}$ and $|\alpha_{-i}|^2 = \frac{N_{-i}}{N}$, where $N$ is the number of measurements, $N_{+i}$ is the number of $| +i \rangle$ measurements, and $N_{-i}$ is the number of $| -i \rangle$ measurements.

I guess in the paper they mean expectation value of $Y$ operator, not just one simple measurement in the $Y$ basis, because of this line "Our predicted label value is the real number between $−1$ and $1$... which is the average of the observed outcomes if $Y_{n+1}$ is measured in multiple copies of...".

Davit Khachatryan

Posted 2020-05-01T00:24:31.153

Reputation: 3 583

1You're right, in the paper, they compute the expectation value of Y. Since I am implementing this on a simulator, I run the circuit multiple times and compute the probabilities just like you mentioned. However, the simulator only does measurements in the computational basis, hence my question – Skyris – 2020-05-27T13:21:30.750