# How to construct a CCY gate in Qiskit

How can one construct a CCY gate using gates which are native to Qiskit (CCX and single qubit gates). I was able to find the answer for CCZ gates, however guessing and testing until I can figure out CCY seems like a bad way to go.

• could you list what are the gates native to Qiskit? Decomposing procedures depend on the allowed gate set. Also, are you asking "How to construct a CCY gate using gates that are native to Qiskit", or "Is there a general procedure for decomposing arbitrary unitary operations?" I would put one of these two questions in the title/body of the post, and remove the other one (on stackexchange it is encouraged to ask a single question per post)
– glS
May 29, 2019 at 17:51

For $$\mathrm{CC} Y$$, given that you have a decomposition for $$\mathrm{CC} Z$$ (or for $$\textrm{CC} X = \mathrm{Toffoli}$$), all you need is the relationship between $$X$$, $$Y$$, and $$Z$$: $$Y = R_z (-\tfrac\pi2) X R_z (\tfrac\pi2) = R_x (\tfrac\pi2) Z R_x(-\tfrac\pi2)$$ Then, given $$Y = U P U^\dagger$$ for some $$P$$ for which you know a decomposition for $$\mathrm{CC} P$$, simply do the analogous decomposition: $$\mathrm{CC}Y = (\mathbf 1 \otimes \mathbf 1 \otimes U) \mathrm{CC} P (\mathbf 1 \otimes \mathbf 1 \otimes U)^\dagger.$$ You can do this for any self-inverse unitary $$V$$ in place of $$Y$$ as well.