## What is the effect of the reset gate on the matrix form of a gate/circuit?

0

From what I understand, any circuit can be combined to make a gate, which has a square, unitary matrix form that acts on the $$2^n$$ row of the qubits state column vector. For example, the circuit

     ┌───┐
q_0: ┤ H ├──■──
├───┤┌─┴─┐
q_1: ┤ H ├┤ X ├
└───┘└───┘


has the matrix form $$\begin{bmatrix} \tfrac{1}{2} & \tfrac{1}{2} & \tfrac{1}{2} & \tfrac{1}{2} \\ \tfrac{1}{2} & -\tfrac{1}{2} & -\tfrac{1}{2} & \tfrac{1}{2} \\ \tfrac{1}{2} & \tfrac{1}{2} & -\tfrac{1}{2} & -\tfrac{1}{2} \\ \tfrac{1}{2} & -\tfrac{1}{2} & \tfrac{1}{2} & -\tfrac{1}{2} \\ \end{bmatrix}$$ which acts on the vector $$\begin{bmatrix}1 \\ 0 \\ 0 \\ 0 \end{bmatrix}$$ of the initial $$|0\rangle$$ state. But when I try to get_unitary() a circuit with a reset gate, Qiskit tells me that reset instruction is not unitary and therefore it cannot give me any matrix form. My question is, in general, how do a reset gate affect the matrix form of a multi-qubit gate/circuit?

Thank you!

Edit: The circuit I'm trying to find the matrix form for is i.e. like this:

     ┌───┐
q_0: ┤ H ├──■───────
├───┤┌─┴─┐
q_1: ┤ H ├┤ X ├─|0>─
└───┘└───┘


1

The reset isn't unitary, so there is no unitary matrix for the circuit. You need to switch to looking at the general channel of the circuit (e.g. described by Krauss operators).

Alternatively, you can introduce environment qubits and replace the reset with unitary operations acting on the environment (e.g. the reset could swap a zero'd qubit in the environment for the qubit you want to reset). You can then look at the unitary of the system+environment circuit, although keep in mind that there are multiple ways to translate a reset so there is some ambiguity in which unitary you get.

Can you introduce me to where I can learn to describe the circuit like that, that can include even non-unitary instructions (book, paper)? – Kim Dong – 2020-11-17T18:46:42.113

1It's covered in nielsen and Chiang when they describe channels iirc – Craig Gidney – 2020-11-17T21:28:36.300

0

You can use:

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit,  execute, BasicAer, Aer
qreg_q = QuantumRegister(2, 'q')
creg_c = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qreg_q, creg_c)
circuit.h(qreg_q[0])
circuit.h(qreg_q[1])
circuit.cx(qreg_q[0], qreg_q[1])
print(circuit)

backend = Aer.get_backend('unitary_simulator')
job = execute(circuit, backend)
result = job.result()
print(result.get_unitary(circuit, decimals=3))


and you will get the output

     ┌───┐
q_0: ┤ H ├──■──
├───┤┌─┴─┐
q_1: ┤ H ├┤ X ├
└───┘└───┘
c: 2/══════════

[[ 0.5+0.0000000e+00j  0.5-6.1232340e-17j  0.5-6.1232340e-17j
0.5-1.2246468e-16j]
[ 0.5+0.0000000e+00j -0.5+6.1232340e-17j -0.5+6.1232340e-17j
0.5-1.2246468e-16j]
[ 0.5+0.0000000e+00j  0.5-6.1232340e-17j -0.5+6.1232340e-17j
-0.5+1.2246468e-16j]
[ 0.5+0.0000000e+00j -0.5+6.1232340e-17j  0.5-6.1232340e-17j
-0.5+1.2246468e-16j]]


But you can also use the quantum_info option.. by running the following code using the above circuit:

import qiskit.quantum_info as qi
operator = qi.Operator(circuit)


The output of operator will be:

Operator([[ 0.5+0.j,  0.5+0.j,  0.5+0.j,  0.5+0.j],
[ 0.5+0.j, -0.5+0.j, -0.5+0.j,  0.5+0.j],
[ 0.5+0.j,  0.5+0.j, -0.5+0.j, -0.5+0.j],
[ 0.5+0.j, -0.5+0.j,  0.5+0.j, -0.5+0.j]],
input_dims=(2, 2), output_dims=(2, 2))


Hope this is what you are looking for.

update: The above description is of course without having the reset operation being applied. Resetting a qubit is not a unitary operation as $$U|0\rangle = |0\rangle$$ and $$U|1\rangle = |0\rangle$$, hence it is not a reversible operation.

I just tried but sadly it didn't work. It said 'Cannot apply Instruction: reset' – Kim Dong – 2020-11-17T11:18:46.680

I see your edited version of the circuit. So the reset option is not unitary hence the reason you can't generate the unitary matrix from your circuit. Reset a qubit to the state $|0\rangle$ can be done by applying measurement (in the computational basis as usual) then apply a bit-flip (X-gate) if the qubit is a $|1\rangle$ and do nothing if it is $|0\rangle$. And we know that measurement is not a unitary operation as well. – KAJ226 – 2020-11-17T18:22:01.250