Before we write a program that implements Shor's code, we need a way to read in an arbitrary Pauli error, which brings us to our first codercise. Shor's code can even decode multi-qubit Pauli errors. So let's create a function that can generate any error we please. We'll use this extensively going forward.

The function that is available to you is called error. It takes two keyword arguments:

  1. error_type: a string associated with the error you'd like to create and
  2. wires: a list of wires that the error acts on.

For example, if you want to create a error on qubit 7, you would do error(error_type = "Y", wires = [7]). If you want to create an error — a three-qubit error — where qubit 4, 5, and 1 get the , , and error, respectively, you would do error(error_type = "XYZ", wires = [4, 5, 1]).

The error function will return a list of Pennylane operators associated to each error. For example, for the on qubits 4, 5, and 1, error would return [qml.PauliX(4), qml.PauilY(5), qml.PauliZ(1)].

You try!

or to submit your code

To interact with codercises, please switch to a larger screen size.

Learning Objectives:

  • Explain the structure of Shor's 9-qubit code from the perspective of combining the three-qubit phase- and bit-flip codes.
  • See how Shor's code can correct more than just single-qubit errors.