qml.fermi.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 as

\[\begin{split}\begin{align*} a^{\dagger}_0 &= \left (\frac{X_0 - iY_0}{2}  \right )\otimes X_1 \otimes X_2 \otimes ... X_n, \\\\ a^{\dagger}_n &= \left (\frac{Z_{n-1} \otimes X_n - iY_n}{2} \right ) \otimes X_{n+1} \otimes X_{n+2} \otimes ... \otimes X_n \end{align*}\end{split}\]

and

\[\begin{split}\begin{align*} a_0 &= \left (\frac{X_0 + iY_0}{2}  \right )\otimes X_1 \otimes X_2 \otimes ... X_n,\\\\ a_n &= \left (\frac{Z_{n-1} \otimes X_n + iY_n}{2} \right ) \otimes X_{n+1} \otimes X_{n+2} \otimes ... \otimes X_n \end{align*}\end{split}\]

where \(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 an Operator. Defaults to False.

  • 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 to None.

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