Question: impiement the function create _ multi _ control _ U ( qc , b , r , ancilla, control _ u _ gate ) with

impiement the function create_multi_control_U(qc, b, r, ancilla, control_u_gate) with inputs:
- qc : a handle to a QuantumCircuit
-\( b \) : a quantum register with \( n=\) len(b) control qubits
-\( r \) : a single result qubit
- ancilla : a quantum register with \(\mathrm{n-1}\) ancillary qubits
- control_u_gate : a reference to a function that when called as control_u_gate(qc, ctrl_qubit, res_qubit) will implement the controlled-U gate with the specified control qubit operating on the result qubit.
Your circuit can use only the specified gates and must ensure that the ancillary qubits are all transformed back to \(|0\rangle \).
In []:
\# your code here
raise NotImplementedError
```
In []: from numpy import pi
from qiskit import QuantumCircuit, QuantumRegister, execute
from qiskit.providers.aer import Aer
def control_phase_gate(qc, ctrl, res):
qc.cp(pi/2, ctrl, res)
b = QuantumRegister(5,'b')
r = QuantumRegister(1,'r')
a = QuantumRegister(4,'a')
qc = QuantumCircuit( r, b, a)
qc.h(b)
qc.h(r)
create_multi_control_U(qc, b,r[0], a, control_phase_gate )
```
impiement the function create _ multi _ control _

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!