---
title: real_amplitudes (v2.2)
description: API reference for qiskit.circuit.library.real_amplitudes in qiskit v2.2
source: https://quantum.cloud.ibm.com/docs/en/api/qiskit/2.2/qiskit.circuit.library.real_amplitudes
---

# qiskit.circuit.library.real\_amplitudes

`qiskit.circuit.library.real_amplitudes(num_qubits, entanglement='reverse_linear', reps=3, skip_unentangled_qubits=False, skip_final_rotation_layer=False, parameter_prefix='θ', insert_barriers=False, name='RealAmplitudes')`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/circuit/library/n_local/real_amplitudes.py#L27-L136)

Construct a real-amplitudes 2-local circuit.

This circuit is a heuristic trial wave function used, e.g., as ansatz in chemistry, optimization or machine learning applications. The circuit consists of alternating layers of $Y$ rotations and $CX$ entanglements. The entanglement pattern can be user-defined or selected from a predefined set. This circuit is “real amplitudes” since the prepared quantum states will only have real amplitudes.

For example a `real_amplitudes` circuit with 2 repetitions on 3 qubits with `"reverse_linear"` entanglement is

```python
┌──────────┐ ░            ░ ┌──────────┐ ░            ░ ┌──────────┐
┤ Ry(θ[0]) ├─░────────■───░─┤ Ry(θ[3]) ├─░────────■───░─┤ Ry(θ[6]) ├
├──────────┤ ░      ┌─┴─┐ ░ ├──────────┤ ░      ┌─┴─┐ ░ ├──────────┤
┤ Ry(θ[1]) ├─░───■──┤ X ├─░─┤ Ry(θ[4]) ├─░───■──┤ X ├─░─┤ Ry(θ[7]) ├
├──────────┤ ░ ┌─┴─┐└───┘ ░ ├──────────┤ ░ ┌─┴─┐└───┘ ░ ├──────────┤
┤ Ry(θ[2]) ├─░─┤ X ├──────░─┤ Ry(θ[5]) ├─░─┤ X ├──────░─┤ Ry(θ[8]) ├
└──────────┘ ░ └───┘      ░ └──────────┘ ░ └───┘      ░ └──────────┘
```

The entanglement can be set using the `entanglement` keyword as string or a list of index-pairs. See the documentation of [`n_local()`](/docs/api/qiskit/2.2/qiskit.circuit.library.n_local "qiskit.circuit.library.n_local"). Additional options that can be set include the number of repetitions, skipping rotation gates on qubits that are not entangled, leaving out the final rotation layer and inserting barriers in between the rotation and entanglement layers.

Examples:

```python
from qiskit.circuit.library import real_amplitudes

ansatz = real_amplitudes(3, reps=2)  # create the circuit on 3 qubits
ansatz.draw("mpl")
```

![Circuit diagram output by the previous code.](https://quantum.cloud.ibm.com/docs/images/api/qiskit/2.2/qiskit-circuit-library-real_amplitudes-1.avif)

```python
ansatz = real_amplitudes(3, entanglement="full", reps=2)  # it is the same unitary as above
ansatz.draw("mpl")
```

![Circuit diagram output by the previous code.](https://quantum.cloud.ibm.com/docs/images/api/qiskit/2.2/qiskit-circuit-library-real_amplitudes-2.avif)

```python
ansatz = real_amplitudes(3, entanglement="linear", reps=2, insert_barriers=True)
ansatz.draw("mpl")
```

![Circuit diagram output by the previous code.](https://quantum.cloud.ibm.com/docs/images/api/qiskit/2.2/qiskit-circuit-library-real_amplitudes-3.avif)

```python
ansatz = real_amplitudes(4, reps=2, entanglement=[[0,3], [0,2]], skip_unentangled_qubits=True)
ansatz.draw("mpl")
```

![Circuit diagram output by the previous code.](https://quantum.cloud.ibm.com/docs/images/api/qiskit/2.2/qiskit-circuit-library-real_amplitudes-4.avif)

**Parameters**

- **num\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int)) – The number of qubits of the RealAmplitudes circuit.
- **reps** ([*int*](https://docs.python.org/3/library/functions.html#int)) – Specifies how often the structure of a rotation layer followed by an entanglement layer is repeated.
- **entanglement** (*BlockEntanglement | Iterable\[BlockEntanglement] | Callable\[\[*[*int*](https://docs.python.org/3/library/functions.html#int)*], BlockEntanglement | Iterable\[BlockEntanglement]]*) – The indices specifying on which qubits the input blocks act. See [`n_local()`](/docs/api/qiskit/2.2/qiskit.circuit.library.n_local "qiskit.circuit.library.n_local") for detailed information.
- **skip\_final\_rotation\_layer** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – Whether a final rotation layer is added to the circuit.
- **skip\_unentangled\_qubits** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – If `True`, the rotation gates act only on qubits that are entangled. If `False`, the rotation gates act on all qubits.
- **parameter\_prefix** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – The name of the free parameters.
- **insert\_barriers** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – If True, barriers are inserted in between each layer. If False, no barriers are inserted.
- **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – The name of the circuit.

**Returns**

A real-amplitudes circuit.

**Return type**

[QuantumCircuit](/docs/api/qiskit/2.2/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
