OpenFermion icon indicating copy to clipboard operation
OpenFermion copied to clipboard

Applying Jordan-Wigner to FermionOperator vs. InteractionOperator

Open max-radin opened this issue 6 years ago • 2 comments

In some cases the result of a Jordan-Wigner transform applied to an InteractionOperator is different if it is converted to a FermionOperator first, as shown in the code below. It seems like jordan_wigner_interaction_op only gives the correct result for Hermitian operators.

from openfermion.ops import InteractionOperator
from openfermion.transforms import get_fermion_operator, jordan_wigner
import numpy as np

N = 4
kappa = np.zeros((N, N))
kappa[0,3] = 2.0
op = InteractionOperator(0., -kappa, np.zeros((N, N, N, N)))

qubit_op1 = jordan_wigner(op)
print(qubit_op1)
# -0.5 [X0 Z1 Z2 X3] +
# -0.5 [Y0 Z1 Z2 Y3]

qubit_op2 = jordan_wigner(get_fermion_operator(op))
print(qubit_op2)
# (-0.5+0j) [X0 Z1 Z2 X3] +
# -0.5j [X0 Z1 Z2 Y3] +
# 0.5j [Y0 Z1 Z2 X3] +
# (-0.5+0j) [Y0 Z1 Z2 Y3]

max-radin avatar Oct 09 '18 20:10 max-radin

Indeed, jordan_wigner_interaction_op is only guaranteed to work for Hermitian operators and is optimized based on that assumption. The InteractionOperator class is intended to represent only Hermitian operators, even though this is neither documented nor enforced. @babbush or @jarrodmcc can correct me if I'm wrong. I think we need to document this better; enforcement would be tricky, though there are certainly things we can do to help (e.g. #444 ).

kevinsung avatar Oct 09 '18 20:10 kevinsung

Yes, so I think we just need better documentation here.

babbush avatar Nov 01 '18 18:11 babbush