2
$\begingroup$

I need to see an example of how Hamiltonian, i.e. any Hermitian matrix, can be decomposed into a linear combination of Pauli matrices. Please show me how this is written in Python.

What I have tried so far is this:

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

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Martin Vesely May 7 at 21:57
  • 3
    $\begingroup$ 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? $\endgroup$ – glS May 8 at 12:30
5
$\begingroup$

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_{ij}=\frac{1}{4}\textrm{tr}\left((\sigma_i\otimes \sigma_{j})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_{ijk}=\frac{1}{8}\textrm{tr}((\sigma_i\otimes \sigma_{j}\otimes \sigma_{k}))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.

| improve this answer | |
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Norbert Schuch May 8 at 21:40
  • $\begingroup$ @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". $\endgroup$ – user1271772 May 8 at 21:48
  • 1
    $\begingroup$ Multilinear? ... $\endgroup$ – Norbert Schuch May 8 at 22:25
  • $\begingroup$ 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 $\endgroup$ – user1271772 May 8 at 23:32
  • $\begingroup$ 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. $\endgroup$ – user1271772 May 8 at 23:35

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