'2 entangle qubit gives all states with 25 %
Solution 1:[1]
The circuit you created is actually doing this: first, applying Hadamard gates to |00> will create the state 1/2(|00>+|01>+|10>+|11>). Then, applying the C-NOT will make |01> to |11> and |11> to |01> (normally |10> to |11> and |11> to |10> with textbook's convention but the Qiskit's convention makes it the other way), therefore your state actually is the same, that's why you get the 25% probability for each. I hope it is clear enough!
Solution 2:[2]
Let's consider the 2-qubit system where we are applying Hadamard operator to both the qubits and then a CNOT (with the first qubit as the control bit).
With qiskit
we can simulate the above system as shown in the code below and see that the results are as per our expectation (the output system is uniform superposition of 4 states with equal probability).
from qiskit import QuantumCircuit, Aer, execute
from qiskit.visualization import plot_histogram
qc = QuantumCircuit(2)
qc.h(0) # |0> -> |+>
qc.h(1) # |0> -> |+>
qc.cx(0,1)
qc.draw()
backend = Aer.get_backend('statevector_simulator')
plot_histogram(execute(qc,backend).result().get_counts())
In order to get the desired states we need to apply a Hadamard gate (H) to the first qubit, a NOT (X) gate to the 2nd qubit and then apply CNOT to have desired entangled states (Bell State):
Simulating the above with qiskit
:
qc = QuantumCircuit(2)
qc.h(0) # |0> -> |+>
qc.x(1) # |0> -> |1>
qc.cx(0,1)
qc.draw()
plot_histogram(execute(qc,backend).result().get_counts())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Lena |
Solution 2 |