# Unitary gate(s) from product of exponent

Often unitary gates are defined as a product of exponentials, with some parameter in the power-term. However, often it is not clear how to construct unitary gates from it, at least not for me that is.

In here we see two of such situations. The first is $$\Pi_{j=1}^n e^{-i\beta\sigma_j^x},$$ with parameter $$\beta$$ and $$\sigma_j^x$$ a single bit Pauli-X on qubit $$j$$. As I understand it, this is the same as a $$R_X(2\beta)$$ gate applied to every qubit. Is that correct?

The second one, that is a bit harder I believe and is related to clauses, is $$\Pi_{\alpha} e^{-i\gamma C_{\alpha}},$$ where $$C_{\alpha}$$ is 1 whenever clause $$\alpha$$ is true and 0 otherwise. How can I implement this as elementary unitary gates?

It may be easier to write with $$e^{-i \beta \sigma^z}$$. You can see that this is the matrix

$$e^{-i \beta \sigma^z} = \begin{pmatrix} e^{-i \beta} & 0\\ 0 & e^{i \beta} \end{pmatrix}\\ = e^{-i \beta} \begin{pmatrix} 1 & 0\\ 0 & e^{i 2 \beta} \end{pmatrix}\\ = e^{-i \beta} R_Z (2 \beta)$$

This was already diagonal in the computational basis so easier, but the same logic holds in the basis for $$\sigma^x$$

For the product, yes you are applying the same to every qubit. You can see that all the individual terms in the product commute. It doesn't matter which order you apply these $$R_X (2 \beta)$$ gates on each.

The second question is a bit misstated with the indexing. You use $$\alpha$$ as the labels for your clauses so it should be

$$\prod_{\alpha=1}^k e^{-i \gamma C_\alpha}$$

where $$C_\alpha$$ is the diagonal $$2^n$$ by $$2^n$$ matrix whose entries are either $$1$$ or $$0$$ depending on whether the clause is true or not. For example if the clause was AND and there were 2 qubits then $$C_\alpha$$ would have diagonal entries $$0,0,0,1$$ for the basis vectors being $$00$$, $$01$$, $$10$$ and $$11$$ in that chosen order. The number of clauses, the number of $$\alpha$$'s does not have to be the same as $$n$$ the number of qubits.

The second question is also a bunch of commuting terms. So if you know how to decompose into gates for a single term, you can just put them one after another in order $$\alpha=1$$ through $$k$$. So let's do just a single term $$e^{-i \gamma C_\alpha}$$ for some arbitrary Boolean expression $$f$$ on $$n$$ inputs.

All the terms are diagonal in the computational basis of size $$2^n$$ with entries either $$e^{-i \gamma}$$ or $$1$$.

It will be useful to have an auxiliary qubit. Then you can think about the reversible circuit that takes you from $$x_1 , \cdots , x_n , y \to x_1 \cdots x_n , y \bigoplus f(x_1 \cdots x_n)$$. This is a reversible operation, so I'll refer to other resources for how to break this down in terms of TOF gates.

So if you have an auxiliary with $$y=0$$ you can do this and then get the auxiliary to be in the state 1 if and only if the $$x_1 \cdots x_n$$. Now do an $$R_Z (-\gamma)$$ on that auxiliary. Now uncompute. That means bringing the auxiliary back to $$0$$. You can do this with the reverse of the reversible circuit you already found.

This will take care of $$e^{-i \gamma C_\alpha}$$ for a single clause. Then just stick all the circuits for all the clauses back to back.

Of course this will be longer than necessary. But now that you have a circuit in many quantum gates that does the job poorly, getting one that does the job well is a much easier task.