Suppose we have a quantum circuit like this. All the gates are known except for one. For any input of q[0] and q[1], we know the corresponding output. I have provided the output state for four different input state which forms a basis .
How can we know that which gate is the unknown gate?
How to solve these types of problems?

- 13,847
- 2
- 25
- 71

- 115
- 7
-
Please refrain from posting one question several times (https://quantumcomputing.stackexchange.com/questions/30027/quantum-circuit-with-one-unknown-gate). Rather edit the former question. – Martin Vesely Feb 04 '23 at 21:50
-
1That question was more general one. I couldn't work out the input state in this question. The answer on this question gives me the way of how to solve the question effectively. – wizzywizzy Feb 05 '23 at 12:49
1 Answers
The effect of a circuit can be explained by matrix-vector multiplications.
If you start with a state $\vec{q}$ and if the gates in your figure are represented by the matrices $A$, $B$, and $U$ (where $U$ is the unknown), then the output will be given by $\vec{q_f} = ABU\vec{q}$.
The $AB$ factor can be replaced by a single matrix called $C$, and with symbolic computation (a.k.a computer algebra) you can combine $U$ and $C$ too.
Let's try this, assuming that your "controlled note" get is just what others usually call "controlled not" or CNOT. Then we have:
$$ A = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix},\tag{1} $$
$$ B = \begin{bmatrix} 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix},\tag{2} $$
$$ U = \begin{bmatrix} a & b & c & d \\ e & f & g & h \\ i & j & k & l \\ m & n & o & p \end{bmatrix},\tag{3} $$
$$ \vec{q} = \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix},\tag{4} $$
and
$$ \vec{q}_f = \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}.\tag{5} $$
This would mean that we have:
$$\tag{6} \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} a & b & c & d \\ e & f & g & h \\ i & j & k & l \\ m & n & o & p \end{bmatrix}\begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix}, $$ $$\tag{7} \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} a & b & c & d \\ e & f & g & h \\ i & j & k & l \\ m & n & o & p \end{bmatrix}\begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix}, $$
$$ \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} = \begin{bmatrix} f \\ b \\ j \\ n \end{bmatrix}.\tag{8} $$
You now have found 4 out of 16 unknown variables. You can do the same for the other 3 scenarios to get the other 4x3 = 12 unkown variables. You can use this matrix-vector multplier to make the computations easier.

- 13,847
- 2
- 25
- 71
-
How do you form the matrix B? I guess it represents Pauli X matrix. But isn't pauli X a 2*2 matrix – wizzywizzy Feb 04 '23 at 15:38
-
1B is the "left Kronecker product" of the identity matrix and the X gate, so in MATLAB/Octave it would be
kron(eye(2),[0 1; 1 0 ])
. – user1271772 No more free time Feb 04 '23 at 15:39 -
So it's like extending X gate to a 4*4 matrix having the same effect? – wizzywizzy Feb 04 '23 at 15:42
-
1Precisely. The identity matrix is happening to qubit 1, and the X matrix is happening to qubit 2. – user1271772 No more free time Feb 04 '23 at 15:43
-
-
-
Any method for solving such problems will be mathematically equivalent to this one, and boil down to the same thing. Instead of maxing the unknown matrix variables = a,b,c,d,e,f,..., you could instead write the unknown matrix as a "paulinomial" as explained here and here and here. Don't forget to click the checkmark under the answer's score if it answered what you were asking. – user1271772 No more free time Feb 04 '23 at 15:58