observable(fermion_ops, init_term=0, mapping='jordan_wigner', wires=None)[source]

Builds the Fermion many-body observable whose expectation value can be measured in PennyLane.

The second-quantized operator of the Fermion many-body system can combine one-particle and two-particle operators as in the case of electronic Hamiltonians \(\hat{H}\):

\[\hat{H} = \sum_{\alpha, \beta} \langle \alpha \vert \hat{t}^{(1)} + \cdots + \hat{t}^{(n)} \vert \beta \rangle ~ \hat{c}_\alpha^\dagger \hat{c}_\beta + \frac{1}{2} \sum_{\alpha, \beta, \gamma, \delta} \langle \alpha, \beta \vert \hat{v}^{(1)} + \cdots + \hat{v}^{(n)} \vert \gamma, \delta \rangle ~ \hat{c}_\alpha^\dagger \hat{c}_\beta^\dagger \hat{c}_\gamma \hat{c}_\delta\]

In the latter equations the indices \(\alpha, \beta, \gamma, \delta\) run over the basis of single-particle states. The operators \(\hat{c}^\dagger\) and \(\hat{c}\) are the particle creation and annihilation operators, respectively. \(\langle \alpha \vert \hat{t} \vert \beta \rangle\) denotes the matrix element of the single-particle operator \(\hat{t}\) entering the observable. For example, in electronic structure calculations, this is the case for: the kinetic energy operator, the nuclei Coulomb potential, or any other external fields included in the Hamiltonian. On the other hand, \(\langle \alpha, \beta \vert \hat{v} \vert \gamma, \delta \rangle\) denotes the matrix element of the two-particle operator \(\hat{v}\), for example, the Coulomb interaction between the electrons.

  • The observable is built by adding the operators \(\sum_{\alpha, \beta} t_{\alpha\beta}^{(i)} \hat{c}_\alpha^\dagger \hat{c}_\beta\) and \(\frac{1}{2} \sum_{\alpha, \beta, \gamma, \delta} v_{\alpha\beta\gamma\delta}^{(i)} \hat{c}_\alpha^\dagger \hat{c}_\beta^\dagger \hat{c}_\gamma \hat{c}_\delta\).

  • Second-quantized operators contributing to the many-body observable must be represented using the FermionOperator data structure as implemented in OpenFermion. See the functions one_particle() and two_particle() to build the FermionOperator representations of one-particle and two-particle operators.

  • The function uses tools of OpenFermion to map the resulting fermionic Hamiltonian to the basis of Pauli matrices via the Jordan-Wigner or Bravyi-Kitaev transformation. Finally, the qubit operator is converted to a PennyLane observable by the function convert_observable().

  • fermion_ops (list[FermionOperator]) – list containing the FermionOperator data structures representing the one-particle and/or two-particle operators entering the many-body observable

  • init_term (float) – Any quantity required to initialize the many-body observable. For example, this can be used to pass the nuclear-nuclear repulsion energy \(V_{nn}\) which is typically included in the electronic Hamiltonian of molecules.

  • mapping (str) – Specifies the fermion-to-qubit mapping. Input values can be 'jordan_wigner' or 'bravyi_kitaev'.

  • wires (Wires, list, tuple, dict) – Custom wire mapping used to convert the qubit operator to an observable measurable in a PennyLane ansatz. For types Wires/list/tuple, each item in the iterable represents a wire label corresponding to the qubit number equal to its index. For type dict, only int-keyed dict (for qubit-to-wire conversion) is accepted. If None, will use identity map (e.g. 0->0, 1->1, …).


the fermionic-to-qubit transformed observable

Return type



>>> t = FermionOperator("0^ 0", 0.5) + FermionOperator("1^ 1", 0.25)
>>> v = FermionOperator("1^ 0^ 0 1", -0.15) + FermionOperator("2^ 0^ 2 0", 0.3)
>>> print(observable([t, v], mapping="jordan_wigner"))
(0.2625) [I0]
+ (-0.1375) [Z0]
+ (-0.0875) [Z1]
+ (-0.0375) [Z0 Z1]
+ (0.075) [Z2]
+ (-0.075) [Z0 Z2]