Hamiltonian simulation
Before Shor and Grover, there was a simpler argument for building quantum computers. In the early 1980s Richard Feynman pointed out that quantum systems are extremely hard to simulate on ordinary computers, and suggested using a quantum system that we control to imitate one that we want to understand. This is still widely expected to be the first application of real scientific value.
Why simulation is hard
Section titled “Why simulation is hard”You know the reason already from the entanglement lesson. A state of qubits has amplitudes. The same is true of electrons in a molecule or spins in a magnet.
Storing 50 qubits’ worth of amplitudes takes about complex numbers, at the edge of what the largest supercomputers hold. For 300 qubits the number of amplitudes exceeds the number of atoms in the observable universe. Classical methods cope by exploiting special structure, and they work very well for many systems. For others, particularly those where many particles are strongly entangled with one another, every known classical method becomes either inaccurate or exponentially slow.
A quantum computer stores the state of qubits in qubits.
How quantum systems evolve
Section titled “How quantum systems evolve”The behaviour of a quantum system is set by its Hamiltonian , a Hermitian matrix that describes its energy. The state changes in time according to the Schrödinger equation, whose solution over a time is
in units where Planck’s constant is 1. The matrix is unitary. Hamiltonian simulation is the task of building a circuit that applies it, to within a chosen error.
The exponential of a matrix is defined by the same power series as for numbers. Two facts make it concrete.
- For a diagonal matrix, exponentiate each diagonal entry. So has diagonal entries and : it is a rotation about the axis of the Bloch sphere.
- For any matrix with , which includes , , and their tensor products,
The eigenstates of are the states of definite energy. If then : energy shows up as the rate at which a phase turns. Keep that in mind for later.
Hamiltonians are sums of small pieces
Section titled “Hamiltonians are sums of small pieces”A general matrix would be hopeless to work with. But the Hamiltonians found in nature are not general. They are sums of terms that each involve only a few particles:
A standard example is a chain of spins in which neighbours interact and a magnetic field acts on each one:
Here means on qubits and and the identity elsewhere. The number of terms grows only in proportion to .
Each term on its own is easy to simulate. The single-qubit ones are rotations. For a two-qubit term such as , notice that it has the value on and and on and : it measures whether the two bits differ. So compute that parity onto one of the qubits with a CNOT, apply a single-qubit phase rotation there, and undo the CNOT.
For the rotation needed is the gate, up to a global phase.
Build . Up to a global phase, it leaves and alone and multiplies and by .
This puzzle needs JavaScript.
Hint
CNOT writes the parity of the two bits onto the bottom wire. Apply there, then undo the CNOT.
With a rotation by a general angle in place of , the same three-gate pattern gives for any .
The catch: terms do not commute
Section titled “The catch: terms do not commute”If each term is easy, why not apply them one after another? Because for matrices,
unless and commute, meaning . The terms all commute with each other, but none of them commutes with the on the same qubit. Physically, the system does not evolve under the interactions and then under the field. Both act at once.
. How well does applying and then reproduce ?
and act on different qubits, so they commute, and the exponential of their sum is exactly the product of the two exponentials.
Trotter’s formula
Section titled “Trotter’s formula”The fix is to take turns quickly. Over a very short time the order in which the terms act hardly matters, so cut the time into short steps and alternate:
This is the Trotter formula, also called a product formula. Each step makes an error proportional to and to the size of the commutator . There are steps, so the total error is proportional to
More steps give a better answer, at the cost of more gates.
The simulator uses the smallest possible example: one qubit with , starting in . The two terms do not commute. The purple curve is the exact evolution, and the orange points are the Trotter approximation after each step.
Things to try:
- With and the first-order formula, start at 1 step and increase. When does the orange path start to follow the purple curve?
- Double the number of steps from 20 to 40. By what factor does the error shown fall?
- Switch to the second-order formula and repeat. How many steps does it need to match the first-order formula at 40?
- Fix the number of steps and increase . What happens to the error?
The second-order formula splits one of the terms in half and puts the halves on either side: half a step of , a full step of , half a step of . The arrangement is symmetric, and that makes the leading error cancel. Its total error falls as where the first-order one falls as . When steps are chained together, neighbouring half steps merge into one gate, so the improvement is almost free.
A note on the number in the panel. It shows 1 minus the fidelity between the two final states, which behaves like the square of the error in the state. That is why doubling the steps divides it by about 4 for the first-order formula and about 16 for the second-order one.
With the first-order formula, you want the error in the simulated evolution to be 10 times smaller, for the same total time. How many more steps do you need?
The first-order error is proportional to . To make it 10 times smaller at the same , make the number of steps 10 times larger.
What it costs
Section titled “What it costs”Put the pieces together for a system of qubits whose Hamiltonian has local terms. One Trotter step uses about small gates, and the number of steps grows polynomially with the time and the accuracy wanted. The total is polynomial in the size of the system, where the direct classical approach is exponential. Seth Lloyd made this argument precise in 1996, confirming Feynman’s suggestion.
Product formulas are the simplest method and often perform better in practice than their worst-case bounds suggest. They are not the last word. Later methods, known by names such as linear combination of unitaries, qubitization and quantum signal processing, reach a cost that grows only linearly with the time and logarithmically with the inverse of the error, which is known to be essentially the best possible. They are harder to explain and need more auxiliary qubits, and which method wins depends on the problem.
From dynamics to energies
Section titled “From dynamics to energies”Simulating evolution is useful directly: you can prepare a state, let it evolve, and measure how a quantity changes. It is also the key to a second kind of question. Chemists and materials scientists mostly want to know energies, above all the lowest one, the ground-state energy, because energy differences govern which reactions happen and how fast.
Recall that an eigenstate with energy picks up the phase under . So the energy is an eigenvalue phase of a gate we can now build, and phase estimation reads eigenvalue phases. Run phase estimation with and the counting register returns an energy.
There is a condition, which you also met in that lesson. Phase estimation returns the energy of a random eigenstate, weighted by how much of it is present in the starting state. To get the ground-state energy you must start from a state that already overlaps well with the ground state. Preparing such a state is a hard problem in general, and for some Hamiltonians it is believed to be hard even for a quantum computer. In practice people rely on good approximate states from classical chemistry.
What to expect, honestly
Section titled “What to expect, honestly”- The promise. Systems with strong correlations among many electrons, such as the active sites of some enzymes and catalysts, and models of high-temperature superconductors, defeat the best classical methods. These are the usual targets.
- The requirements. Useful accuracy for such problems needs deep circuits, well beyond what today’s noisy devices can run, so it needs error correction. Resource estimates have been improving steadily and are still large.
- The competition. Classical simulation methods keep improving too, and several claimed quantum advantages in simulation have been matched by better classical algorithms afterwards. Where the practical crossover lies is an open research question.
Where the speedups come from
Section titled “Where the speedups come from”That completes the track. It is worth setting the algorithms side by side, because between them they cover most of what is known.
| Source of the speedup | Example | Size of the speedup |
|---|---|---|
| Hidden periodic structure, found by the Fourier transform | Shor’s algorithm, phase estimation | Exponential over the best known classical methods |
| Amplitude amplification | Grover’s search | Quadratic, and provably no more |
| The problem is itself quantum | Hamiltonian simulation | Exponential over the best known classical methods, for suitable systems |
In every case the mechanism is the one from the first lesson: arrange the amplitudes so that wrong answers cancel and right ones reinforce. A quantum computer is not a faster computer in general. It is a machine for problems that have the right structure for interference, and finding more of those problems is one of the main open tasks of the field.
Where to go next:
- Quantum Error Correction explains how the long circuits in this track could ever be run on imperfect hardware.
- Quantum Machine Learning covers variational algorithms, which try to get value from short circuits, including a different approach to finding ground-state energies.
- Quantum Cryptography deals with the consequences of Shor’s algorithm and with what quantum states make possible in return.
Remember it
Section titled “Remember it”What is the task called Hamiltonian simulation?
Building a circuit that applies , the evolution of a quantum system with Hamiltonian over a time , to within a chosen error.
Why is simulating a quantum system hard for a classical computer in general?
The state of particles has amplitudes.
State the first-order Trotter formula and how its error behaves.
for steps, with error proportional to .
When is exactly?
When and commute, .
What circuit applies ?
A CNOT, a rotation on the target qubit, and the same CNOT again.
How can a quantum computer find an energy of a Hamiltonian ?
By phase estimation on , whose eigenvalue phases are the energies. The starting state must overlap well with the eigenstate wanted.