---
title: simplify (latest version)
description: API reference for qiskit_addon_obp.utils.simplify in the latest version of qiskit-addon-obp
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit-addon-obp/utils-simplify
---

# Pauli operator simplification

`qiskit_addon_obp.utils.simplify`

Functions for simplifying Pauli operators.

### OperatorBudget

*class* `OperatorBudget(max_paulis=None, max_qwc_groups=None, simplify=True, atol=None, rtol=None)`

[GitHub](https://github.com/Qiskit/qiskit-addon-obp/tree/main/qiskit_addon_obp/utils/simplify.py#L43-L77)

Bases: [`object`](https://docs.python.org/3/library/functions.html#object)

A class for storing the constants that determine how large an operator may grow.

Backpropagation will stop if either of the following conditions is met:

- The number of Pauli terms across all of the observables exceeds `max_paulis`. When `max_paulis = None`, the number of Pauli terms in the observables is not constrained.
- The number of qubit-wise commuting Pauli groups across all of the observables exceed `max_qwc_groups`. When `max_qwc_groups = None`, the number of qubit-wise commuting Pauli groups in the observables is not constrained.

**Parameters**

- **max\_paulis** ([*int*](https://docs.python.org/3/library/functions.html#int) *| None*)
- **max\_qwc\_groups** ([*int*](https://docs.python.org/3/library/functions.html#int) *| None*)
- **simplify** ([*bool*](https://docs.python.org/3/library/functions.html#bool))
- **atol** ([*float*](https://docs.python.org/3/library/functions.html#float) *| None*)
- **rtol** ([*float*](https://docs.python.org/3/library/functions.html#float) *| None*)

#### atol

Type: `float | None`

Default value: `None`

Absolute tolerance for checking if coefficients are zero. Defaults to the [`atol`](/docs/api/qiskit/qiskit.quantum_info.SparsePauliOp#atol) value of `SparsePauliOp`.

#### is\_active

`is_active()`

[GitHub](https://github.com/Qiskit/qiskit-addon-obp/tree/main/qiskit_addon_obp/utils/simplify.py#L75-L77)

Return whether `self` places any bounds on operator size.

**Return type**

[bool](https://docs.python.org/3/library/functions.html#bool)

#### max\_paulis

Type: `int | None`

Default value: `None`

The maximum number of Pauli terms the backpropagated operator may contain.

#### max\_qwc\_groups

Type: `int | None`

Default value: `None`

The maximum number of qubit-wise commuting Pauli groups the backpropagated operator may contain.

#### rtol

Type: `float | None`

Default value: `None`

Relative tolerance for checking if coefficients are zero. Defaults to the [`rtol`](/docs/api/qiskit/qiskit.quantum_info.SparsePauliOp#rtol) value of `Sparse`.

#### simplify

Type: `bool`

Default value: `True`

A flag denoting whether to call [`simplify()`](#qiskit_addon_obp.utils.simplify.simplify "qiskit_addon_obp.utils.simplify.simplify") at every iteration.

### SimplifyMetadata

*class* `SimplifyMetadata(num_unique_paulis, num_duplicate_paulis, num_trimmed_paulis, sum_trimmed_coeffs)`

[GitHub](https://github.com/Qiskit/qiskit-addon-obp/tree/main/qiskit_addon_obp/utils/simplify.py#L26-L40)

Bases: [`object`](https://docs.python.org/3/library/functions.html#object)

A simple dataclass for returning the tracked attributes during operator simplification.

**Parameters**

- **num\_unique\_paulis** ([*int*](https://docs.python.org/3/library/functions.html#int))
- **num\_duplicate\_paulis** ([*int*](https://docs.python.org/3/library/functions.html#int))
- **num\_trimmed\_paulis** ([*int*](https://docs.python.org/3/library/functions.html#int))
- **sum\_trimmed\_coeffs** ([*float*](https://docs.python.org/3/library/functions.html#float))

#### num\_duplicate\_paulis

Type: `int`

The number of duplicate Pauli terms. See also `num_duplicate_paulis`.

#### num\_trimmed\_paulis

Type: `int`

The number of trimmed Pauli terms. See also `num_trimmed_paulis`.

#### num\_unique\_paulis

Type: `int`

The number of unique Pauli terms. See also `num_unique_paulis`.

#### sum\_trimmed\_coeffs

Type: `float`

The sum of the trimmed coefficients. See also `sum_trimmed_coeffs`.

### simplify

`simplify(operator, *, atol=None, rtol=None)`

[GitHub](https://github.com/Qiskit/qiskit-addon-obp/tree/main/qiskit_addon_obp/utils/simplify.py#L80-L169)

Simplifies the provided Pauli operator.

This is an adaption of `SparsePauliOp.simplify()` which tracks metadata of the simplified terms.

**Parameters**

- **operator** ([*SparsePauliOp*](/docs/api/qiskit/qiskit.quantum_info.SparsePauliOp)) – the `SparsePauliOp` to simplify.
- **atol** ([*float*](https://docs.python.org/3/library/functions.html#float) *| None*) – the absolute tolerance for checking if coefficients are zero. If `None`, this will fallback to using `SparsePauliOp.atol`.
- **rtol** ([*float*](https://docs.python.org/3/library/functions.html#float) *| None*) – the relative tolerance for checking if coefficients are zero. If `None`, this will fallback to using `SparsePauliOp.rtol`.

**Returns**

The simplified Pauli operator.

**Return type**

[tuple](https://docs.python.org/3/library/stdtypes.html#tuple)\[[*SparsePauliOp*](/docs/api/qiskit/qiskit.quantum_info.SparsePauliOp), [*SimplifyMetadata*](#qiskit_addon_obp.utils.simplify.SimplifyMetadata "qiskit_addon_obp.utils.simplify.SimplifyMetadata")]
