I am new to Quantum Computing. I would really appreciate if some one could offer me some ideas, suggestions and/or useful references to solve the following problem about realizing an arbitrary operator by a quantum circuit.

If I start with a general two-qubit operator $\hat{U}$ (which corresponds to a 4 by 4 unitary matrix $U$ in the computational basis), what is the strategy to (1) decompose $U$ into the basic gates, such as the $CNOT$ gate, the Hadamard gate $H$, and the single-qubit rotational gates ($R_x$, $R_y$ and $R_z$); (2) design the corresponding quantum circuit to realize this two-qubit operator $\hat{U}$ (either with ancillary qubits or not)?

In other words, what is the strategy (1) to convert the following unitary matrix (two-qubit operator $\hat{U}$ in the computational basis $\{ |00\rangle, \ |01\rangle, \ |10\rangle, \ |10\rangle \}$) \begin{align} U= \begin{pmatrix} a & b & c & d \\ b^{\ast} & f & g & h \\ c^{\ast} & g^{\ast} & i & j \\ d^{\ast} & h^{\ast} & j^{\ast} & k \end{pmatrix} \ , \end{align} into the basic gates (e.g., $CNOT$, $H$, $R_x$, $R_y$ and $R_z$ gates); and (2) to realize the unitary matrix $U$ in a quantum circuit?

Thank you!

  • $\begingroup$ I will take some care in following the references provided (they are cryptic at best). Perhaps you may find this arxiv.org/abs/quant-ph/0507171 useful. Look carefully to the proofs, specially in Theorem 4, as in them the process for the decomposition is described. $\endgroup$ Commented Mar 17, 2021 at 13:13

2 Answers 2


Every 2x2 unitary matrix can be decomposed to a matrix product of four matrices expresing rotations and phase shifts.

Every controlled operator (i.e. two qubit gate) can be decomposed to product of three single qubit gates acting on target qubit and two CNOT gates. Single qubit gates can be again decomposed to rotations and phase shifts are mentioned above.

In case your 4x4 matrix can be writen as Kronecker product of two 2x2 matrices, you can again apply decomposition from the first paragraph.

Based on these theorems, you can rewrite any two qubit operators in terms of CNOTs and single qubits rotations and phase shifts. All these gates are available on a quantum computer.

Please see details how to do so in Elementary gates for quantum computing.


A universal method to decompose 2-qubit unitaries into primitive gates is sometimes referred to as "Krauss-Cirac decomposition". Here are several sources:

For gates on multiple qubits, this question offers several more sources.

  • $\begingroup$ @ Mariia Mykhailova Thank you for your comments and suggestions. I will read these papers to solve the toy problem described in the question. I do have further questions. Are there other options for solving this problem, such as the Cosine-Sine Decomposition and the Gray code. Are they applicable? $\endgroup$
    – Marxmas
    Commented Dec 19, 2019 at 2:32
  • $\begingroup$ @ Mariia Mykhailova I ask so because of the following reason. Eventually, I would like to generalize the 4 by 4 problem to, e.g., 8 by 8 matrix problem. Therefore, I am looking for functional algorithms (it would be better if they go with examples) that are more general, robust and hopefully efficient as well. I was wondering if you would recommend some useful references as well for solving the more general problems, e.g., decomposing the 8 by 8 matrix. $\endgroup$
    – Marxmas
    Commented Dec 19, 2019 at 2:33
  • $\begingroup$ I've added a link to a question that has more resources on decomposing multi-qubit gates. $\endgroup$ Commented Dec 19, 2019 at 17:47
  • $\begingroup$ @Marxmas maybe something is known for a high number of qubits. As far as I know, the decomposition given here is actually "the same" as the one known for quaternions. I don't doubt that a similar $8\times 8$ decomposition may exist, but as you will see in my comment above, the $4\times 4$-case is sufficiently complicated and I don't want to imagine how would it look like for higher orders. $\endgroup$ Commented Mar 17, 2021 at 13:18
  • $\begingroup$ Hence, if you do it you maybe have a paper or a thesis. However, a better idea would be to find a relation between $8\times 8$ transformation that uses the $4\times 4$ computation given here... $\endgroup$ Commented Mar 17, 2021 at 13:20

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.