# How do I compute the output of quantum circuit involving multiple gates?

I'm new in quantum computing, I have this question.

Qubits $$x$$ and $$y$$ are in $$\mathbb{C}^2$$ (column vector) and $$A, B$$ are unitary matrices ($$A$$ 8x8 and $$B$$ 4x4 matrix).

If I'm not wrong the input of $$A$$ is $$x_1 \otimes x_2 \otimes x_3$$ which is in $$\mathbb{C}^8$$ (column vector). Now given the output $$z=A(x_1 \otimes x_2 \otimes x_3)$$ how can I extract $$y_3$$ from $$z$$ to calculate $$y_3 \otimes y_4$$ ($$x_4 = y_4$$) which is the input of $$B$$?

• Suppose the circuit goes on. I don't want to measure y's. I want to how to perform calculation after A matrix-gate.
– asv
Apr 28, 2020 at 15:12
• I want to know how to calculation are peformed. I don't want to use software I want to understand the calculation.
– asv
Apr 28, 2020 at 15:15
• Use the partial trace: en.wikipedia.org/wiki/Partial_trace Apr 28, 2020 at 15:19
In general, you cannot just extract the part of the state that corresponds to $$y_3$$ and $$y_4$$. Instead, you have to consider the entire state (which you will describe using a 16-element vector), and you apply to it the unitary $$I\otimes B$$ where $$I$$ is the $$4\times 4$$ identity matrix.