# Convert Hamiltonian to Ising Formulation or QUBO

I have a tridiagonal Hamiltonian matrix that I need to convert to QUBO or Ising format to use D-Wave's quantum annealing solvers. For a generic tridiagonal: $$\begin{pmatrix} a_1 & b_1 \\ c_1 & a_2 & b_2 \\ & c_2 & \ddots & \ddots \\ & & \ddots & \ddots & b_{n-1} \\ & & & c_{n-1} & a_n \end{pmatrix}$$

How would I convert this to a either a QUBO or an Ising Formulation? I've seen how to do the reverse here, but it seems trying to invert this procedure is somewhat intractable.

Given that you decompose your matrix into a sum of Pauli operators such that there are no instances of $$X$$ and $$Y$$ (so basically a Pauli sum of $$Z$$, $$I$$ and any tensor product of these two), you can define a PauliSumOp object and then use from_ising to convert it into a QUBO program. The code to do this looks as follows:

from qiskit_optimization.translators import from_ising
from qiskit.opflow.primitive_ops import PauliSumOp

op   = PauliSumOp.from_list([("ZZ", 1), ("IZ", 2), ("Z", 3)]) # example operator
qp   = from_ising(op)
qubo = conv.convert(qp)


The particular operator from my example outputs the following QUBO program:

\ This file has been generated by DOcplex
\ ENCODING=ISO-8859-1
\Problem name: CPLEX

Minimize
obj: [ - 24 x0^2 + 32 x0*x1 - 16 x1^2 ]/2 + 6
Subject To

Bounds
0 <= x0 <= 1
0 <= x1 <= 1

Binaries
x0 x1
End

• What happens if the decomposition contains an X or Y? The specific hamiltonian I am working with decomposes into a sum that contains II, IX, XX, and YY. Apr 28 at 21:41