k-means minimizes E(y1,…,yk) = ∑i minc ‖xi − yc‖2 by alternating between two easy sub-problems: (1) fix the centers and reassign each point to its nearest center, then (2) fix the assignment and move each center to the mean of its points. Click "Step" to run one sub-problem at a time and watch the energy on the right only ever go down.