# How to map an arbitrary Fermionic operator to Spins (Qubits)?

There are several Tutorials from Qiskit demonstrating the use of PySCF driver. Usually, it takes as input the geometric structure of the molecule -> second quantised-operators -> JW or Parity mapping -> VQE.

However, I do not want to input a molecule but other Fermionic based operators, e.g. Fermi-Hubbard model. How do I do that?

You can do this through FermionicOperator, it is Deprecated in the newer update of qiskit though so you will get warning about this issue.

Here is an example, I just made up some random second-quantized fermionic one-body operator (h1) to demonstrate how this works under the parity mapping:

b = np.random.rand(2,2)
one_body_operator = (b + b.T)/2
ferOp = FermionicOperator(h1=one_body_operator )
qubitOp = ferOp.mapping(map_type='parity' , threshold=0.00000001)
print( qubitOp.print_details() )



which gives you the qubits representation:

II  (0.4098900912867185+0j)
IZ  (-0.23235537601756617+0j)
ZX  (-0.12228344289218121+0j)
IX  (0.12228344289218121+0j)
ZZ  (-0.17753471526915232+0j)



If you want to use Jordan-Wigner, then specify map_type = 'jordan_wigner' . Similarly, map_type = 'bravyi_kitaev'  for Bravyi Kitaev mapping.

Here is the link to Qiskit Ferminonic operator for more details.

• Really helpful, thanks a lot! Just a further clarification: Your example uses a given matrix, however, how would the solution look like for string manipulations? Because I cannot scale up using your method, or can I? – quantumdip May 30 at 17:20