QPanda3  0.1.0
Supported by OriginQ
Loading...
Searching...
No Matches
PauliOperator

Prev Tutorial: Quantum Visualization
Next Tutorial: Variational Quantum Circuit


Introduction

Pauli operator is an important concept in quantum mechanics, with a wide range of application prospects. The mathematical form of the Pauli operator is a matrix, usually represented as S = (Sx, Sy, Sz), where Sx, Sy, Sz represent the components of spin in the x, y, and z directions, respectively. These four components, including a unit vector, can be easily applied to calculations and derivations in quantum mechanics. Specifically, the Pauli operators are a set of three 2×2 unitary matrices The Hermitian matrix is also known as the unitary matrix. These four components correspond to the quantum logic gate X (x-direction component), the quantum logic gate Y (y-direction component), the quantum logic gate Z (z-direction component), and the quantum logic gate I unit vector.

To distinguish between the X, Y, Z gates and the combination of these four gates, we refer to these four gates as the basic Pauli operators, and the combination of these four gates as the Pauli operator combination. The combination of Pauli operators can express complex physical concepts. For example, the Hamiltonian can be simulated using a combination of basic Pauli operators.

The lower part uses \(\sigma_X\) \(\sigma_Y\) \(\sigma_Z\) \(\sigma_f\) to represent the unitary matrices corresponding to X, Y, Z, and I, respectively.

Unitary matrix

The unitary matrix of the Pauli operator in the basis

\[ \sigma_X= \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \]

\[ \sigma_Y= \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix} \]

\[ \sigma_Z= \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \]

\[ \sigma_I= \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \]

Matrix multiplication

Matrix multiplication operation between basic Pauli operators

The \(=\) below represents the equal sign in mathematical formulas

XX,YY,ZZ

The Pauli operator multiplied by itself yields the identity matrix

\[ \sigma_X\sigma_X=\sigma_I \]

\[ \sigma_Y\sigma_Y=\sigma_I \]

\[ \sigma_Z\sigma_Z=\sigma_I \]

X/Y/Z and I

The value of the Pauli operator multiplied by the identity matrix remains unchanged, whether it is multiplied by the left or right

\[ \sigma_X\sigma_I=\sigma_I\sigma_X=\sigma_I \]

\[ \sigma_Y\sigma_I=\sigma_I\sigma_X=\sigma_I \]

\[ \sigma_Z\sigma_I=\sigma_I\sigma_X=\sigma_I \]

X/Y/Z and X/Y/Z

Multiplication between X, Y, Z

\[ \sigma_X\sigma_Y=i\sigma_Z \]

\[ \sigma_Y\sigma_X=-i\sigma_Z \]

\[ \sigma_X\sigma_Z=-i\sigma_Y \]

\[ \sigma_Z\sigma_X=i\sigma_Y \]

\[ \sigma_Y\sigma_Z=i\sigma_X \]

\[ \sigma_Z\sigma_Y=-i\sigma_X \]

Simulation of Pauli Operator

QPanda3 uses the PauliOperator class to simulate basic Pauli operators and their combinations. To simulate the way Pauli operators act on quantum systems, the PauliOperator class assigns a qubit index to each of the basic Pauli operators. Each PauliOperator object can be expressed using a quantum circuit such as QCircuit in QPanda3.

For X/Y/Z/I

Simulation of the Pauli operator for the foundation

Here is API doc

Simulation of Pauli X

Output

op:
{ qbit_total = 1, pauli_with_coef_s = { 'X0 ':1 + 0j, } }

Simulation of Pauli Y

Output

op:
{ qbit_total = 1, pauli_with_coef_s = { 'Y0 ':1 + 0j, } }

Simulation of Pauli Z

Output

op:
{ qbit_total = 1, pauli_with_coef_s = { 'Z0 ':1 + 0j, } }

Simulation of Pauli I

Output

op:
{ qbit_totql = 1, paulis = [ 'I', ], coefs = [ 1 + 0j, ] }

For combination

Simulation of the combination of Pauli operators

Here is API doc

From vectors

Constructs a PauliOperator from vectors of operations and coefficients.

Output

op:
{ qbit_totql = 3, paulis = [ 'XZI', 'IXY', ], coefs = [ 2 + 0j, 3 + 0j, ] }

From tuples

Constructs a PauliOperator from a vector of tuples.

Output

op:
{ qbit_totql = 5, paulis = [ 'XXIIZ', 'IZZII', ], coefs = [ 1 + 2j, -1 + 1j, ] }

Operations

Addition, subtraction, multiplication, division, and tensor product operations

Describing

For the convenience of description, some expressions are agreed upon here. These expressions will be used for explanation in the following.

Terms of Pauli Operator

The "X0 Z1" and "X1 Y2" in PauliOperator({"X0 Z1":2+1.j,"X1 Y2":3+1.j}) are called terms of the PauliOperator object;

Equivalence

