Design a quantum circuit with 4 input bits ????0,????1,????2,????3 such that it “marks” the amplitudes corresponding to the states ||????0????1????2????3⟩∈{||0011⟩,||1100⟩,||0101⟩}
by inverting their amplitudes, leaving all other states unchanged. In this problem, you are asked to achieve this without using ancillary qubits or a result bit.
Let us consider the simple problem of inverting the amplitude corresponding to ||1111⟩ leaving all the others unchanged. Show that this can be performed using a “multi controlled phase gate” with a phase of ???? radians. Write down a brief description of how such a circuit would work. See documentation for such a gate: https://docs.quantum.ibm.com/api/qiskit/qiskit.circuit.library.MCPhaseGate
A multicontrolled phase gate with control qubits ????0,????1,????2 and operating on ????3 and a phase of ???? implements the unitary operation that transforms ||1111⟩ to −||1111⟩ , while leaving all the other pure states unchanged.
Using the idea of a multi-controlled phase gate, now use X-gates (quantum not) to convert each of the pure states ||0011⟩,||1100⟩,||0101⟩ each to ||1111⟩ and use MCP gate above to mark the phase. Remember to use X-gates to convert the inputs back.
from qiskit import QuantumRegister, QuantumCircuit
from numpy import pi
def mark_pure_states(qc, b0 , b1, b2, b3):
# mark the components corresponding to the pure states |0011> , |1100>, |0101>
# your code here
input_registers = [b0,b1,b2,b3]
for i in input_registers:
qc.h(i)
qc.x(i)
n = len(input_registers)
qc.mcp(np.pi, input_registers[0:n-1], input_registers[n-1])
for i in input_registers:
qc.x(i) # invert back
qc.h(i) # apply Hadamard back
b = QuantumRegister(4, 'b')
qc = QuantumCircuit(b)
mark_pure_states(qc, b[0], b[1], b[2], b[3])
qc.draw('mpl', style='iqp')
quantum draw
Jettapol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.