I was wondering, how can one perform a multi-qubit rotation in Quirk? For example, if I want to simulate the magic-state distillation protocol, I need e.g. a $(IIZZZ)_{\pi/8}$ rotation of 5 qubits. Is there a simple way to do it?


1 Answer 1


I use parity controls combined with global phase gates to achieve this effect.


You can alternatively use phase kickback from controlled Pauli gates to temporarily copy the observable's value onto an ancilla, and then phase the ancilla with a Z,S,T,etc gate.

  • $\begingroup$ Thanks! So, if I understand your example correctly, you did a ZZZ rotation of the first 3 qubits, whereas the last one used for the global phase but is not part of the calculation? This is to say, for the magic state distillation with 5 qubits rotations, I need to use an additional one with this sqrt(i) in each rotation? $\endgroup$ Commented Jan 16 at 18:16
  • 1
    $\begingroup$ @DavidDentelski that's right. It's not really involved; just there as a place to park the label. $\endgroup$ Commented Jan 17 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.