# How to derive the state of a qubit after a partial measurement?

I am trying to solve a problem from the course "Quantum Information Science I" of MIT Open Learning Library, but I get stuck.

Here is the problem. Consider the below circuit where the meter sign denotes the measurement with $$\{|0\rangle,|1\rangle\}$$ basis. Suppose $$\psi_i=a|0⟩+b|1⟩$$ and $$𝑈=𝑋$$ where $$a$$ and $$b$$ are real numbers satisfying $$a^2+b^2=1$$ and $$𝑋$$ denotes the Pauli $$𝑋$$.

Find the probability of getting result $$0$$, and the state $$|\psi_𝑓⟩$$ when the measurement result is 0. Express the probability and the state in terms of $$a$$ and $$b$$. For expressing the state, use the ket notation with $$\{|0⟩,|1⟩\}$$ basis. Choose the global phase so that the coefficients are real.

My answer is as follows. When applying the circuit, I found $$|0\psi_i⟩=\frac{1}{2}\left((a+b)|00⟩+(a+b)|01⟩+(a-b)|10⟩+(b-a)|11⟩\right)$$.

Thus, I think the probability of getting 0 (for the first qubit) is $$\frac{1}{2}(a+b)^2$$.

Regarding the expression of the state $$|\psi_𝑓⟩$$ in terms of $$a$$ and $$b$$ when the measurement result is 0, I am a bit stuck. Any ideas ? What is the process for that?

Your expression of the final state and your computation of the probability of measuring $$0$$ are both correct. We thus have to find the expression of $$\left|\psi_f\right\rangle$$ once the first qubit has been measured as $$|0\rangle$$.

Mathematically, up to a normalisation factor, the expression of $$\left|\psi_f\right\rangle$$ is equal to: $$\left(|0\rangle\!\langle0|\otimes I_2\right)|\psi\rangle$$ where $$I_2$$ is the $$2\times2$$ identity matrix and $$|\psi\rangle$$ is the state just before the measurement.

When I started to learn Quantum Computing, I found it quite difficult to deal with the mathematical formalism. At the beginning of your journey, you will essentially deal with pure states and measurements performed in the basis in which you've expressed your state. The following method will allow you to find the final expression of your state once a subsystem has been measured.

We start from: $$|\psi\rangle=\frac12\left[(a+b)|00\rangle+(a+b)|01\rangle+(a-b)|10\rangle+(b-a)|11\rangle\right]$$ Thus, $$|\psi\rangle$$ is a superposition between four terms. What happens during the measurement of the first qubit is that the state will collapse. This collapse will only keep the terms that are consistent with the measurement. In this case, it will only keep the terms in which the first qubit is equal to $$0$$: $$|0\rangle\left|\psi_f\right\rangle\propto\frac12\left[(a+b)|00\rangle+(a+b)|01\rangle\right]$$ Note that I didn't write an equality symbol, but a proportionality one. Indeed, the state we've written is not a valid quantum state since its norm isn't one. Now that the first qubit isn't entangled anymore with the rest of the system, let us put it out of the expression: $$\left|\psi_f\right\rangle\propto\frac12\left[(a+b)|0\rangle+(a+b)|1\rangle\right]$$ Now, we simply have to compute the norm of this "pseudo-state" so that we can normalise it: $$\left\|\frac12\left[(a+b)|0\rangle+(a+b)|1\rangle\right]\right\|=\frac{a+b}{\sqrt{2}}$$ Thus, the final expression for $$\left|\psi_f\right\rangle$$ is: $$\left|\psi_f\right\rangle=\frac{\frac12\left[(a+b)|0\rangle+(a+b)|1\rangle\right]}{\frac{a+b}{\sqrt{2}}}=\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)$$

As a side note, we could have been a little bit faster by noting that $$\left|\psi_f\right\rangle$$ is proportional to $$\frac{a+b}{2}(|0\rangle+|1\rangle)$$, which means that $$|0\rangle$$ and $$|1\rangle$$ share the same amplitude. You can always remove the global normalisation factor (in this case, $$\frac{a+b}{2}$$) because you're going to normalise the state anyway, but it is important to keep the relative amplitudes intact.

For instance, if you start with the state: $$\frac{|00\rangle+2|01\rangle+|11\rangle}{\sqrt{6}}$$ If you measure $$|0\rangle$$ on the first qubit, the state of the second qubit is proportional to $$|0\rangle+2|1\rangle$$, which means that it is $$\frac{1}{\sqrt{5}}|0\rangle+\frac{2}{\sqrt{5}}|1\rangle$$.

@TristanNemoz's answer is perfect. I just want to emphasize an important point regarding the effect of the measurement of the ancillary qubit on the main register in the Hadamard test, which is also important in quantum phase estimation for obvious reasons.

The expression for the final state of the two-qubit system comprising the ancilla and the qubit in the main register can be cast in a simpler form:

$$\begin{equation} |\psi \rangle = \frac{a+b}{\sqrt{2}}|0\rangle \otimes |+\rangle \; + \; \frac{a-b}{\sqrt{2}}|1\rangle \otimes |-\rangle. \end{equation}$$

From visual inspection, it is immediately clear that, upon measuring the ancilla in state $$|0\rangle$$ ($$|1\rangle$$) the main register is projected onto state $$|+\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}}$$ $$\Big( |-\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}} \Big)$$. The modulus squared of the prefactors of the two terms in the equation above yield the probabilities of the two measurements.

Of course, this is not a coincidence. The reason why we could simplify this expression in such an elegant way is the fact that we made use of the eigenbasis of $$U$$ ($$X$$ in this case). Upon measuring the ancilla in the $$Z$$ basis, if we obtain state $$|0\rangle$$ ($$|1\rangle$$), which is the eigenstate of $$Z$$ with eigenvalue $$+1$$ ($$-1$$), we retrieve in the main register the corresponding eigenstate of $$U$$ with the same eigenvalue $$+1$$ ($$-1$$).

This is precisely why quantum phase estimation is such a promising algorithm to find the ground state (or an exact eigenstate, more generally) of a unitary operator (which could be the complex exponential of an Hermitian operator, like an Hamiltonian) given just an initial state with nonzero overlap with the target eigenstate. Upon measuring an eigenvalue in the ancillary register, the main register is projected onto the corresponding eigenstate.