VQE and QAOA Playground

Train a quantum circuit yourself. Tune the angles of QAOA on small MaxCut graphs, watch the cost landscape, then run VQE on spin chains and compare with the exact answer.

Reviewed December 2026. New to this? Choose the hexagon, press Optimise at p = 1, then p = 3.

Expected cut ⟨C⟩

2.9991

Best possible cut

4 of 4 edges

Approximation ratio

0.7498

Chance of an optimal cut

53.5%

Random guessing gives

2.00 (ratio 0.5000)

Parameters

2

Most likely cut: 1010 cuts 4 edges

0123

Layer 1 landscape (p = 1 values)

γ from 0 to 2πβ: 0 to π

Eight most likely outcomes (qubit 0 on the left). Highlighted: optimal cuts.

1010
26.7%
0101
26.7%
1100
7.8%
0110
7.8%
1001
7.8%
0011
7.8%
0000
1.7%
1111
1.7%
Average cut from 200 simulated shots: 3.00 (exact value 3.00). The gap is shot noise.

A five-minute path

  1. QAOA tab: choose the hexagon and drag γ and β. Watch the circle on the landscape move.
  2. Press Optimise and note the approximation ratio. Raise p to 2 and 3 and press it again.
  3. Choose the triangle and see why no layer count can cut all three edges.
  4. VQE tab: set 2 qubits and 0 layers, then add layers and compare with the dashed exact line.
  5. Press “New random start” a few times on the 4-qubit Heisenberg chain and see different endpoints.
  6. Layers vs accuracy tab: run the comparison and read the table.

What the playground does and does not do

  • It simulates exactly, up to 6 qubits for QAOA and 4 for VQE.
  • It has no hardware noise. The sampling box shows shot noise for QAOA only.
  • The VQE models are an Ising and a Heisenberg chain, not molecules.
  • It does not claim that either algorithm beats classical methods.

Reference tables

Produced by the same functions as the lab.

Best expected cut found by the optimiser (6 random starts per row), and its ratio to the true maximum. The values are lower bounds on what the best parameters could reach.
GraphEdgesMax cutp = 1p = 2p = 3
Triangle (3 nodes)322.000 (1.000)2.000 (1.000)2.000 (1.000)
Square (4-cycle)443.000 (0.750)4.000 (1.000)4.000 (1.000)
Complete graph K4643.698 (0.924)4.000 (1.000)4.000 (1.000)
Pentagon (5-cycle)543.750 (0.937)4.000 (1.000)4.000 (1.000)
House (5 nodes, 6 edges)654.110 (0.822)4.496 (0.899)4.709 (0.942)
Hexagon (6-cycle)664.500 (0.750)5.000 (0.833)6.000 (1.000)
Triangular prism (6 nodes)975.939 (0.848)6.603 (0.943)6.875 (0.982)
Parameters in the lab’s ansatz: one RY rotation per qubit before every CNOT ladder and after the last. CNOTs per layer = qubits − 1.
Qubits0 layers1 layer2 layers3 layers4 layers
2246810
33691215
448121620
Memory needed to hold all 2^n complex amplitudes at 16 bytes each.
QubitsAmplitudesMemory
102^1016 KiB
202^2016 MiB
302^3016 GiB
402^4016 TiB
502^5016 PiB

Eight guides

Predict, then check

Pick any graph and set γ = 0. What is the expected cut?

Half the number of edges, because the state is still the uniform superposition. For the triangle that is 1.5.

What is the largest cut of the square (4-cycle)?

4 edges: colour the nodes alternately.

What is the largest cut of the triangle?

2 of 3 edges, because an odd cycle cannot be coloured with two colours without a clash.

For the hexagon, what is the best approximation ratio found with p = 1, 2 and 3?

0.750, 0.833, 1.000.

How many parameters does a 4-qubit VQE circuit with 3 layers have?

16. The exact ground energy of the 4-qubit Heisenberg chain is -6.4641.

Related on QuantumAtlas

Frequently asked questions

What does this playground do?

It runs two variational algorithms on small problems: QAOA for the MaxCut problem on seven graphs, and VQE for the ground-state energy of two spin chains. All results are exact statevector simulations.

Is this running on a real quantum computer?

No. It simulates up to six qubits in your browser, with no hardware noise.

What is MaxCut?

Colour the nodes of a graph with two colours so that as many edges as possible join nodes of different colours.

What does the approximation ratio mean?

The expected cut found by QAOA divided by the true maximum cut, which the lab finds by checking every colouring.

Why does the energy never go below the exact value?

Because of the variational principle: no state has lower average energy than the ground state.

Why do different random starts give different answers?

The cost landscape has several valleys and the optimiser stops in the one it starts near.

Why is there no molecule in the lab?

A molecular Hamiltonian needs coefficients from a chemistry package for a specific geometry and basis. This lab does not type such numbers from memory.

Does this show a quantum advantage?

No. Every problem here is trivial for a classical computer, and the lab makes no advantage claim.

What is the parameter-shift rule?

A way to get the exact gradient of a circuit’s cost from two extra runs per parameter. See the gradients guide.

How should I cite results from this page?

Cite the original papers listed under the sources, not the lab output.

Sources and further reading

References were written from memory of the original works. Check the originals for exact citations.