Free quantum tool · Level: First-year university and up
ZX-calculus spiders
Build a diagram out of coloured dots, then rewrite it. Keep an eye on the matrix beside it while you do. It never moves.
Try this on the tool above
- The diagram opens as green 90°, green 90°, H, H. Turn on fuse and cancel: four nodes become a single green 180°, which is the Z gate.
- Turn on the matrix layer first, then fuse. All 4 entries read the same before and after, and that single fact is the entire claim of the calculus.
- Clear, set the phase to 180° and press X for one red spider. Clear again and build H, green 180°, H. Both diagrams are the NOT gate.
The ZX-calculus draws quantum processes as diagrams of green Z spiders and red X spiders joined by wires. Two rules do most of the work: same-colour spiders joined by a wire merge into one and their angles add, and a Hadamard box on each leg swaps a spider's colour. Rewriting with those rules counts as a proof, because the diagram and the linear map it stands for are the same object.
The usual mistake
Green and red are two different kinds of node I have to memorise separately.
Switch on the colour-change layer. Every red dot turns green with a Hadamard on either side, and the matrix does not budge. A red spider is the same spider read in the other basis, and the Hadamard is precisely what swaps those bases. There is one kind of node here.
Fusion is the rule that does the work
The diagram opens on four nodes: two green spiders at 90° and two Hadamard boxes. Turn on fuse and cancel and it drops to a single green spider at 180°, which is the Z gate. Two angles added, two Hadamards gone, one node left.
Nothing was approximated along the way. The matrix panel shows the same four numbers before and after, and it will keep showing them however you rearrange the picture. Rules that are equalities are what turn a notation into a calculus.
What the Hadamard really is
The colour-change layer wraps every red spider in Hadamards and turns it green, and the matrix sits still through all of it. Red was never a second species of node.
That also settles a question the gates page leaves open. The Hadamard is the thing that swaps the two bases, which is far more useful than calling it the gate that makes superpositions.
Why bother when matrices already work
For one qubit you would not, honestly. The case starts when a circuit has enough wires that its matrix runs to thousands of entries with no structure you can see. Fusion is local, so a diagram simplifies in place, while a matrix that size can only be multiplied out.
The other reason is that some facts are easier to see than to compute. Teleportation is the standard example: as a circuit it is a sequence you verify line by line, and as a diagram it is a bent wire pulled straight.
What this tool leaves out
Every diagram here is a chain with one wire in and one wire out. Real ZX diagrams branch, and a spider can carry any number of legs, which is where the name comes from in the first place.
That restriction buys something. With one leg in and one out, every rule above is an exact matrix equality. In the full calculus a rewrite usually holds only up to a scalar factor, and tracking those factors is a real part of the subject. This page will not teach you that part.
Reading Picturing Quantum Processes on your own?
Browse physics and maths tutors, pick one whose subjects match your course, and book a single hour to start.
Frequently asked questions
- What is the ZX-calculus?
- A diagrammatic language for quantum processes, built from two kinds of node called spiders and a short list of rewrite rules. Bob Coecke and Ross Duncan developed it, and Coecke and Aleks Kissinger's book Picturing Quantum Processes teaches quantum theory through it from the first page.
- What is a spider?
- A node with any number of wires in and out, carrying a phase angle. A green Z spider acts on the |0⟩ and |1⟩ basis, a red X spider does the same job in the |+⟩ and |−⟩ basis. With one wire in and one out, a green spider at angle α is exactly the phase gate from the gates page.
- What is spider fusion?
- Two spiders of the same colour joined by at least one wire merge into a single spider whose angle is the sum of theirs. It is the rule that makes diagrams shrink, and it is why a long circuit and a short one can be recognised as the same process.
- Do I need category theory to use it?
- No. The rules are visual and you can apply them by hand within a few minutes, which is what this tool is for. Category theory explains where the rules come from and why they are complete, and that can wait until you want to know why it works rather than how.
More interactive quantum tools
- Quantum teleportation, two ways →The same protocol as a circuit and as a bent wire pulled straight.
- Quantum gates and interference →Stack gates on a qubit and watch +0,5 and −0,5 cancel to nothing.
- Superposition and the Bloch sphere →Two angles, one point on a sphere. See which of them a measurement can actually detect.