Two for the Price of One: Simulating Superdense Coding

Project Overview:

Quantum teleportation sends a qubit's state using entanglement plus two classical bits. Superdense coding does almost the reverse, it lets you send two classical bits of information by physically transmitting only a single qubit, as long as you and the receiver already share an entangled pair in advance. It sounds like it breaks the rules of information, cramming two bits into one qubit, but it works because the entangled pair itself was already quietly carrying extra correlation before you even started. In this project you will build the circuit, encode a specific 2 bit message, and confirm your partner correctly decodes it every time.

Materials Required:

A computer with internet access

A free Google account, to use Google Colab, no installation needed

Basic comfort reading Python

Background: How Superdense Coding Actually Works

Alice and Bob start by sharing one entangled pair of qubits, created together in advance, then physically separated, one qubit stays with Alice, the other travels to Bob, well before any message is decided.

When Alice later wants to send Bob a 2 bit message, 00, 01, 10, or 11, she does not need to send both qubits. She only applies one of four simple operations to her own single qubit, based on which 2 bit message she wants to send, then sends just that one qubit to Bob. Each of the four possible operations changes the shared entangled state in a distinct, recognizable way, even though Bob's qubit never left his hands.

Once Bob receives Alice's qubit, he combines it with his own original qubit using a specific 2 qubit measurement. Because the earlier entanglement guarantees the two qubits are correlated in a very specific way, this single measurement perfectly reveals which of the four operations Alice applied, recovering both bits of her message correctly, from transmitting only one physical qubit.

Step by Step Instructions

Set up your notebook.

Go to Google Colab at colab.research.google.com and create a new notebook.

Install Qiskit.

Type the following into a code cell and run it:

pip install qiskit qiskit-aer

Build a function that creates the shared entangled pair.

Qubit 0 will belong to Alice, qubit 1 will belong to Bob.

from qiskit import QuantumCircuit

from qiskit_aer import AerSimulator

def create_entangled_pair():

qc = QuantumCircuit(2, 2)

qc.h(0)

qc.cx(0, 1)

return qc

Add Alice's encoding step based on her chosen message.

Each message applies a different, specific operation to Alice's qubit only.

def encode_message(qc, message):

if message == "00":

pass

elif message == "01":

qc.x(0)

elif message == "10":

qc.z(0)

elif message == "11":

qc.x(0)

qc.z(0)

return qc

Add Bob's decoding step.

Bob combines the two qubits and measures both, this is the step that only works correctly because the pair started entangled.

def decode_message(qc):

qc.cx(0, 1)

qc.h(0)

qc.measure(0, 0)

qc.measure(1, 1)

return qc

Put it all together and test one message.

simulator = AerSimulator()

message_to_send = "10"

qc = create_entangled_pair()

qc = encode_message(qc, message_to_send)

qc = decode_message(qc)

print(qc.draw())

result = simulator.run(qc, shots=1000).result()

counts = result.get_counts()

print(f"Sent message: {message_to_send}")

print("Bob's decoded result:", counts)

Check the output.

You should see all 1000 shots landing on a single outcome that exactly matches the message you sent, just in reverse bit order depending on how Qiskit labels qubits, so 10 should decode consistently to the same 2 bit string every single run, with zero randomness or error.

Test all four messages.

for message in ["00", "01", "10", "11"]:

qc = create_entangled_pair()

qc = encode_message(qc, message)

qc = decode_message(qc)

result = simulator.run(qc, shots=1000).result()

counts = result.get_counts()

print(f"Sent: {message}  ->  Decoded: {counts}")

Confirm each message decodes perfectly and uniquely.

Each of the four sent messages should produce a different, single, consistent decoded result, proving Bob correctly recovers all 2 bits of information every time, despite only ever physically receiving one qubit from Alice.

Congratulations, you just simulated superdense coding, a real protocol that has been experimentally demonstrated in labs and directly proves that pre-shared entanglement has genuine, usable communication value, not just theoretical interest.

Fun Fact:

Superdense coding and quantum teleportation are often described as mirror images of each other, teleportation uses entanglement plus two classical bits to send one qubit of information, while superdense coding uses entanglement plus one qubit to send two classical bits, and both were discovered by studying exactly what entanglement makes physically possible that classical correlations alone cannot.

Previous
Previous

Finding a Needle in a Haystack: Simulating Grover's Search Algorithm

Next
Next

The Narrower You Look: Seeing Heisenberg's Uncertainty Principle with a Slit