---
title: library (latest version)
description: API reference for qiskit_fermions.operators.library in the latest version of qiskit-fermions
source: https://quantum.cloud.ibm.com/docs/en/api/qiskit-fermions/operators-library
---

# Operator Library

Building on top of the operator representations provided by [`operators`](/docs/api/qiskit-fermions/operators#module-qiskit_fermions.operators "qiskit_fermions.operators"), this module provides various tools to simplify the construction of commonly used operators.

## Commutator Generators

Operator classes can implement the [`SupportsCommutators`](/docs/api/qiskit-fermions/protocols-supports-commutators#qiskit_fermions.protocols.SupportsCommutators "qiskit_fermions.protocols.SupportsCommutators") [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol), which allows them to be used with the functions listed in the table below, to quickly compute multiple commutator variants.

|                                                                                                                                                                                                                           |                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| [`commutator`](/docs/api/qiskit-fermions/operators-library-commutator#qiskit_fermions.operators.library.commutator "qiskit_fermions.operators.library.commutator")(op\_a, op\_b)                                          | Computes the commutator of two operators.          |
| [`anti_commutator`](/docs/api/qiskit-fermions/operators-library-anti-commutator#qiskit_fermions.operators.library.anti_commutator "qiskit_fermions.operators.library.anti_commutator")(op\_a, op\_b)                      | Computes the anti-commutator of two operators.     |
| [`double_commutator`](/docs/api/qiskit-fermions/operators-library-double-commutator#qiskit_fermions.operators.library.double_commutator "qiskit_fermions.operators.library.double_commutator")(op\_a, op\_b, op\_c, sign) | Computes the double-commutator of three operators. |

## Common Operators

Various common operators can easily be generated from constructor methods. This section provides an overview of these methods for a quick reference, grouped by category.

### Electronic Integrals

The constructor methods listed here generally take the coefficients of electronic structure Hamiltonians as an input. Different flavors exist:

- `tril`: these methods consume 1-dimensional arrays of flattened (generalized) triangular indices
- `full`: these methods consume high-dimensional arrays
- `spin`: these methods take separate arrays for the different spin species
- `sym`: these methods take a single array for one spin species and infer the other spin species
- 1-Body Terms

|                                                                                                                                                                                                                                              |                                                             |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [`FermionOperator.from_1body_tril_spin_sym()`](/docs/api/qiskit-fermions/operators-fermion-operator#qiskit_fermions.operators.FermionOperator.from_1body_tril_spin_sym "qiskit_fermions.operators.FermionOperator.from_1body_tril_spin_sym") | Constructs from spin-symmetric triangular 1-body integrals. |
| [`FermionOperator.from_1body_tril_spin()`](/docs/api/qiskit-fermions/operators-fermion-operator#qiskit_fermions.operators.FermionOperator.from_1body_tril_spin "qiskit_fermions.operators.FermionOperator.from_1body_tril_spin")             | Constructs from separate spin triangular 1-body integrals.  |

- 2-Body Terms

|                                                                                                                                                                                                                                              |                                                             |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [`FermionOperator.from_2body_tril_spin_sym()`](/docs/api/qiskit-fermions/operators-fermion-operator#qiskit_fermions.operators.FermionOperator.from_2body_tril_spin_sym "qiskit_fermions.operators.FermionOperator.from_2body_tril_spin_sym") | Constructs from spin-symmetric triangular 2-body integrals. |
| [`FermionOperator.from_2body_tril_spin()`](/docs/api/qiskit-fermions/operators-fermion-operator#qiskit_fermions.operators.FermionOperator.from_2body_tril_spin "qiskit_fermions.operators.FermionOperator.from_2body_tril_spin")             | Constructs from separate spin triangular 2-body integrals.  |

## Other Generators

Finally, the following additional operator generator utilities exist in this module:

|                                                                                                                                                           |                                                        |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| [`FCIDump`](/docs/api/qiskit-fermions/operators-library-fci-dump#qiskit_fermions.operators.library.FCIDump "qiskit_fermions.operators.library.FCIDump")() | An electronic structure Hamiltonian in FCIDump format. |
