## `eigenkit.chemistry.fermion`

Fermionic operators: linear combinations of products of creation / annihilation operators on spin-orbital modes.

Conventions (OpenFermion-compatible):

- A *mode* is a spin-orbital, indexed `0 .. M-1`.
- A *ladder operator* is `(mode, action)` with `action = 1` for creation `$a_{\text{mode}}^\dagger$` and `action = 0` for annihilation `a_mode`.
- A *term* is a tuple of ladder operators applied left-to-right, e.g. `$a_2^\dagger a_0$` is `((2, 1), (0, 0))`.

Operators are NOT normal-ordered (the Jordan-Wigner map handles raw products directly), so `$a_p^\dagger a_q$` and `$a_q a_p^\dagger$` are stored as written.

### `FermionOperator`

A complex linear combination of fermionic terms, stored as `{term: coeff}`.

#### `__init__(terms=None)`

Build an operator from a mapping of terms to coefficients.

Parameters:

| Name    | Type                  | Description | Default                                                                                                                                                                                                                                                                                                           |
| ------- | --------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `terms` | \`dict[Term, complex] | None\`      | Maps each term to its coefficient. A term is a tuple of (mode, action) pairs, where action is 1 for creation and 0 for annihilation, applied from left to right. The empty tuple is the identity. The coefficients of repeated terms are added together. Leave it out for the zero operator. The default is None. |

#### `annihilation(mode)`

The annihilation operator `a_mode`.

Parameters:

| Name   | Type  | Description                                                      | Default    |
| ------ | ----- | ---------------------------------------------------------------- | ---------- |
| `mode` | `int` | The index of the spin-orbital from which an electron is removed. | *required* |

Returns:

| Type                | Description                         |
| ------------------- | ----------------------------------- |
| `'FermionOperator'` | The operator, as a FermionOperator. |

#### `creation(mode)`

The creation operator `a†_mode`.

Parameters:

| Name   | Type  | Description                                                    | Default    |
| ------ | ----- | -------------------------------------------------------------- | ---------- |
| `mode` | `int` | The index of the spin-orbital in which an electron is created. | *required* |

Returns:

| Type                | Description                         |
| ------------------- | ----------------------------------- |
| `'FermionOperator'` | The operator, as a FermionOperator. |

#### `hermitian_conjugate()`

The adjoint of the operator.

The order of each term is reversed, creation and annihilation are swapped, and each coefficient is replaced by its complex conjugate.

Returns:

| Type                | Description                        |
| ------------------- | ---------------------------------- |
| `'FermionOperator'` | The adjoint, as a FermionOperator. |

#### `identity(coefficient=1.0)`

The identity operator, optionally scaled.

Parameters:

| Name          | Type     | Description                                                  | Default |
| ------------- | -------- | ------------------------------------------------------------ | ------- |
| `coefficient` | `Scalar` | The factor that multiplies the identity. The default is 1.0. | `1.0`   |

Returns:

| Type                | Description                                |
| ------------------- | ------------------------------------------ |
| `'FermionOperator'` | The scaled identity, as a FermionOperator. |

#### `number(mode)`

The number operator `a†_mode a_mode`.

It counts the electrons in one spin-orbital.

Parameters:

| Name   | Type  | Description                    | Default    |
| ------ | ----- | ------------------------------ | ---------- |
| `mode` | `int` | The index of the spin-orbital. | *required* |

Returns:

| Type                | Description                         |
| ------------------- | ----------------------------------- |
| `'FermionOperator'` | The operator, as a FermionOperator. |

#### `zero()`

The zero operator, which has no terms.

Returns:

| Type                | Description               |
| ------------------- | ------------------------- |
| `'FermionOperator'` | The zero FermionOperator. |
