Introduction
Interested in learning how to program quantum computers? Then check out our Qiskit textbook Introduction to Quantum Computing with Qiskit.
In this tutorial we will explore Bell states and how to implement them IBM Quantum Computers with Qiskit.
What are Bell states?
Bell states are the four states that can be created when two qubits are maximally entangled. The four states are represented as so:
Now we will go through each state and see how to implement it using quantum circuits.
The first Bell state is incredibly easy to implement as it can be created using a two qubit circuit consisting of a Hadamard gate and CNOT gate found below:
This will entangle the two qubits such that the combined state becomes:
Now lets see how the circuit actually creates the first Bell state. Since the circuit consists of two qubits both initialised to |0〉the initial combined state will be:
Now that we have the two qubits initialised we can now apply a Hadamard gate to our control qubit. Now there’s a problem. How do we apply a Hadamard gate to our control qubit when it is part of a 2 qubit state? The best solution is to expand out the Hadamard gates matrix so that we can apply it to our two qubit state. This can be done by finding the Kronecker
product of the Hadamard gate and identity gate.
Remember the Hadamard gate matrix is:
and the Identity gate matrix:
Then the Kronecker product is:
Next we need to multiply the above matrix by our initialised qubit state:
Now we just need to apply the CNOT gate to the circuit by multiplying the state above with the CNOT matrix:
Which finally gives us the state:
Now that we have shown how the first Bell state is created we can move on to the second Bell state.
Remember that the second Bell state is:
Which is the same as the first Bell state but with a negative phase!. As such this can be implemented easily by using the same circuit as the first Bell state but with the addition of initializing the first qubit to |1〉with a Pauli-X gate:
The third state is a little different as only 1 qubit should be |1〉such that the combined state becomes:
This state can be created using a circuit very similar to the last two but with the second qubit initialized to |1〉using a Pauli-X gate:
The fourth Bell state is basically the same as the third Bell state but with a negative phase:
This can be implemented by applying Pauli-Z gates to both qubits like so:
How to run the program
Copy and paste the code below in to a python file
Enter your API token in the IBMQ.enable_account('Insert API token here') part
Save and run
Code
from qiskit import QuantumRegister, ClassicalRegister from qiskit import QuantumCircuit, execute,IBMQ from qiskit.tools.monitor import job_monitor IBMQ.enable_account('ENTER API KEY HERE') provider = IBMQ.get_provider(hub='ibm-q') backend = provider.get_backend('ibmq_qasm_simulator') q = QuantumRegister(2,'q') c = ClassicalRegister(2,'c') def firstBellState(): circuit = QuantumCircuit(q,c) circuit.h(q[0]) # Hadamard gate circuit.cx(q[0],q[1]) # CNOT gate circuit.measure(q,c) # Qubit Measurment print(circuit) job = execute(circuit, backend, shots=8192) job_monitor(job) counts = job.result().get_counts() print(counts) def secondBellState(): circuit = QuantumCircuit(q,c) circuit.x(q[0]) # Pauli-X gate circuit.h(q[0]) # Hadamard gate circuit.cx(q[0],q[1]) # CNOT gate circuit.measure(q,c) # Qubit Measurment print(circuit) job = execute(circuit, backend, shots=8192) job_monitor(job) counts = job.result().get_counts() print(counts) def thirdBellState(): circuit = QuantumCircuit(q,c) circuit.x(q[1]) # Pauli-X gate circuit.h(q[0]) # Hadamard gate circuit.cx(q[0],q[1]) # CNOT gate circuit.measure(q,c) # Qubit Measurment print(circuit) job = execute(circuit, backend, shots=8192) job_monitor(job) counts = job.result().get_counts() print(counts) def fourthBellState(): circuit = QuantumCircuit(q,c) circuit.x(q[1]) # Pauli-X gate circuit.h(q[0]) # Hadamard gate circuit.z(q[0]) # Pauli-Z gate circuit.z(q[1]) # Pauli-Z gate circuit.cx(q[0],q[1]) # CNOT gate circuit.measure(q,c) # Qubit Measurment print(circuit) job = execute(circuit, backend, shots=8192) job_monitor(job) counts = job.result().get_counts() print(counts) print("Creating first Bell State:\n") firstBellState() print("\nCreating second Bell State:\n") secondBellState() print("\nCreating third Bell State:\n") thirdBellState() print("\nCreating fourth Bell State:\n") fourthBellState()