qrisp.operators.fermionic.FermionicOperator.reduce#
- FermionicOperator.reduce(assume_hermitian=False)[source]#
Applies the fermionic anticommutation laws to bring the operator into a standard form. This can reduce the amount of terms because several terms might be the permuted version of each other and therefore their coefficients add up.
This function can reduce the amount of terms even further if the user can guarantee that the operator will be hermitized. In this case more identifications can be made.
- Parameters:
- assume_hermitianbool, optional
If set to True the function will assume that the result will be hermitized. The default is False.
- Returns:
- FermionicOperator
The reduced FermionicOperator.
Examples
We create a FermionicOperator with redundant term definitions:
from qrisp.operators import * O = a(0)*a(1) - a(1)*a(0) print(O.reduce()) # Yields: 2*a0*a1
To demonstrate the
assume_hermitian
feature, we create a FermionicOperator that has redundant terms, if hermitized.>>> O = a(0)*a(1) + c(1)*c(0) >>> reduced_O = O.reduce(assume_hermitian = True) >>> print(reduced_O) 2*a0*a1
Hermitizing gives the original operator.
>>> print(reduced_O.hermitize()) 1.0*a0*a1 + 1.0*c1*c0