2
$\begingroup$

I am writing a program where I need to find the eigenstates of an operator that is a Kronecker product of conditional quantum gates. I am wondering how I would compute this product in matrix form as the conditional gates act on different qubits.

For example: Say I want to find the Kronecker product of some Pauli-X gate X_k that acts on qubit k and conditional phase gates CZ_i,j that have a control qubit i and target j:

X_1 ⊗ CZ_2,3 ⊗ CZ_3,4 ⊗ CZ_2,4

How would I compute this product so the result is a matrix? (Or in some form where I can find the eigenstates) For context, I am using Python and NumPy.

$\endgroup$
5
  • 2
    $\begingroup$ Your indices overlap. Should make disjoint or clarify the order of terms. $\endgroup$
    – AHusain
    Commented Jun 11, 2019 at 22:20
  • 1
    $\begingroup$ @AHusain: actually, the overlapping terms happen to commute. Still, the question shows a bit of confusion about what the tensor product means. Perhaps the OP would benefit from a solution to a simpler example. $\endgroup$ Commented Jun 12, 2019 at 0:13
  • $\begingroup$ @NieldeBeaudrap Yes the overlapping terms are correct and thank you for the reply. Would you care to elaborate? How I understand it, in a tensor product the first term acts on the first qubit, the second term acts on the second qubit and so forth. My lack on understanding is clear for I am unsure of how to compute the tensor product when gates act on multiple qubits. Can you clarify this? $\endgroup$
    – meelszz
    Commented Jun 12, 2019 at 0:25
  • $\begingroup$ @NieldeBeaudrap so they do. Could still make disjoint so that this question can address how to compute tensor product using Python and Numpy. Could address the underlying confusion of what tensor product means separately. $\endgroup$
    – AHusain
    Commented Jun 12, 2019 at 0:27
  • $\begingroup$ @AHusain Ahh I see. So I must turn the conditional phase gates into disjoint single qubit operators and compute from there? $\endgroup$
    – meelszz
    Commented Jun 12, 2019 at 0:32

2 Answers 2

2
$\begingroup$

You can always write your operation as one gate at a time, and take the product. So, in your case, you'd be calculating a product $$ U=U_1U_2U_3U_4 $$ where, for example, $U_1=X_1=X\otimes 1\otimes 1\otimes 1$, $$U_2=CZ_{2,3}=I\otimes I\otimes I\otimes I-I\otimes |1\rangle\langle 1|\otimes(Z-I)\otimes I,$$ and so on. In particular, you can start to use the formulation I've given you for $U_2$ to work out how to apply CZ on any pair of qubits. For instance, $$ U_4=CP_{2,4}=I\otimes I\otimes I\otimes I-I\otimes |1\rangle\langle 1|\otimes I\otimes(Z-I). $$

$\endgroup$
2
$\begingroup$

pauli_X=[[0,1],[1,0]] cz=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,-1]] np.kron(np.kron(np.kron(pauli_X,cz),cz),cz)

This would compute $X_1 \otimes CZ_{2,3} \otimes CZ_{4,5} \otimes CZ_{6,7}$.

Addressing the confusion about what tensor product means. $A$ operating on $d_1$ qubits $(\mathbb{C}^2)^{\otimes d_1}$ and $B$ operating on $d_2$ qubits $(\mathbb{C}^2)^{\otimes d_2}$ means that $A \otimes B$ will operate on $(\mathbb{C}^2)^{\otimes d_1} \otimes (\mathbb{C}^2)^{\otimes d_2}$ which is $d_1 + d_2$ qubits. No overlapping indices between the $d_1$ and the $d_2$.

Edit: to address comment

In this case there are 7 qubits so the total Hilbert space is $(\mathbb{C}^2)^{\otimes 7} \simeq \mathbb{C}^{2^7}$ with basis indexed by the $2^7$ bit strings of length 7. From 0000000, 0000001, 0000010, etc all the way to 1111111.

$\endgroup$
2
  • $\begingroup$ Ok thank you, this makes sense but how would I compute it if the indices on the CZ gates overlap and are not next to each other? (Like in the question) This is where my confusion is. $\endgroup$
    – meelszz
    Commented Jun 12, 2019 at 5:30
  • $\begingroup$ The code you wrote outputs a matrix with dimensions 128 by 128. This doesn't make sense to me because the matrix is acting on 7 qubits so wouldn't it operate on a vector of size 14? Can you clarify this? I don't understand how you are then able to use the matrix to operate on a state. $\endgroup$
    – meelszz
    Commented Jun 12, 2019 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.