A quantum algorithm solves computational tasks using fewer physical resources than the best-known classical algorithm. Of most interest are those for which an exponential reduction is achieved. The key example is the phase estimation algorithm, which provides the quantum speedup in Shor's factoring algorithm and quantum simulation algorithms. To date, fully quantum experiments of this type have demonstrated only the read-out stage of quantum algorithms, but not the steps in which input data is read in and processed to calculate the final quantum state. Indeed, knowing the answer beforehand was essential. We present a photonic demonstration of a full quantum algorithm-the iterative phase estimation algorithm (IPEA)-without knowing the answer in advance. This result suggests practical applications of the phase estimation algorithm, including quantum simulations and quantum metrology in the near term, and factoring in the long term.M any quantum computations can be roughly broken down into two stages: read-in and processing of the input data; and processing and read-out of the solution. In the first phase, the initial data are read into a quantum register and processed with quantum gates, sometimes multiple times. This produces a quantum state in which the solution is encoded. In the second phase the quantum state may be subjected to further processing followed by measurement, producing a classical data string containing the solution. Even though quantum computers are currently limited to a small number of qubits, there is considerable interest in the small-scale demonstration of quantum algorithms, even if the size of the problems solved means that they remain easily tractable with classical techniques. Such demonstrations remain challenging, even for small numbers of qubits, as they typically require the sequential application of a large number of quantum gates 1 . Note we are making a distinction here between quantum algorithms and direct quantum simulation (Supplementary Section S1).In recent years there have been a number of elegant demonstrations of the read-out phase of Shor's factoring algorithm 2-5 and a quantum chemistry simulation algorithm 6-8 . In these demonstrations, quantum gates have been used to produce the quantum state corresponding to a particular solution of the algorithm. It was then shown that the corresponding solution could be read out with high fidelity from this state. However, in each case, the method for producing the quantum state explicitly required the solution to be already known from a classical calculation. That is, the solution was put into the quantum state by hand, before being read out through further processing and measurement. It is clearly important to go beyond this restriction and demonstrate both stages of a quantum algorithm.
Phase estimation algorithmFirst, we briefly review the standard phase estimation algorithm 1 . Given a unitary U and one of its eigenstates |cl that fulfil the equationthe task is to find what the corresponding eigenvalue is-in other words, find th...