# Pauli Strings on the same qubit?

I am working on solving a Max-Cut problem using fewer qubits via efficient encoding methods of more classical information onto a single qubit.Using the method of

The original problem has the formulation (say): maximize $$-2 x_0x_3 - 2x_0x_6 - 2x_0x_8 - 2x_1x_5 - 2x_1x_7 - 2x_1x_8 - \dots ...$$

I'm making use of Pauli Correlations (as mentioned in this paper) to encode the binary variables.

Eg: $$[x_0, x_1,x_2, \dots , x_8] = [XXI, XIX, IXX, YYI, YIY, IYY, ZZI, ZIZ, IZZ]$$

Now when the Hamiltonian is calculated, I have interacting terms, like for the first term:

$$x_0 \times x_3 = XXI \times YYI$$

But how to encode this in the pauli list or sparsepauli list of qiskit?

I know that $$X \times Y = \iota Z$$, but I cannot write

op = SparsePauliOp.from_list([("iZiZI", -2)])


or is it correct to write them as separate terms in the SparsePauliOp, like this:

op = SparsePauliOp.from_list([("XXI", -2),("YYI", -2)])


How do I generate the Hamiltonian $$H$$ of the given maxcut problem, where the binary variables are not encoded on the $$Z$$ basis, rather than in the pairs of Pauli Correlations, as mentioned above?

How can I go about coding this thing up?

• If my answer was helpful in solving your question can you please mark it as accepted. As this is a common question about SparsePauliOp accepted answer will indicate future visitors that the particular answer was helpful. Commented May 20 at 4:38

To get a sparse pauli operator for $$X \times Y = iZ$$ you can use complex coeffecients. Here is how you can do this:

op = SparsePauliOp.from_list([("Z", 1j)])


In python, if you multiply a number by 1j the number will be treated as imaginary number. Now lets consider a general example, if you have $$(2 + 3i)XXI$$ as a term in your hamiltonian then you can make a sparse pauli operator in qiskit like this:

op = SparsePauliOp.from_list([("XXI", 2 + 1j*3)])


Hope this helps!

• What to do if the resulting string is $\iota Z \iota Z I$, where to add the complex number then? because we only have one coefficient for this. Commented May 20 at 1:50
• The string $iZiZI$ is a tensor product of three elements $iZ \otimes iZ \otimes I$. Now you can use the properties of tensor product $iZiZI = (i \times i)(ZZI) = (-1) \times (ZZI)$. So there is always be only one coefficient for a pauli string. Commented May 20 at 2:23