2 Prepare quantum states
This chapter covers
- Using quantum gates to change quantum states
- Using Dirac notation to calculate the effect of quantum gates on quantum states
- Using Q# and Qiskit to write quantum programs
- Running quantum programs using simulators
- Peeking at the state of a quantum program during its execution
- Writing tests for quantum programs
Quantum algorithms revolve around manipulating the states of quantum systems. Figure 2.1 shows the typical structure of a quantum algorithm. The algorithm starts with preparing the quantum system in a certain superposition state and then applies a sequence of transformations to it before performing a measurement to extract the algorithm results. The goal of the algorithm is to lead the system to a superposition state in which the basis states that are answers to the problem being solved have large amplitudes, and all the other basis states have much smaller amplitudes. This allows the final measurement to yield the answer to the problem with high probability.
Figure 2.1 Any quantum algorithm can be broken down into several steps: prepare the initial state, evolve it following the algorithm, and measure the end state to get the result. The goal of the algorithm is to end up in a state in which the result of the final measurement is a correct answer. (Each block of eight bars represents the eight amplitudes of the basis states that compose a three-qubit quantum state.)
