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.

  • 2
    $\begingroup$ Could you please add more details? Does the matrix represent quadratic part in your QUBO? What about linear part? $\endgroup$ Apr 26, 2022 at 6:02

1 Answer 1


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_optimization.converters import QuadraticProgramToQubo
from qiskit.opflow.primitive_ops import PauliSumOp

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

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

\ This file has been generated by DOcplex
\Problem name: CPLEX

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

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

 x0 x1
  • 1
    $\begingroup$ 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. $\endgroup$
    – MYang
    Apr 28, 2022 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.