# How does measurement change the effective transformation matrix?

I have simulated three cases in Qiskit and tried doing some manual calculations to verify the simulated results.

Case 1: The initial state is $$\psi_i = |00\rangle = \begin{Bmatrix}1 \\0 \\ 0 \\ 0\end{Bmatrix}$$ and the transformation is $$H_2 = H_1 \otimes H_1 = \frac{1}{2}\begin{bmatrix}1 & 1 &1 &1 \\1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1\end{bmatrix}$$. Therefore, the final state would be $$\psi_f = \frac{1}{2} \begin{Bmatrix}1 \\1 \\ 1 \\ 1\end{Bmatrix}$$.

This is matching with the simulation results.

Case 2: Since the first qubit is being measured, the state of first cubit collapses to $$|0\rangle$$, and the second qubit undergoes Hadamard transformation, the effective transformation could be $$H_1\otimes \begin{bmatrix}1 & 1 \\ 0 & 0\end{bmatrix}=\frac{1}{\sqrt{2}} \begin{bmatrix}1 & 1 & 1 & 1 \\0 & 0 & 0 & 0 \\ 1 & 1 & -1 & -1 \\ 0 & 0 & 0 & 0\end{bmatrix}$$. Therefore, the final state could be $$\psi_f = \frac{1}{\sqrt{2}} \begin{Bmatrix}1 \\0 \\ 1 \\ 0\end{Bmatrix}$$.

This also is matching with the simulation results.

Case 3: Since the first qubit is being measured, the state of first cubit collapses to $$|0\rangle$$, and the second qubit undergoes Hadamard transformation, the effective transformation could be $$\begin{bmatrix}1 & 1 \\ 0 & 0\end{bmatrix}\otimes \begin{bmatrix}1 & 1 \\ 0 & 0\end{bmatrix}=\begin{bmatrix}1 & 1 & 1 & 1 \\0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0\end{bmatrix}$$. Therefore, by following the same method, the final state should be $$\psi_f = \begin{Bmatrix}1 \\0 \\ 0 \\ 0\end{Bmatrix}$$. This is differing from the simulation results. The simulation is giving the final state to be $$\psi_f = \begin{Bmatrix}0 \\0 \\ 1 \\ 0\end{Bmatrix}$$. And the effective transformation matrix from the simulation seems to be $$\begin{bmatrix}0 & 0 & 0 & 0 \\0 & 0 & 0 & 0 \\ 1 & 1 & -1 & -1 \\ 0 & 0 & 0 & 0\end{bmatrix}$$, which is diffrent from the transformation matrix that I calculated.

Exactly where am I doing mistake in my calculations? And what is the correct method to find the effective transformation matrix of a system that involves post-measurement? Thanks.

Note that $$H \otimes H = \dfrac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1\\ 1 & -1 \end{pmatrix} \otimes \dfrac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1\\ 1 & -1 \end{pmatrix} = \dfrac{1}{2}\begin{pmatrix} 1 & 1 & 1 & 1\\ 1 & -1 & 1 & -1\\ 1 & 1 & -1 & -1\\ 1 & -1 & -1 & 1 \end{pmatrix}$$ and therefore $$(H \otimes H) |0\rangle^{\otimes 2} = H|0\rangle \otimes H|0\rangle = \dfrac{|0\rangle + |1 \rangle}{\sqrt{2}} \otimes \dfrac{|0\rangle + |1 \rangle}{\sqrt{2}} = \dfrac{|00\rangle + |01\rangle + |10\rangle + |11\rangle}{2} =\dfrac{1}{2} \begin{pmatrix}1\\1\\1\\1 \end{pmatrix}$$ And the circuit represents the operation $$(H \otimes H) |0\rangle^{\otimes 2}$$ and thus the final state before measurement is $$|\psi\rangle = \dfrac{1}{2} \begin{pmatrix}1\\1\\1\\1 \end{pmatrix}$$

Upon measurement, you have even probability of $$1/4$$ or $$25\%$$ to collapse to either the state $$|00\rangle$$, $$|01\rangle$$, $$|10\rangle$$ or $$|11\rangle$$. So if you do 1000 measurements, about 1/4 of the time you will observe the state $$|00\rangle$$, about 1/4 of the time you will see $$|01\rangle$$, and so on.

You can perform a qasm (shot based) simulation and check the counts to see this effect:

You can also perform a qasm simulation and check the counts to see this: Simply do

from qiskit import IBMQ, Aer, QuantumCircuit, execute
qc = QuantumCircuit(2)
qc.h([0,1])
qc.measure_all()
job = execute(qc, Aer.get_backend('qasm_simulator'), shots=4321)
print('States observed upon measurement:', job.result().get_counts())

States observed upon measurement: {'10': 1112, '00': 1074, '11': 1114, '01': 1021}

• Thanks for taking time to write the answer, but my issue seems to be still unsolved because, upon measurement the Qiskit simulation is giving a 100% probability of |10⟩ instead of 25% probability for each of the four states. Before measurement, it is giving 25% probability to all the four states, which is the Case 1 in my question, but upon measurement of both the states it is giving a 100% probability of |10⟩ which is what i couldn't understand why/how. Oct 24 at 8:50
• I think it might have something to do with how the matrices are changed based on measurement. For example, if there is a measuring device by which the state can be captured, the Quantum superposition collapses to a definite state, whether the measurement is made before transformation or after transformation, and it seems that that might be somehow playing a role here. Oct 24 at 9:12
• No, it has to due with the Quantum composer default collapsing to certain state in these situation because of a fixed random seed that has been set. But if you look at the probability distribution, you will see the 25% I am talking about. You can also remove the measurement operations and see that the state is uniformly distributed over the computational basis $\{00, 01, 10, 11\}$ as well. Check the updated answer: I added the script to perform a qasm simulation to help you visualize this. Oct 24 at 15:36
• Thanks for the explanation. Yeah, i recently figured it out, but thanks for explaining. I am still wondering why it is always collapsing to that particular state in Qiskit, rather than any other particular state. Oct 24 at 16:41
• @epelaaez i just changed the seeds and it got changed, and i now understand why it works that way. thank you! (Btw i already +1'd your answer) Oct 24 at 22:09

In the IBMQ composer, adding a measurement collapses the qubits. If you change the visualizations seed (in the top right of the interface), you'll see that the final state will collapse to a state other than $$|10\rangle$$. When running your circuit in an actual device or simulator, you'll get the equal probability of $$25\%$$ that you are expecting ($$\pm$$ some noise if you are using a real device/noisy simulator).