qml.qchem.qubit_observable

qubit_observable(o_ferm, cutoff=1e-12, mapping='jordan_wigner')[source]

Convert a fermionic observable to a PennyLane qubit observable.

Parameters
  • o_ferm (Union[FermiWord, FermiSentence]) – fermionic operator

  • cutoff (float) – cutoff value for discarding the negligible terms

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

Returns

Simplified PennyLane Hamiltonian

Return type

Operator

Example

>>> w1 = qml.fermi.FermiWord({(0, 0) : '+', (1, 1) : '-'})
>>> w2 = qml.fermi.FermiWord({(0, 0) : '+', (1, 1) : '-'})
>>> s = qml.fermi.FermiSentence({w1 : 1.2, w2: 3.1})
>>> print(qubit_observable(s))
-0.775j * (Y(0) @ X(1)) + 0.775 * (Y(0) @ Y(1)) + 0.775 * (X(0) @ X(1)) + 0.775j * (X(0) @ Y(1))

If the new op-math is deactivated, a legacy Hamiltonian instance is returned.

>>> qml.operation.disable_new_opmath()
UserWarning: Disabling the new Operator arithmetic system for legacy support.
If you need help troubleshooting your code, please visit
https://docs.pennylane.ai/en/stable/news/new_opmath.html
>>> w1 = qml.fermi.FermiWord({(0, 0) : '+', (1, 1) : '-'})
>>> w2 = qml.fermi.FermiWord({(0, 1) : '+', (1, 2) : '-'})
>>> s = qml.fermi.FermiSentence({w1 : 1.2, w2: 3.1})
>>> print(qubit_observable(s))
  (-0.3j) [Y0 X1]
+ (0.3j) [X0 Y1]
+ (-0.775j) [Y1 X2]
+ (0.775j) [X1 Y2]
+ ((0.3+0j)) [Y0 Y1]
+ ((0.3+0j)) [X0 X1]
+ ((0.775+0j)) [Y1 Y2]
+ ((0.775+0j)) [X1 X2]