Skip to main content
simplified question
Source Link

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)) 

circuitcircuit

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}$$paulis

How dobut I incorporate the "control" propertywant to createuse a "controlled-Pauli" operation?handwritten analytical method.

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 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])) 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 = Ulist[0].control(1, ctrl_state=0) circuit.append(Pauli_XX, [2,1,0]) Pauli_ZZ = 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)) 

circuit

What is the equivalent 8x8 matrix operation of these controlled Pauli gates? I know that the (not controlled) Pauli gates can be written as tensor products:

$$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

$$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 do I incorporate the "control" property to create a "controlled-Pauli" operation?

I am learning how to use Qiskit's controlled Pauli gates. 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, Operator circuit = qk.QuantumCircuit(qk.QuantumRegister(3)) Ulist = [f.to_instruction() for f in PauliList(['XX','ZZ'])] circuit.append(Ulist[0].control(1, ctrl_state=1), [2,1,0]) # circuit.append(Ulist[1].control(1, ctrl_state=1), [2,1,0]) circuit.draw(output='mpl') 

circuit

How do I derive the 8x8 matrix operation of these controlled Pauli gates? I'm aware that Qiskit's functions can tell me the form of these matrices:

circOp = Operator.from_circuit(circuit) circOp.draw("latex") 

paulis

but I want to use a handwritten analytical method.

Source Link

Understanding Qiskit's controlled-Pauli gates

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 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])) 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 = Ulist[0].control(1, ctrl_state=0) circuit.append(Pauli_XX, [2,1,0]) Pauli_ZZ = 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)) 

circuit

What is the equivalent 8x8 matrix operation of these controlled Pauli gates? I know that the (not controlled) Pauli gates can be written as tensor products:

$$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

$$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 do I incorporate the "control" property to create a "controlled-Pauli" operation?