<jupyter_start><jupyter_text>Dense coding @Author: <NAME>The purpose is to send 2-classical bits by exchangin a single quantum qubit. The key is for Alice and Bob to share an entangle 2-qubit state.  So, initially, Alice has qubit 0 and Bob qubit 1.<jupyter_code>%matplotlib inline
from qiskit import *
from qiskit.tools.visualization import plot_histogram
import qiskit.tools.jupyter
%qiskit_version_table<jupyter_output><empty_output><jupyter_text>Create a circuit with quantum register of 2 qubits and classical register of 2 bits<jupyter_code>circuit=QuantumCircuit(2,2)<jupyter_output><empty_output><jupyter_text>Create the entangled state, concretely $$|B00>=\frac{1}{\sqrt{2}}(|00>+|11>)$$<jupyter_code>circuit.h(0)
circuit.cx(0,1)<jupyter_output><empty_output><jupyter_text>Alice performs an operation on q0 depending on the 2-bit sequence she wants to send, according to the following rule* 00, I* 01, X* 10, Y* 11, Z For example, let's assume Alice wants to send 01. Then apply she applies X to her qubit<jupyter_code>circuit.x(0)<jupyter_output><empty_output><jupyter_text>now Alice sends her qubit to Bob. When Bob receives the qubits, he first disentangles the 2 qubit-state.<jupyter_code>circuit.cx(0,1)
circuit.h(0)<jupyter_output><empty_output><jupyter_text>Finally Bob measures the two qubits onto the two classical bits<jupyter_code>circuit.measure((0,1),(0,1))
## You can see the final version of your circuit graphically. The qubit 0 is on the top of the circuit. 
circuit.draw(output='mpl')<jupyter_output><empty_output><jupyter_text>Run the simulation  in order to run the simulation we must use the Aer component of qiskit<jupyter_code>simulator=Aer.get_backend('qasm_simulator')
result=execute(circuit,backend=simulator).result()

# to see the result plot the histogram
plot_histogram(result.get_counts(circuit))<jupyter_output><empty_output><jupyter_text>Run remotely on IBM's QC in order to send the program to the IBM computer, we must load the account<jupyter_code>IBMQ.load_account()
providerhere=IBMQ.get_provider('ibm-q')<jupyter_output><empty_output><jupyter_text>To see the available QPUs, you can get the list from IBM service<jupyter_code>providerhere.backends()<jupyter_output><empty_output><jupyter_text>To select the most appropiate QPU for your circuit (or the QPU with smallest queue), you can also connect to IBM Quantum ComputingOr you can compare directly<jupyter_code>%qiskit_backend_overview
qcomphere=providerhere.get_backend('ibmqx2')
qcomphere<jupyter_output><empty_output><jupyter_text>finally declare the job<jupyter_code>jobhere=execute(circuit,backend=qcomphere)<jupyter_output><empty_output><jupyter_text>and monitor de execution<jupyter_code>from qiskit.tools.monitor import job_monitor
job_monitor(jobhere)<jupyter_output>Job Status: job is queued (5)<jupyter_text>Finally, let us plot the result<jupyter_code>qresult = jobhere.result()

plot_histogram(qresult.get_counts(circuit))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0913688469318948, 'fraction_numerical': 0.01449763991908294, 'mean_word_length': 8.389240506329115, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '473354', 'license': 'Apache-2.0', 'n_tokens_mistral': 1050, 'n_tokens_neox': 976, 'n_words': 270, 'path': 'Notebooks/qiskit/Dense_Coding.ipynb', 'repo_name': 'gomeztato/QuantumCourse', 'size': '2970'}