# What is an example of how a Hamiltonian can be decomposed in terms of Pauli matrices?

I need to see an example of how Hamiltonian, i.e. any Hermitian matrix, can be decomposed into a linear combination of Pauli matrices.

I would prefer an option to do this in larger than 2 dimensions, if that is possible.

• Hi and welcome to Quantum computing SE. There is probably missing figure or equation because there is written What I have tried so far is this: but then there is nothing. – Martin Vesely May 7 '20 at 21:57
• Please clarify what exactly you are asking for. Right now, H = qutip.sigmax() seems like it would be a possible answer to your question: it's an Hermitian matrix decomposed into a linear combination of Pauli matrices, written in python. I'm guessing you are asking for something more specific? – glS May 8 '20 at 12:30
• The user accepted my answer. What they want is clear. Please re-open or choose a close reason different from "needs details for clarity". – user1271772 Feb 27 at 21:23

I call this the "Paulinomial decomposition" as you are writing the matrix $$H$$ as a polynomial of Pauli matrices:

$$H=a_{XX}X_1X_2 + a_{XY}X_1Y_2 +a_{XZ}X_1Z_2 + a_{XI}X_1 + a_{YY}Y_1Y_2 + \cdots$$ (for the 2-qubit case).

To get the coefficients, you can use this formula:

$$a_{AB}=\frac{1}{4}\textrm{tr}\left((A_1\otimes B_2)H\right)$$

For example, here is a 2-qubit gate (the square root of the SWAP gate) written as a polynomial of Pauli matrices: You can even do this for a $$2^n \times 2^n$$ Hamiltonian, for example an 8x8 Hamiltonian can be done like this:

$$a_{ABC}=\frac{1}{8}\textrm{tr}((A_1\otimes B_2\otimes C_3))H)$$

I have a code that can also do it for arbitrary matrices (not only $$2^n \times 2^n$$, but I haven't touched it for 2 years and might need to test it again). If it would be helpful, I can try to dig it up and polish it for you to use.

• To correct my notation -- every term appears to power 0 or 1, so it is really a linear decomposition. You can of course call this a polynomial, but it is really a linear decomposition. – Norbert Schuch May 8 '20 at 21:40
• @NorbertSchuch Again, it is not linear either. The multi-variable function $xy+x+y-2$ is considered a quadratic, not a linear function, and it is not a monomial because it has multiple terms. For example this is a quadratic function: en.wikipedia.org/wiki/… even if $A$ and $B$ are 0 but $E\ne0$. When you have a product of two variables, you can't for example use linear programming (for optimization) because the problem is considered "non-linear". – user1271772 May 8 '20 at 21:48
• Multilinear? ... – Norbert Schuch May 8 '20 at 22:25
• That might be another way to describe it. In the definition of a "quadratic form" for example, it's okay for $a_{ij}=0$ whenever $i=j$. I suppose if we consider $X_1$ and $X_2$ to be different "variables" since they act on different qubits (one of them is the matrix $I \otimes X$ and the other one is $X \otimes I$), we could call this linear, but in the AQC community, and also in the Operations Research community, we definitely call XX terms quadratic and X terms linear. There is an entire field called "quadratization" which is about turning k-local Hamiltonians into "quadratics" exactly like – user1271772 May 8 '20 at 23:32
• the first equation in my answer. I did not come up with this term, it might have been Endre Boros, Aritanan Gruber, Yves Crama, and Martin Anthony who came up with the term, but it might have been around even earlier. In any case, minimizing $b_1b_2 + b_1 - b_2$ where $b_1,b_2\in \{0,1\}$ is most definitely called QUBO (quadratic unconstrained boolean optimization). That literature is too big for us not to accept these functions as quadratic! P.S. when I talked about "quadratic forms" I meant to include this: en.wikipedia.org/wiki/Quadratic_form#Definitions. – user1271772 May 8 '20 at 23:35