# A problem with application of multi controlled rotation gates [closed]

This message pops up when I run an mcrx gate

The mcrx gate needs a single qubit as target.

Here is a part of code I run:

QC.mcrx(np.pi,[0,1,2],3)
QC.draw('mpl')


'

• Hi and welcome to Quantum Computing SE. Could you please post whole code you have the problem with? Also, please do not post screen shots of an error message but the text of the error itself. Commented Jan 11, 2021 at 8:03

Here is a way to implement multi-controlled RX gate if you interested:

from qiskit import QuantumCircuit,QuantumRegister
from qiskit.circuit.library.standard_gates import RXGate
from qiskit.circuit import Parameter
import matplotlib.pyplot as plt
qr=QuantumRegister(4)
circ=QuantumCircuit(qr)
a=Parameter('a') # You can replace a with pi here
CCCRX=RXGate(a).control(3)
circ.append(CCCRX,qr)
print(circ)


Which output:


q0: ────■────
│
q1: ────■────
│
q2: ────■────
┌───┴───┐
q3: ┤ RX(a) ├
└───────┘


You can decompose this circuit to looks what is being implement underneath by executing the line of code: circ.decompose().draw()  which will output:

If you absolutely want to use mcrx method then this should do it:

from qiskit.circuit.library.standard_gates import mcrx
import numpy as np
qr= QuantumRegister(4)
circ=QuantumCircuit(qr)
circ.mcrx(np.pi,[ qr[0], qr[1], qr[2] ],qr[3])


note that if I decompose this circuit (like we did earlier), I will get the exact same circuit as the decomposed circuit on top (by replacing 'a' with pi to the top circuit):

• i seems to have o problem with it can you do this by using mcrx gate Commented Jan 11, 2021 at 7:52
• I added that part to the answer. Commented Jan 11, 2021 at 8:06
• I also added how the two methods are equivalent by looking at the circuit decomposition of the two circuits. Commented Jan 11, 2021 at 8:17