qml.pauli.simplify

simplify(h, cutoff=1e-12)[source]

Add together identical terms in the Hamiltonian.

The Hamiltonian terms with identical Pauli words are added together and eliminated if the overall coefficient is smaller than a cutoff value.

Parameters
  • h (Hamiltonian) – PennyLane Hamiltonian

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

Returns

Simplified PennyLane Hamiltonian

Return type

Hamiltonian

Example

>>> c = np.array([0.5, 0.5])
>>> h = qml.Hamiltonian(c, [qml.X(0) @ qml.Y(1), qml.X(0) @ qml.Y(1)])
>>> print(simplify(h))
(1.0) [X0 Y1]