---
title: "Quick start"
description: "Define a small tensor network, search a contraction path, and verify its numerical result."
eyebrow: "Getting started"
---

## Running a search {#choose-route}

After [installing a Python package with Light / Heavy](/docs/installation#python), run the three blocks below in order within one Python session to calculate `A @ B @ C`. A complete package loads its compiled library automatically; source builds first need [library configuration](/docs/installation#engine). This example separates planning from numerical execution; the [homepage demonstration](/#contraction-example) uses a quantum circuit to illustrate tensors, contraction trees, and results.

## 1. Define the network and arrays {#network}

```python
import numpy as np

inputs = [("a", "b"), ("b", "c"), ("c", "d")]
output = ("a", "d")
size_dict = {"a": 2, "b": 3, "c": 4, "d": 2}

a = np.arange(6, dtype=np.float64).reshape(2, 3)
b = np.arange(12, dtype=np.float64).reshape(3, 4)
c = np.arange(8, dtype=np.float64).reshape(4, 2)
arrays = [a, b, c]
```

`inputs[i]` lists indices in the axis order of `arrays[i]`. `output` selects retained indices and their order; `size_dict` must contain every used index and its dimension, with no missing or extra entries.

## 2. Optimize the contraction path {#plan}

```python
from arctn import arctn_plan

plan = arctn_plan(
    inputs, output, size_dict,
    preset="light", seed=0,
)
print("SSA path:", plan.ssa_path)
print("sliced indices:", plan.sliced_legs)
print("metrics:", dict(plan.metrics))
```

`plan` contains network structure, SSA path, and metrics, not numerical arrays. No slicing was requested, so `plan.sliced_legs` is empty. `preset="light"` selects the lower-overhead preset; the default is Heavy.

## 3. Execute and verify {#execute}

```python
result, info = plan.execute(
    arrays, backend="native", return_info=True
)

np.testing.assert_allclose(result, a @ b @ c)
print(info["execution_backend"])
print(result)
```

```text
native
[[ 324.  422.]
 [1008. 1304.]]
```

`execute()` reuses the path without calling Light or Heavy again. `backend="native"` selects the ArcTN Rust CPU executor; NumPy computes the reference result for numerical verification.

## Next steps {#next}

- [Using Heavy](/docs/tutorial-heavy) — Inspect the path, objective, and search time.
- [Slicing example](/docs/tutorial-slicing) — Bound intermediate tensor size.
- [Saving and reusing paths](/docs/tutorial-reuse) — Save paths and slicing information; compile unsliced plans for repeated execution.
- [Quimb example](/docs/tutorial-quimb) — Use an existing Circuit or TensorNetwork.
