I came across this while reading lecture notes and I have no idea how they got the $M_0$ and $M_1$.

The way I see it, the matrix $U$ is a block matrix:

$$ \left[ \begin{array}{ c c } P & 0 \\ 0 & H \end{array} \right]. $$

Calculating these matrix elements on the B part gives me $P$, instead of $M_0$ or $M_1$.

Also, the bottom control qubit isn't affected by the measurement so the $H$ gate will turn it back into a $|0 \rangle$ every time... so how is it even possible to get a $1$? what's my mistake?


You've incorrectly found that the matrix for $H$ is given by

$$ \left(\begin{array}{cc} 1&0\\0&H \end{array}\right) $$ where $H$ and $1$ are $2\times 2$ matrices, and we're using the following ordering of basis elements: $(|00\rangle,|01\rangle,|10\rangle,|11\rangle)$. This isn't true. An easy way to see that is to compute the matrix element $\langle 00 |H| 00\rangle$. If you're correct, that matrix element should be 1. But,

$$ \begin{array}{rcl} \langle 00 |H| 00\rangle &=& \langle 0|_A \langle 0|_B (1_A\otimes H_B) |0\rangle_A|0\rangle_B\\ &=& \langle 0|_A 1_A|0\rangle_A \langle 0|_B H_B |0\rangle_B\\ &=& \langle 0|_B |+\rangle_B\\ &=& \frac{1}{\sqrt{2}}\\ \end{array} $$

The $H$ operator is NOT block diagonal in this matrix representation! The only way to find the matrix elements of $H$ is to explicilty compute all these inner products. Alternatively, you can abandon writing the matrices explicitly, and just work with tensors of bras and kets; for this problem, the latter method is simpler.

To answer your final question (How do you get a $|1\rangle$?) the answer is that the controlled $P$ operator actually affects measurements of qubit $B$. Without the controlled $P$ operator, you'd never expect a $|1\rangle$, just as you said. An easy way to see that is by setting $P$ to be the identity in the formulas for $M_1$ and $M_0$ above.

An addendum about matrix representations of tensor products

You seem to be confused between "$H$ acts only on system $B$" and "the matrix representation of $H$ should have the form $\left(\begin{smallmatrix}1&0\\0&H\end{smallmatrix}\right)$". The two things are NOT related. There is NO connection between operators which only act on system $B$ and operators with the matrix form $\left(\begin{smallmatrix}1&0\\0&H\end{smallmatrix}\right)$. Going further, it's also NOT true that $H_A\otimes H_B$ has matrix form $\left(\begin{smallmatrix}H_A&0\\0&H_B\end{smallmatrix}\right)$. You should not think of tensor products as block diagonal matrices, because that is not what they are!

Let's consider the simple case of $(1\otimes H_B)$. We want to write it as a matrix:

$$ \left( \begin{array}{c|cccc} &|00\rangle&|01\rangle&|10\rangle&|11\rangle\\ \hline |00\rangle\\ |01\rangle\\ |10\rangle\\ |11\rangle\\ \end{array} \right) $$ where I've explicitly labelled the basis we're writing the matrix in. To find the first column of the matrix, we just need to figure out what $(1\otimes H_B)$ does to $|00\rangle$ and read off the matrix elements. Well,

$$(1\otimes H_B)|00\rangle = |0 +\rangle=|0\rangle\otimes\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)=\frac{1}{\sqrt{2}}(|00\rangle+|01\rangle)$$

Notice that $(1\otimes H_B)$ only affected the second qubit, as you expected. Now we can fill in the first row of our matrix:

$$ \left( \begin{array}{c|cccc} &|00\rangle&|01\rangle&|10\rangle&|11\rangle\\ \hline |00\rangle&\frac{1}{\sqrt{2}}\\ |01\rangle&\frac{1}{\sqrt{2}}\\ |10\rangle&0\\ |11\rangle&0\\ \end{array} \right) $$

To find the next row, you'd figure out the image of $|01\rangle$, etc. This is the ONLY way to reliably find matrix representations of tensor products. You DON'T simply stack the matrices.

If this feels counterintuitive to you, fiddle around with finding more basis elements until it makes sense. Notice that an operator that only acts on one subsystem ONLY affects that subsystem's bits, just like you expected. It's just that "only affecting one subsystem's bits" doesn't imply the block diagonal form you thought it did.

  • $\begingroup$ Then why is this how they write the matrix $C(U)$ here: en.wikipedia.org/wiki/Quantum_gate#Controlled_gates The circuit I have is a $C(P)$ followed by a $H$ on the 2nd qubit, so it's $(1 \otimes H)C(P)$. Except in the wiki, the control bit is the top one, so the matrix should be flipped. $\endgroup$ – Spine Feast Jul 5 '16 at 19:20
  • $\begingroup$ The controlled $P$ gate is of the form you think it is, but $H$ is not of the form you think it is. $H$ doesn't act on only the last two basis elements in the matrix representation. $\endgroup$ – Jahan Claes Jul 5 '16 at 19:27
  • $\begingroup$ Basically, tensor products are complicated; using explicit braket notation when taking matrix elements will help. $\endgroup$ – Jahan Claes Jul 5 '16 at 19:28
  • $\begingroup$ @DepeHb I edited my answer now that I better understand what you were thinking. Hope that helps! $\endgroup$ – Jahan Claes Jul 5 '16 at 19:44
  • $\begingroup$ I'm confused by the form of $H$... I see that it's not in block form but I don't really understand why - I naively assumed that since the "box" is applied only to one of the qubits, then it shouldn't affect the others...? $\endgroup$ – Spine Feast Jul 5 '16 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.