# 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)$$.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 31, "wp-katex-eq": 0, "align": 0, "equation": 3, "x-ck12": 0, "texerror": 0, "math_score": 1.0000040531158447, "perplexity": 2492.0148660972764}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-49/segments/1637964362930.53/warc/CC-MAIN-20211204033320-20211204063320-00189.warc.gz"}