qml.fermi

Overview

This module contains functions and classes for creating and manipulating fermionic operators.

Functions

bravyi_kitaev(fermi_operator, n[, ps, …])

Convert a fermionic operator to a qubit operator using the Bravyi-Kitaev mapping.

from_string(fermi_string)

Return a fermionic operator object from its string representation.

jordan_wigner(fermi_operator[, ps, …])

Convert a fermionic operator to a qubit operator using the Jordan-Wigner mapping.

parity_transform(fermi_operator, n[, ps, …])

Convert a fermionic operator to a qubit operator using the parity mapping.

Classes

FermiA(orbital)

The fermionic annihilation operator \(a\)

FermiC(orbital)

The fermionic creation operator \(a^{\dagger}\)

FermiSentence(operator)

Immutable dictionary used to represent a Fermi sentence, a linear combination of Fermi words, with the keys as FermiWord instances and the values correspond to coefficients.

FermiWord(operator)

Immutable dictionary used to represent a Fermi word, a product of fermionic creation and annihilation operators, that can be constructed from a standard dictionary.

FermiC and FermiA

The fermionic creation and annihilation operators are constructed with FermiC and FermiA, respectively. We pass in the index of the orbital that the operator acts on. For example, the operators \(a^{\dagger}_0\) and \(a_3\), acting on the \(0\text{th}\) and \(3\text{rd}\) orbitals, are constructed as

>>> qml.FermiC(0)
a⁺(0)
>>> qml.FermiA(3)
a(3)

These operators can be multiplied by each other to create \(n\)-orbital fermionic operators such as \(a^{\dagger}_0 a_0 a^{\dagger}_3 a_3\). We call these \(n\)-orbital fermionic operators Fermi words.

>>> qml.FermiC(0) * qml.FermiA(0) * qml.FermiC(3) * qml.FermiA(3)
a⁺(0) a(0) a⁺(3) a(3)

The Fermi words can be linearly combined to create fermionic operators that we call Fermi sentences. For instance, a fermionic Hamiltonian such as \(H = 1.2 a^{\dagger}_0 a_0 + 2.3 a^{\dagger}_3 a_3\) can be constructed from Fermi words with

>>> h = 1.2 * qml.FermiC(0) * qml.FermiA(0) + 2.3 * qml.FermiC(3) * qml.FermiA(3)
>>> h
1.2 * a⁺(0) a(0)
+ 2.3 * a⁺(3) a(3)

Mapping to qubit operators

The fermionic operators can be mapped to the qubit basis by using the jordan_wigner() function. This function can be used to map FermiC and FermiA operators as well as Fermi words and Fermi sentences.

>>> qml.jordan_wigner(qml.FermiA(1))
(0.5*(PauliZ(wires=[0]) @ PauliX(wires=[1])))
+ (0.5j*(PauliZ(wires=[0]) @ PauliY(wires=[1])))
>>> qml.jordan_wigner(qml.FermiC(1) * qml.FermiA(1))
((0.5+0j)*(Identity(wires=[1])))
+ ((-0.5+0j)*(PauliZ(wires=[1])))
>>> f = 0.5 * qml.FermiC(1) * qml.FermiA(1) + 0.75 * qml.FermiC(2) * qml.FermiA(2)
>>> qml.jordan_wigner(f)
((0.625+0j)*(Identity(wires=[1])))
+ ((-0.25+0j)*(PauliZ(wires=[1])))
+ ((-0.375+0j)*(PauliZ(wires=[2])))

FermiWord and FermiSentence

Fermi words and Fermi sentences can also be constructed directly with FermiWord and FermiSentence by passing dictionaries that define the fermionic operators.

For Fermi words, the dictionary items define the fermionic creation and annihilation operators. The keys of the dictionary are tuples of two integers. The first integer represents the position of the creation/annihilation operator in the Fermi word and the second integer represents the orbital it acts on. The values of the dictionary are one of '+' or '-' symbols that denote creation and annihilation operators, respectively. The operator \(a^{\dagger}_0 a_3 a^{\dagger}_1\) can then be constructed with

>>> qml.fermi.FermiWord({(0, 0): '+', (1, 3): '-', (2, 1): '+'})
a⁺(0) a(3) a⁺(1)

A Fermi sentence can be constructed directly by passing a dictionary of Fermi words and their corresponding coefficients to the FermiSentence class. For instance, the Fermi sentence \(1.2 a^{\dagger}_0 a_0 + 2.3 a^{\dagger}_3 a_3\) can be constructed as

>>> fw1 = qml.fermi.FermiWord({(0, 0): '+', (1, 0): '-'})
>>> fw2 = qml.fermi.FermiWord({(0, 3): '+', (1, 3): '-'})
>>> qml.fermi.FermiSentence({fw1: 1.2, fw2: 2.3})
1.2 * a⁺(0) a(0)
+ 2.3 * a⁺(3) a(3)