---
title: jordan_wigner (latest version)
description: API reference for qiskit_fermions.mappers.library.jordan_wigner in the latest version of qiskit-fermions
source: https://quantum.cloud.ibm.com/docs/en/api/qiskit-fermions/mappers-library-jordan-wigner
---

# jordan\_wigner

`jordan_wigner(operator, num_qubits)`

Map an operator to a `SparseObservable` under the Jordan-Wigner transformation.

This is the type-agnostic entry point to the Jordan-Wigner transformation. It dispatches on the concrete type of `operator` to the appropriate direct implementation. Today only [`FermionOperator`](/docs/api/qiskit-fermions/operators-fermion-operator "qiskit_fermions.operators.FermionOperator") is supported, delegating to [`fermion_jordan_wigner()`](/docs/api/qiskit-fermions/mappers-library-fermion-jordan-wigner "qiskit_fermions.mappers.library.fermion_jordan_wigner"); any other operator type raises a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) until a direct implementation exists for it.

**Parameters**

- **operator** ([*OperatorTrait*](/docs/api/qiskit-fermions/operators-operator-trait "qiskit_fermions.operators.operator_trait.OperatorTrait")) – the operator to map.
- **num\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int)) – the number of qubits for the resulting qubit operator. This must be strictly greater than the largest mode index in `operator` (any additional qubits are padded with the identity).

**Returns**

The mapped qubit operator.

**Raises**

- [**TypeError**](https://docs.python.org/3/library/exceptions.html#TypeError) – if `operator` is of a type for which no Jordan-Wigner implementation exists.
- [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – if `num_qubits` is too small to hold the operator’s support.

**Return type**

[*SparseObservable*](/docs/api/qiskit/qiskit.quantum_info.SparseObservable)

```pycon
>>> from qiskit_fermions.mappers.library import jordan_wigner
>>> from qiskit_fermions.operators import FermionOperator
>>> fop = FermionOperator.from_dict({((True, 0), (False, 0)): 0.1})
>>> jordan_wigner(fop, 2).simplify()
<SparseObservable with 2 terms on 2 qubits: (0.05+0j)() + (-0.05+0j)(Z_0)>
```

An operator type without a direct implementation raises a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError):

```pycon
>>> from qiskit_fermions.operators import MajoranaOperator
>>> mop = MajoranaOperator.from_dict({(0, 1): 1.0})
>>> jordan_wigner(mop, 2)
Traceback (most recent call last):
...
TypeError: jordan_wigner does not support operator type 'MajoranaOperator'; only FermionOperator is supported today.
```
