openfermion.transforms.binary_code_transform
Transforms a Hamiltonian written in fermionic basis into a Hamiltonian written in qubit basis, via a binary code.
openfermion.transforms.binary_code_transform(
hamiltonian: openfermion.ops.FermionOperator,
code: openfermion.ops.BinaryCode
) -> openfermion.ops.QubitOperator
Used in the notebooks
The role of the binary code is to relate the occupation vectors (v0 v1 v2
... vN-1) that span the fermionic basis, to the qubit basis, spanned by
binary vectors (w0, w1, w2, ..., wn-1).
The binary code has to provide an analytic relation between the binary
vectors (v0, v1, ..., vN-1) and (w0, w1, ..., wn-1), and possibly has the
property N>n, when the Fermion basis is smaller than the fermionic Fock
space. The binary_code_transform function can transform Fermion operators
to qubit operators for custom- and qubit-saving mappings.
Note |
|
Logic multi-qubit operators are decomposed into Pauli-strings (e.g.
CPhase(1,2) = 0.5 * (1 + Z1 + Z2 - Z1 Z2 ) ), which might increase
the number of Hamiltonian terms drastically.
|
Args |
hamiltonian
|
FermionOperator
the fermionic Hamiltonian
|
code
|
BinaryCode
the binary code to transform the Hamiltonian
|
Returns |
|
A QubitOperator, the transformed Hamiltonian
|
Raises |
TypeError
|
if the hamiltonian is not a FermionOperator or code is not
a BinaryCode
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-07-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-07-14 UTC."],[],[]]