> ## Documentation Index
> Fetch the complete documentation index at: https://docs.classiq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Estimate the Total Error

`estimate_total_errors` combines a routed `program` (from
[routing](/user-guide/error-correction/routing)) with the `logical_noise` fits (from
[initializing the logical noise model](/user-guide/error-correction/logical-noise)) to
estimate the program's total error (`1 - fidelity`) at each requested code distance. Larger
code distances suppress errors further, at the cost of more physical qubits.

[comment]: DO_NOT_TEST

```python theme={null}
from classiq.error_correction.total_error import estimate_total_errors

total_errors = estimate_total_errors(
    program,
    logical_noise,
    code_distances=[5, 7, 9, 11],
)

for code_distance, error in total_errors.items():
    print(f"d={code_distance}: total error = {error:.2e}")
```

`estimate_total_errors` returns a `dict` mapping each code distance to its estimated total
error, and the loop above prints it like this:

```text theme={null}
d=5: total error = 3.14e-03
d=7: total error = 8.72e-05
d=9: total error = 2.35e-06
d=11: total error = 6.03e-08
```

Reading it: each step up in code distance suppresses the total error by roughly two orders
of magnitude here, so you can pick the smallest distance that meets your target fidelity —
trading physical-qubit overhead against logical accuracy.
