# qrisp.QuantumVariable.uncompute#

QuantumVariable.uncompute(do_it=True, recompute=False)[source]#

Method for automatic uncomputation. Uses a generalized form of this algorithm.

Parameters
do_itbool, optional

If set to False, this variable will be appended to the uncomputation stack of it’s QuantumSession and uncomputed once an uncompute call with `do_it = True` is performed. The default is True.

recomputebool, optional

If set to True, this QuantumVariable will be uncomputed but temporarily recomputed, if it is required for the uncomputation of another QuantumVariable. For more information check recomputation. The default is False.

Examples

We create two QuantumVariables, apply some gates and perform automatic uncomputation:

```>>> from qrisp import QuantumVariable, x, cx, h, p, mcx
>>> a = QuantumVariable(3)
>>> b = QuantumVariable(2)
>>> mcx(a, b[0])
>>> h(a[:2])
>>> x(b[0])
>>> cx(b[0], b[1])
>>> p(0.5, b[1])
>>> print(a.qs)
```
```QuantumCircuit:
--------------
┌───┐
a.0: ──■──┤ H ├───────────────
│  ├───┤
a.1: ──■──┤ H ├───────────────
│  └───┘
a.2: ──■──────────────────────
┌─┴─┐┌───┐
b.0: ┤ X ├┤ X ├──■────────────
└───┘└───┘┌─┴─┐┌────────┐
b.1: ──────────┤ X ├┤ P(0.5) ├
└───┘└────────┘
Live QuantumVariables:
---------------------
QuantumVariable a
QuantumVariable b
```
```>>> b.uncompute()
>>> print(b.qs)
```
```QuantumCircuit:
--------------
┌────────┐                              ┌────────┐┌───┐
a.0: ┤0       ├──────────────────────────────┤0       ├┤ H ├
│        │                              │        │├───┤
a.1: ┤1       ├──────────────────────────────┤1       ├┤ H ├
│  pt3cx │                              │  pt3cx │└───┘
a.2: ┤2       ├──────────────────────────────┤2       ├─────
│        │┌───┐                    ┌───┐│        │
b.0: ┤3       ├┤ X ├──■──────────────■──┤ X ├┤3       ├─────
└────────┘└───┘┌─┴─┐┌────────┐┌─┴─┐└───┘└────────┘
b.1: ───────────────┤ X ├┤ P(0.5) ├┤ X ├────────────────────
└───┘└────────┘└───┘
Live QuantumVariables:
---------------------
QuantumVariable a
```