% Single qubit teleportation example for Quack! % by Peter Rohde quack; disp(' '); disp('Single qubit teleportation example'); disp(' '); init_state(3); input_state = 1; EPR_1 = 2; EPR_2 = 3; % Prepare the state to be teleported prepare_plus(input_state); % Prepare the EPR pair prepare_bell_00(EPR_1, EPR_2); % What does the input state look like? disp('Reduced density matrix of input state:'); print_rdm(input_state); % Peform the Bell measurement on the first two qubits outcome = bell_measure(input_state, EPR_1); disp(['Measurement result: ' outcome]); disp(' '); % What does reduced density matrix of the uncorrected output state look like? disp('Reduced density matrix of uncorrected output state:'); print_rdm(EPR_2); global state; state1 = state; % Depending on the measurement outcome, perform the appropriate local correction if outcome == '00' disp('Applied I correction'); end if outcome == '01' disp('Applied X correction'); X(EPR_2); end if outcome == '10' disp('Applied Z correction'); Z(EPR_2); end if outcome == '11' disp('Applied XZ correction'); Z(EPR_2); X(EPR_2); end % What does the reduced density matrix of the corrected output state look like? disp('Reduced density matrix of corrected output state:'); print_rdm(EPR_2); % Show the circuit history disp('Circuit history:'); print_hist;