qml.parity_transform¶
- parity_transform(fermi_operator, n, ps=False, wire_map=None, tol=None)[source]¶
Convert a fermionic operator to a qubit operator using the parity mapping.
Note
Hamiltonians created with this mapping should be used with operators and states that are compatible with the parity basis.
In parity mapping, qubit j stores the parity of all j−1 qubits before it. In comparison,
jordan_wigner()
simply uses qubit j to store the occupation number. In parity mapping, the fermionic creation and annihilation operators are mapped to the Pauli operators asa†0=(X0−iY02)⊗X1⊗X2⊗...Xn,a†n=(Zn−1⊗Xn−iYn2)⊗Xn+1⊗Xn+2⊗...⊗Xnand
a0=(X0+iY02)⊗X1⊗X2⊗...Xn,an=(Zn−1⊗Xn+iYn2)⊗Xn+1⊗Xn+2⊗...⊗Xnwhere X, Y, and Z are the Pauli operators and n is the number of qubits, i.e., spin orbitals.
- Parameters
fermi_operator (FermiWord, FermiSentence) – the fermionic operator
n (int) – number of qubits, i.e., spin orbitals in the system
ps (bool) – whether to return the result as a
PauliSentence
instead of anOperator
. Defaults toFalse
.wire_map (dict) – a dictionary defining how to map the orbitals of the Fermi operator to qubit wires. If
None
, the integers used to order the orbitals will be used as wire labels. Defaults toNone
.tol (float) – tolerance for discarding the imaginary part of the coefficients
- Returns
a linear combination of qubit operators
- Return type
Union[PauliSentence, Operator]
Example
>>> w = qml.fermi.from_string('0+ 1-') >>> parity_transform(w, n=6) ( -0.25j * Y(0) + (-0.25+0j) * (X(0) @ Z(1)) + (0.25+0j) * X(0) + 0.25j * (Y(0) @ Z(1)) )
>>> parity_transform(w, n=6, ps=True) -0.25j * Y(0) + (-0.25+0j) * X(0) @ Z(1) + (0.25+0j) * X(0) + 0.25j * Y(0) @ Z(1)
>>> parity_transform(w, n=6, ps=True, wire_map={0: 2, 1: 3}) -0.25j * Y(2) + (-0.25+0j) * X(2) @ Z(3) + (0.25+0j) * X(2) + 0.25j * Y(2) @ Z(3)