# How to make the gate decomposition of CCCRY However, I now also want to do this for CCCRY. Please someone tell me.

• Thank you KAJ226, Yitian Wang and Appo. Nov 27 '20 at 6:06

There is an automatic way to design a gate, utilizing qiskit. When drawing the figure of a quantum, you can use the code circ.decompose().draw() to show a decomposed circuit.

Code first:

from qiskit import QuantumCircuit,QuantumRegister
from qiskit.circuit.library.standard_gates import RYGate
from qiskit.circuit import Parameter
import matplotlib.pyplot as plt
qr=QuantumRegister(4)
circ=QuantumCircuit(qr)
a=Parameter('a') # You can replace a with theta here
CCCRY=RYGate(a).control(3)
circ.append(CCCRY,qr)
circ.decompose().draw('mpl')
plt.show()


And this gives the following decomposition: In this figure, $$U_3(\theta,\phi,\lambda)=RZ(\phi)RX(-\pi/2)RZ(\theta)RX(\pi/2)RZ(\lambda)$$, so $$U_3(\theta,0,0)=RY(\theta)$$.

In general, you can design $$n$$-controlled $$U$$ gate, $$CCC\cdots CU = C^{n}U$$, using the technique from Mike and Ike on page 184, starting with where and here your $$Controlled-U$$ is $$CR_y$$ which is You can use the same trick by replacing $$RY(\theta)$$ by $$CRY(\theta)$$ i.e

$$CCCRY = CC(CRY)$$

Then you can continue the simplification process till you find an excutable circuit.