1. Chemistry
A chemist often wants one number: the energy of a molecule in its most stable arrangement. That number decides whether a bond holds, how long it is, and whether a reaction is likely. For a large molecule the classical calculation of that number becomes the expensive part of the work.
The question
Given a recipe for the energy, which quantum state has the lowest score?
The recipe used here is a toy, chosen so every term is visible:
Each average is read from probabilities. For one qubit, . On two qubits, with qubit 0 as the left bit:
- compares the left bit 0 against the left bit 1.
- compares the right bit 0 against the right bit 1.
- compares the outcomes where the bits agree against the outcomes where they differ.
The quantum idea
The circuit is a guess at the molecule’s state. The measurement is a score. You keep the guess with the lower score. That loop is the variational quantum eigensolver, written out for one qubit on the variational algorithms page. Here the guess has two qubits, so you can see a product state and an entangled state side by side.
A toy you can run
Three guesses. The product state leaves both qubits at 0. The Bell state entangles them. The third guess flips both qubits with .
import math
import numpy as np
from fqkit import QuantumCircuit, Hadamard, RX, CNOT, run
np.set_printoptions(precision=4, suppress=True)
def energy(build):
qc = QuantumCircuit(2)
build(qc)
p = np.abs(run(qc)) ** 2
z0 = (p[0] + p[1]) - (p[2] + p[3])
z1 = (p[0] + p[2]) - (p[1] + p[3])
zz = (p[0] + p[3]) - (p[1] + p[2])
return float(0.4 * z0 + 0.4 * z1 + 0.2 * zz)
def product(qc):
return None
def bell(qc):
qc.add_gate(Hadamard(), [0])
qc.add_gate(CNOT(), [0, 1])
def both_flipped(qc):
qc.add_gate(RX(math.pi), [0])
qc.add_gate(RX(math.pi), [1])
for name, build in (("product", product), ("bell", bell), ("both flipped", both_flipped)):
print(f"{name:14s} E = {energy(build): .1f}")product E = 1.0
bell E = 0.2
both flipped E = -0.6The flipped state wins. Entanglement was available and, for this particular recipe, it was not the lowest score. That is a useful result: a famous state is not automatically the answer. The method is to score the guesses you can prepare.
Follow up
- In the chemistry notebook, add an
RYon qubit 0 before the flips and print the energy at a few angles. Which angle undercuts ? If none does, say so. - Read variational algorithms for the one-qubit case, where the score is and the minimum is obvious.
- Real molecular Hamiltonians are long sums of Pauli strings, not three terms. The circuit can stay small. The number of separate experiments grows with the number of terms.
The real scale
A hydrogen molecule in a minimal basis is already a research calculation: many terms, a layered circuit, and a classical optimizer choosing the angles. Drug-binding estimates and battery materials are the same loop with a larger recipe. FQkit will show you the loop. It will not fit a protein.