The equivalence of Pauli operator terms

  • Essential condition 1: The quantum systems corresponding to the two Pauli operator terms are identical, which is manifested as the qbits in the quantum system being completely identical
  • Essential condition 2: The two Pauli operator terms have the same effect on the quantum system

For examples

  • "X0 Z1" is equal to "X0 Z1" provided that the corresponding quantum systems are the same, both containing qbits with indices 0 and 1, and that the other qbits are also the same
  • "X1 Y2" is equal to "I0 X1 Y2" if the corresponding quantum systems are the same, both containing qbits with indices 0, 1, and 2, and other qbits are also the same

Coefficient

Coefficients of Pauli operator terms

For PauliOperator({“X0 Z1”:2+1.j,”X1 Y2”:3+1.j}) , we call 2+1.j the coefficient of term “X0 Z1” and 3+1.j the coefficient of term “X1 Y2” .

Addition

Here is API doc

Using rules

PauliOperator + PauliOperator

Output

H3: { qbit_total = 2, pauli_with_coef_s = { 'X0 Y1 ':3 + 0j, } }

Rules of operation

  • If the items are the same, the coefficients of the corresponding items are added
  • Different items, different items and their coefficients are retained
  • If the coefficient of an item is 0, delete the item

Subtraction

Here is API doc

Using rules

PauliOperator - PauliOperator

Output

H3: { qbit_total = 2, pauli_with_coef_s = { 'X0 Y1 ':-1 + 0j, } }

Rules of operation

  • If the items are the same, the coefficients of the corresponding items are subtracted
  • If the items are different, different items and their coefficients will be retained
  • If the coefficient of an item is 0, delete the item

Scalar multiplication

Here is API doc

Using rules

PauliOperator * Complex
Complex * PauliOperator

Output

H4:
{ qbit_total = 2, pauli_with_coef_s = { 'X0 Y1 ':4.4 + 1j, } }

Rules of operation

  • Multiply each coefficient by a complex number
  • If the coefficient of an item is 0, delete the item

Multiplication

Here is API doc

Using rules

PauliOperator * PauliOperator

Output

H3:
{ qbit_total = 2, pauli_with_coef_s = { '':1 + 0j, } }

Rules of operation

Single-term and single-term

Multiply a PauliOperator object containing only a single term with another PauliOperator object containing only a single term

(1) Consolidated into 1 item:

Output

H3:
{ qbit_total = 4, pauli_with_coef_s = { 'X0 Y1 X2 Y3 ':1 + 0j, } }

(2) Pauli operators on the same qubit can evolve and the coefficients of the terms may be changed during the evolution

Output

H3:
{ qbit_total = 2, pauli_with_coef_s = { 'Y0 Y1 ':0 -1j, } }

(3) If the coefficient of an item is 0, delete the item

Multi-term and Multi-term

Multi-term PauliOperator object multiply Multi-term PauliOperator object

(1) Apply the allocation rate in a manner akin to polynomial multiplication

Output

H3:
{ qbit_total = 1, pauli_with_coef_s = { 'Y0 ':2.64 -2.31j, 'X0 ':2.42 + 2.52j, } }

(2) Apply the rules of addition, multiplication of single terms, and tensor product operations

Tensor product

Here is API doc

Using rules

PauliOperator tensor PauliOperator

Output

H3:
{ qbit_total = 4, pauli_with_coef_s = { 'X0 Y1 X2 Y3 ':1 + 0j, } }

Rules of operation

The qbit numbers of the quantum system Q1 corresponding to the Pauli operator string H1 are 0...n-1; There is a Pauli operator A1 acting on the k1 qbit of Q1.

The qbit numbers of the Q2 quantum system corresponding to the Pauli string H2 are 0...m-1; There is a Pauli operator A2 acting on the k2 qbit of Q2.

After the execution of H3=H1.tensor(H2), the qbit number of the quantum system Q3 corresponding to H3 is 0...(m+n-1),where A1 acts on qbit k1 of Q3 and A2 acts on the (n+k2) qbit of Q3

Continue to apply the rules of addition, multiplication, and division

Output

H3:
{ qbit_total = 7, pauli_with_coef_s = { 'Z0 Y3 Y6 ':1 + 0j, } }

Application

Calculate expectation

On CPUQVM

Calculate the expectation of running quantum programs on quantum systems with Pauli operators

Output

without I:
{ qbit_total = 3, pauli_with_coef_s = { 'X0 Z1 ':2 + 0j, 'X1 Y2 ':3 + 0j, } }
res: 0.0

On QPU

Calculate the expectation of running quantum programs on QPU with Hamiltonian

Please watch Quantum Cloud Service to learn more ablout originqc's cloud service

API doc for QCloudBackend.expval_pauli_operator

Output

Note
The numerical values of the results will fluctuate.
res: 2.1531999999999996

On Full Amplitude Simulator in originqc's cloud

Calculate the expectation of running quantum programs on QPU with Hamiltonian

Please watch Quantum Cloud Service to learn more ablout originqc's cloud service

API doc for QCloudBackend.expval_pauli_operator

Output

res: 3.1