Quantum teleportation is the transfer of quantum information (quantum states) from one particle to another over a distance, using quantum entanglement and classical communication. This experiment using qiskit demonstrates the principles of quantum teleportation on IBM's 7-Qubit Quantum Computer Nairobi. It illustrates the phenomena of superposition, entanglement, and the collapse of quantum states upon measurement.
Code Walkthrough
1. Initialization of the Quantum Circuit:
The circuit is initialized with 7 qubits. For teleportation, we focus on the first three qubits, with Qubits 0 and 1 being prepared in an entangled state and Qubit 2 as the target for teleportation.
2. Entanglement Creation between Qubits 0 and 1:
2. Hadamard Gate on Qubit 0:
The Hadamard gate creates a superposition state. It transforms the basis states as follows:
CNOT Gate between Qubit 0 and Qubit 1:
The Controlled-NOT gate entangles Qubit 0 with Qubit 1. Its operation can be described as:
3. Measurement and Collapse of Qubits 0 and 1:
The measurement of these qubits collapses their quantum state into one of the basis states. The state of each qubit becomes either ∣0⟩ or ∣1⟩, with probabilities dependent on their state prior to measurement.
4. Conditional Operation on Qubit 2:
Based on the measurement of Qubit 0, a conditional operation (Pauli-X gate) is applied to Qubit 2. The Pauli-X gate acts as a quantum bit-flip operation:
5. Execution of the Quantum Circuit:
The circuit is sent and executed on IBM's 7-Qubit Quantum Computer Nairobi.
6. Result Analysis:
The final states of the qubits are analyzed post-execution. The analysis involves interpreting the quantum state transfer fidelity, based on the observed probabilities of outcomes.
7. Data Saving and Extended Analysis:
The experimental results, along with the backend information, are saved for further analysis.
Dominant Outcomes:
The states '0000000' and '0000011' clearly dominate the results, with each having close to 1900 occurrences. This prominence suggests that the quantum teleportation protocol primarily resulted in these states, which is indicative of successful teleportation.
Success Indicators:
The high frequency of '0000000' and '0000011' compared to the other states suggests a high degree of fidelity in the teleportation process.
Error rate:
The small occurrence of the error states ('0000001' and '0000010') indicates small systematic errors or imperfections in the quantum circuit or the quantum computer itself, such as gate errors, decoherence, or measurement errors and is normal in real systems.
Code:
from qiskit import QuantumCircuit, transpile
from qiskit.visualization import plot_histogram
from qiskit. tools.monitor import job_monitor
from qiskit_ibm_provider import IBMProvider
import json
import matplotlib.pyplot as plt
# Insert your IBM API Key here
IBM_API_KEY = 'Your_Key_Here'
# Enable your IBMQ account using the new provider
provider = IBMProvider(IBM_API_KEY)
# Define a simplified quantum circuit
num_qubits = 7
qc = QuantumCircuit(num_qubits, num_qubits)
# Quantum teleportation setup
qc.h(0) # Prepare Qubit 0 in a superposition state
qc. cx(0, 1) # Entangle Qubit 0 with Qubit 1
# Measure Qubits 0 and 1
qc.measure([0, 1], [0, 1])
# Conditional operation on Qubit 2 based on Qubit 0's measurement
qc.x(2).c_if(qc.clbits[0], 1) # Apply X-gate on Qubit 2 if Qubit 0 is 1
# Execute the circuit on a quantum computer
backend = provider.get_backend('ibm_nairobi')
transpiled_circuit = transpile(qc, backend=backend)
job = backend. run(transpiled_circuit)
job_monitor(job)
# Retrieve and plot the results
results = job.result().get_counts(qc)
plot_histogram(results)
plt. show()
# Save results and backend information to a JSON file
results_data = {
"results": results,
"backend_info": {
"backend_name": backend. name,
"qubit_count": backend.configuration().n_qubits,
"basis_gates": backend.configuration().basis_gates,
"quantum_volume": backend.configuration().quantum_volume
}
}
file_path = 'c:\\Users\\Documents\\QC\\teleportation_results.json'
with open(file_path, 'w') as file:
json.dump(results_data, file, indent=4)