# How to write an $n$-qubits parametric unitary as a linear combination of tensor products between parametric 2$\times$2 matrices?

As far as I understood, it should always be possible to decompose any $$n$$-qubits unitary $$U$$ into a linear combination of tensor products between $$n$$ complex matrices $$W_i \in \mathbb{M}_{2 \times 2}$$ (acting on single qubits):

$$U = \sum_k \lambda_k \left( \bigotimes_{i=1}^{n} W_i \right)$$

This should be true for unitaries of parametric gates as well; for instance, the RZZGate can be written as follows: $$R_{ZZ}(\theta) = | 0 \rangle \langle 0 | \otimes R_Z(\theta) + | 1 \rangle \langle 1 | \otimes R_Z(-\theta)$$

So, here is my question: is there a general procedure to find such a decomposition for any given parametric $$U$$? In particular, what is the decomposition of the $$R_{XX}(\theta)$$ and $$R_{YY}(\theta)$$ gates?

By a change of basis, you can infer that

$$R_{XX(\theta)} = |+\rangle\langle+|\otimes R_x(\theta)+|-\rangle\langle-|\otimes R_x(-\theta)$$ $$R_{YY(\theta)} = |+i\rangle\langle+i|\otimes R_y(\theta)+|-i\rangle\langle-i|\otimes R_y(-\theta)$$

where $$|\pm\rangle$$ are the eigenstates of $$\sigma_x$$ and $$|\pm i\rangle$$ are the eigenstates of $$\sigma_y$$.

General decompositions

There are infinitely many ways to decompose a unitary $$U$$ as a sum of tensor products of operators. A classic decomposition is to use the Pauli matrices e.g.

$$U = \sum_{a,b,c,... = \{0,x,y,z\}} \lambda_{a,b,c,...} \sigma_a \otimes \sigma_b \otimes \sigma_c\otimes...$$

where $$\sigma_0$$ is the $$2\times2$$ identity matrix. This decomposition is especially easy to perform because the Pauli strings $$\sigma_a\otimes\sigma_b\otimes...$$ are orthonormal.

$$\lambda_{a,b,c,...} = \frac{1}{2^N}\text{Tr}[U(\sigma_a \otimes \sigma_b \otimes \sigma_c\otimes...)]$$

where $$N$$ is the number of qubits. To prove this, just plug the first equation into the second. This would also work for your $$\bigotimes_i W_i$$ decomposition, though you have to modify the above slightly if they aren't orthonormal.

Another even simpler basis to work in is the computational basis

$$U = \sum_{x_1,y_1,x_2,y_2,x_3,y_3...=\{0,1\}} |x_1\rangle\langle y_1|\otimes |x_2\rangle\langle y_2|\otimes|x_3\rangle\langle y_3|\otimes...$$ $$=\sum_{x_1,y_1,x_2,y_2,x_3,y_3...=\{0,1\}} |x_1x_2x_3...\rangle\langle y_1y_2y_3...|$$

A decomposition with nice properties

The above probably doesn't quite answer the essence of your question. The problem is that there are many ways to decompose a unitary into sums of tensor products, but most of them won't give the nice simple decomposition of the RZZ gate that you want.

So more needs to be specified. Do you want to write the gate as a sum over projection operators, like $$U = \sum_{i={0,1}} |i\rangle\langle i| U_i$$? That's not possible in general (consider the swap gate). Do you want a decomposition with the minimum number of terms? That sounds tricky, especially the n-qubit case. Probably worth a separate question!

It's not too bad to say something useful about the two-qubit case, using the Cartan decomposition. Any two-qubit unitary can be written as

$$U = U_1 \otimes U_2 \exp(-i(c_x X\otimes X + c_y Y\otimes Y + c_z Z\otimes Z)) V_1^\dagger \otimes V_2^\dagger$$

If you consider the Taylor expansion of the exponential term, you can see that it will only contain four terms when written in the Pauli basis: $$II$$, $$XX$$, $$YY$$ and $$ZZ$$. (I suspect that this is the minimal general decomposition, but I'm not sure). For the $$R_{ZZ}$$ gate, only $$c_z$$ is non-zero and $$U$$ only contains $$II$$ and $$ZZ$$ terms. The same applies for the $$R_{XX}$$ and $$R_{YY}$$ terms, and a bit of algebra gives you the expressions at the top.

For more details on the Cartan decomposition, see this paper.

• Thank you for the great answer! Could you please add the same kind of decomposition for the XXPlusYYGate and XXMinusYYGate defined in Qiskit? Mar 27 at 11:07
• That would take a few minutes to work out, and like I said it's ambiguous what you want to accomplish with this definition. But I think you should have the tools you need to find a form that you like. You can already start with the matrix decomposition that they give you, which has already performed the matrix exponentiation. If you try expressing it in the Pauli basis, remember that you already know which terms will be non-zero. Mar 27 at 16:49