Can anyone explain how Qiskit does the merging of single-qubit gates for the purpose of optimization?

  1. u1(lambda1) * u1(lambda2) = u1(lambda1 + lambda2)

  2. u1(lambda1) * u2(phi2, lambda2) = u2(phi2 + lambda1, lambda2)

  3. u2(phi1, lambda1) * u1(lambda2) = u2(phi1, lambda1 + lambda2)

  4. u1(lambda1) * u3(theta2, phi2, lambda2) = u3(theta2, phi2 + lambda1, lambda2)

  5. u3(theta1, phi1, lambda1) * u1(lambda2) = u3(theta1, phi1, lambda1 + lambda2)

  6. Using Ry(pi/2).Rz(2lambda).Ry(pi/2) = Rz(pi/2).Ry(pi 2lambda).Rz(pi/2),

  7. u2(phi1, lambda1) * u2(phi2,lambda2) = u3(pi - lambda1 - phi2, phi1 + pi/2, lambda2 + pi/2)

  8. For composing u3's or u2's with u3's,u2(phi,lambda) = u3(pi/2, phi, lambda)

How do they come up with these equations? Is there a property to derive them?

  • 2
    $\begingroup$ Have you tried simply substituting the definitions of the different rotations into the formulae and verifying that they work? $\endgroup$
    – DaftWullie
    Aug 27, 2020 at 6:21

1 Answer 1


As pointed by DaftWullie, you can verify these formulas direcly by substituing parameters and multiplying matrices describing the gates. Also you can use very useful formula valid for any rotation around an axis $a$ for angles $\alpha$ and $\beta$: $$ R_a(\alpha)R_a(\beta) = R_a(\alpha+\beta). $$

This can be used in the first identity for example, since $U1$ is in fact z-rotation (up to global phase).


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.