# How to construct a CU3 gate using only CX and U3 gates?

Knowing that CX and U3 (taking 3 parameters $$\theta, \phi$$ and $$\lambda$$) form a set of universal gates how can I construct an arbitrary CU3 gate using a decomposition of only CX and arbitrary U3 gates?

I use the ideas from these slides, specifically slide 8,9,10.

We can decompose any $$U_{3}(\theta,\phi,\lambda)$$ into a rotation around the $$Z,Y$$ & again $$Z$$ axis, because for any $$U \in SU(2)$$ we can write: $$$$U = \begin{bmatrix} e^{i(\alpha-\frac{\beta}{2}-\frac{\delta}{2})}\cos(\frac{\gamma}{2}) & e^{i(\alpha-\frac{\beta}{2}+\frac{\delta}{2})}\sin(\frac{\gamma}{2}) \\ e^{i(\alpha+\frac{\beta}{2}-\frac{\delta}{2})}\sin(\frac{\gamma}{2}) & e^{i(\alpha+\frac{\beta}{2}+\frac{\delta}{2})}\cos(\frac{\gamma}{2}) \end{bmatrix} = e^{i\alpha}R_{z}(\beta)R_{y}(\gamma)R_{z}(\delta),$$$$

where $$\beta$$, $$\gamma$$ & $$\delta$$ can be computed straightforwardly from $$\theta$$, $$\phi$$ and $$\lambda$$.

Then, let $$A = R_{z}(\beta)R_{y}(\gamma/2)$$, $$B = R_{y}(-\gamma/2)R_{z}(-\delta/2-\beta/2)$$ and $$C = R_{z}(\delta/2 - \beta/2)$$.

A straightforward calculation shows that: $$$$\begin{split} ABC &= R_{z}(\beta)R_{y}(\gamma/2)R_{y}(-\gamma/2)R_{z}(-\delta/2-\beta/2)R_{z}(\delta/2 - \beta/2) = I\\ AXBXC &= R_{z}(\beta)R_{y}(\gamma/2)XR_{y}(-\gamma/2)R_{z}(-\delta/2-\beta/2)XR_{z}(\delta/2 - \beta/2) \\ &= R_{z}(\beta)R_{y}(\gamma/2)R_{y}(\gamma/2)XXR_{z}(\delta/2+\beta/2)R_{z}(\delta/2 - \beta/2) \\ &= R_{z}(\beta)R_{y}(\gamma)R_{z}(\delta) = e^{-i\alpha}U. \end{split}$$$$

We can use this fact to implement $$CU$$ by using two $$CX$$ gates that we apply between the $$A$$&$$B$$ and the $$B$$&$$C$$ gates: $$$$\begin{split} &(I\otimes A)CX(I\otimes B)CX(I\otimes C) \\ = &\big(|0\rangle\langle0|\otimes ABC\big) + \big(|1\rangle\langle1|\otimes AXBXC\big) \\ = &\big(|0\rangle\langle0|\otimes I\big) + \big(|1\rangle\langle1|\otimes e^{-i\alpha}U\big) \\ = & CU \big(R_{z}(\alpha)\otimes I\big) \end{split}$$$$ where the last phase gate on the control qubit is needed because we have the phase $$\alpha$$ in our equality $$U = e^{i\alpha}AXBXC$$.

This allows us to implement any controlled-$$U$$ gate.

• If you need help with calculating $\big(\alpha, \beta, \gamma, \delta\big)$ from $\big(\theta, \phi, \lambda\big)$ please let me know! – JSdJ May 7 '20 at 12:04

Here is a construction of $$CU3$$ gate on IBM Q:

  u1((lambda+phi)/2) c;
u1((lambda-phi)/2) t;
cx c,t;
u3(-theta/2,0,-(phi+lambda)/2) t;
cx c,t;
u3(theta/2,phi,0) t;


Where t is a target qubit and c is control qubit.

Note that $$U1$$ gate is a special case of $$U3$$, it holds that $$U1(\lambda)=U3(0,0,\lambda)$$.