qml.qchem.qubit_observable¶

qubit_observable(o_ferm, cutoff=1e-12)[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

Returns

Simplified PennyLane Hamiltonian

Return type

Operator

Example

>>> qml.operation.enable_new_opmath()
>>> 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 Hamiltonian instance is returned.

>>> 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]


Using PennyLane

Release news

Development

API

Internals