Skip to content

Instantly share code, notes, and snippets.

@made2591
Created August 13, 2020 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save made2591/266189dfa0b71a759a4f47a13fab155b to your computer and use it in GitHub Desktop.
Save made2591/266189dfa0b71a759a4f47a13fab155b to your computer and use it in GitHub Desktop.
The quantum teleportation for IBM Q
include "qelib1.inc";
// ALICE CODE
// create a 3 qubit register
qreg q[3];
// create a 3 single qubit register
creg c0[1];
creg c1[1];
creg c2[1];
gate post q {
}
// prepare the state to teleport
h q[0];
t q[0];
h q[0];
s q[0];
// prepare the bell state
h q[1];
cx q[1],q[2];
// prevent change
barrier q[0],q[1],q[2];
// start teleport
cx q[0],q[1];
h q[0];
// make measurement over the first state
measure q[0] -> c0[0];
// make measurement over the first half of Bell state
measure q[1] -> c1[0];
// BOB CODE
// apply X if n is 1
if(c1==1) x q[2];
// apply Z if m is 1
if(c0==1) z q[2];
post q[2];
// make measurement over the second half of Bell state
measure q[2] -> c2[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment