-
Notifications
You must be signed in to change notification settings - Fork 0
/
entangled_qubits.qs
31 lines (27 loc) · 979 Bytes
/
entangled_qubits.qs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/// Entanglement
///
/// # Description
/// Qubits are said to be entangled when the state of each one of them cannot be
/// described independently from the state of the others.
///
/// This Q# program entangles two qubits.
namespace Sample {
open Microsoft.Quantum.Diagnostics;
@EntryPoint()
operation EntangleQubits() : (Result, Result) {
// Allocate the two qubits that will be entangled.
use (q1, q2) = (Qubit(), Qubit());
// Set the first qubit in superposition by calling the `H` operation,
// which applies a Hadamard transformation to the qubit.
// Then, entangle the two qubits using the `CNOT` operation.
H(q1);
CNOT(q1, q2);
// Show the entangled state using the `DumpMachine` function.
DumpMachine();
// Measurements of entangled qubits are always correlated.
let (m1, m2) = (M(q1), M(q2));
Reset(q1);
Reset(q2);
return (m1, m2);
}
}