I am learning how to use Qiskit's controlled Pauli gates by comparing with Python's numpy matrix multiplication operations. For example, I can create a simple three-qubit circuit containing controlled Pauli-XX and -ZZ gates using the code:
import numpy as np import qiskit as qk from qiskit.quantum_info import PauliList from qiskit_aer import StatevectorSimulator xlist = np.array([8, 3])/np.linalg.norm(np.array([8, 3])) ylist = np.array([5, 6])/np.linalg.norm(np.array([5, 6])) zlist = np.array([1, 4])/np.linalg.norm(np.array([1, 4]))Operator circuit = qk.QuantumCircuit(qk.QuantumRegister(3)) circuit.initialize(xlist, [1]) circuit.initialize(ylist, [0]) circuit.initialize(zlist, [2]) Ulist = [f.to_instruction() for f in PauliList(['XX','ZZ'])] Pauli_XX = circuit.append(Ulist[0].control(1, ctrl_state=0ctrl_state=1) circuit.append(Pauli_XX, [2,1,0]) Pauli_ZZ =# circuit.append(Ulist[1].control(1, ctrl_state=1) circuit.append(Pauli_ZZ, [2,1,0]) ## circuit measurement simulator = StatevectorSimulator() job = qk.transpile(circuit, simulator) out = simulator.run(job,shots=16).result().get_statevector() print(out) circuit.draw(output='mpl') The initial entangled state is alternatively calculated using numpy:
psi = np.kron(xlist,ylist) psi = np.kron(zlist,psi) print('init state = ' + str(psi)) What isHow do I derive the equivalent 8x8 matrix operation of these controlled Pauli gates? I know I'm aware that the (not controlled) Pauli gatesQiskit's functions can be written as tensor productstell me the form of these matrices:
$$X \otimes X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \otimes \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \end{bmatrix}$$
and
circOp = Operator.from_circuit(circuit) circOp.draw("latex") $$Z \otimes Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \otimes \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 \\ 0 & 0 & -1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}$$
How dobut I incorporate the "control" propertywant to createuse a "controlled-Pauli" operation?handwritten analytical method.

