microsoft / Quantum

Microsoft Quantum Development Kit Samples
https://docs.microsoft.com/quantum
MIT License
3.87k stars 919 forks source link

Entanglement measurements #304

Closed ValeskyRomanov closed 4 years ago

ValeskyRomanov commented 4 years ago

Hello, I'm new to Q# but i have a bit of quantum background (I took 2 semesters of quantum mechanics as an undergrad).

I've been working through the example/quick start (https://docs.microsoft.com/en-us/quantum/quickstart?view=qsharp-preview&tabs=tabid-csharp#prepare-entanglement) and noticed that we are checking the entangled qubits to have the same value:

if (M(q1) == res) { set agree += 1; }

Should not the entangled qubits have opposite values? E.g. if one is measured as one then the other should be zero. I believe this is because of conservation of angular momentum.

I am probably missing something, but hoping someone could point it out. Thank you.

ValeskyRomanov commented 4 years ago

Oh and when creating a new issue, the default template asks to submit instead on https://quantum.uservoice.com/ which is no longer a valid method. FYI.

cgranade commented 4 years ago

Hello, I'm new to Q# but i have a bit of quantum background (I took 2 semesters of quantum mechanics as an undergrad).

Welcome, and thanks for joining the Quantum Development Kit community! ♥

I've been working through the example/quick start (https://docs.microsoft.com/en-us/quantum/quickstart?view=qsharp-preview&tabs=tabid-csharp#prepare-entanglement) and noticed that we are checking the entangled qubits to have the same value:

if (M(q1) == res) { set agree += 1; }

Should not the entangled qubits have opposite values? E.g. if one is measured as one then the other should be zero. I believe this is because of conservation of angular momentum.

In the linked quickstart, the two qubits are prepared in an entangled state using the following instructions:

H(q0);
CNOT(q0, q1);

Since by convention, freshly allocated qubits in Q# start off in the |0⟩ state, the first step prepares q0 and q1 in the state (|0⟩ + |1⟩) / √2 ⊗ |0⟩, while the second step prepares q0 and q1 in the state (|00⟩ + |11⟩) / √2. In both the |00⟩ and |11⟩ terms, we have that a 𝑍-basis measurement of q0 and q1 will return the same Result, since both the |00⟩ and |11⟩ computational basis states have even parity.

We could have prepared a different entangled state, however, that's a more close analogy to the angular momentum case that you mentioned. To do so, you'd want to flip either of the two qubits after with an X instruction after preparing the initial entanglement:

H(q0);
CNOT(q0, q1);
X(q0);

That last instruction will prepare q0 and q1 in the state (|01⟩ + |10⟩) / √2, such that measuring each qubit will give opposite results (odd parity). In both cases, the qubits are entangled, though, as you cannot describe the pure state of either qubit alone.

I am probably missing something, but hoping someone could point it out. Thank you.

Happy to help out! I'm going to close the issue for now, since this isn't a bug with the samples itself, but please feel free to reopen or to open a new issue if you find a problem with the samples or want to suggest an improvement. In the meantime, the q# tag on the Quantum Computing StackExchange site can be a great place to ask questions as well. Thanks, and have fun developing with Q#! 💕

ValeskyRomanov commented 4 years ago

Fantastic answer, thank you! It's been a few years since university and I had forgotten about parity.