---
title: MCXVChain (v2.1)
description: API reference for qiskit.circuit.library.MCXVChain in qiskit v2.1
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/2.1/qiskit.circuit.library.MCXVChain
---

# MCXVChain

*class* `qiskit.circuit.library.MCXVChain(num_ctrl_qubits=None, dirty_ancillas=False, label=None, ctrl_state=None, *, _base_label=None, relative_phase=False, action_only=False)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.1/qiskit/circuit/library/standard_gates/x.py#L1208-L1335)

Bases: [`MCXGate`](/docs/api/qiskit/2.1/qiskit.circuit.library.MCXGate "qiskit.circuit.library.standard_gates.x.MCXGate")

Implement the multi-controlled X gate using a V-chain of CX gates.

**Parameters**

- **dirty\_ancillas** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – when set to `True`, the method applies an optimized multicontrolled-X gate up to a relative phase using dirty ancillary qubits with the properties of lemmas 7 and 8 from arXiv:1501.06911, with at most 8\*k - 6 CNOT gates. For k within the range \{1, …, ceil(n/2)}. And for n representing the total number of qubits.
- **relative\_phase** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – when set to `True`, the method applies the optimized multicontrolled-X gate up to a relative phase, in a way that, by lemma 7 of arXiv:1501.06911, the relative phases of the `action part` cancel out with the phases of the `reset part`.
- **action\_only** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – when set to `True`, the method applies only the action part of lemma 8 from arXiv:1501.06911.
- **num\_ctrl\_qubits** (*Optional\[*[*int*](https://docs.python.org/3/library/functions.html#int)*]*) –
- **label** (*Optional\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str)*]*) –
- **ctrl\_state** (*Optional\[Union\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str)*,* [*int*](https://docs.python.org/3/library/functions.html#int)*]]*) –

## Methods

### get\_num\_ancilla\_qubits

*static* `get_num_ancilla_qubits(num_ctrl_qubits, mode='v-chain')`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.1/qiskit/circuit/library/standard_gates/x.py#L1311-L1314)

Get the number of required ancilla qubits.

**Parameters**

- **num\_ctrl\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int)) –
- **mode** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) –

### inverse

`inverse(annotated=False)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.1/qiskit/circuit/library/standard_gates/x.py#L1284-L1309)

Invert this gate. The MCX is its own inverse.

**Parameters**

**annotated** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – when set to `True`, this is typically used to return an [`AnnotatedOperation`](/docs/api/qiskit/2.1/qiskit.circuit.AnnotatedOperation "qiskit.circuit.AnnotatedOperation") with an inverse modifier set instead of a concrete [`Gate`](/docs/api/qiskit/2.1/qiskit.circuit.Gate "qiskit.circuit.Gate"). However, for this class this argument is ignored as this gate is self-inverse.

**Returns**

inverse gate (self-inverse).

**Return type**

[MCXVChain](#qiskit.circuit.library.MCXVChain "qiskit.circuit.library.MCXVChain")
