10
$\begingroup$

As part of a variational algorithm, I would like to construct a quantum circuit (ideally with pyQuil) that simulates a Hamiltonian of the form:

$H = 0.3 \cdot Z_3Z_4 + 0.12\cdot Z_1Z_3 + [...] + - 11.03 \cdot Z_3 - 10.92 \cdot Z_4 + \mathbf{0.12i \cdot Z_1 Y_5 X_4}$

When it comes to the last term, the problem is that pyQuil throws the following error:

TypeError: PauliTerm coefficient must be real

I started diving into the literature and it seems like a non-trivial problem. I came across this paper on universal quantum Hamiltonians where complex-to-real encodings as well as local encodings are discussed. However, it is still not clear to me how one would practically implement something like this. Can anyone give me some practical advice how to solve this problem?

$\endgroup$
  • 1
    $\begingroup$ Does it throw an error when you replace that i with $S_j^2*(X_j S_j X_j)^2$? $\endgroup$ – AHusain Jul 24 '18 at 17:57
  • 3
    $\begingroup$ Remember that a Hamiltonian should be Hermitian. That’s only true of the coefficients are real. $\endgroup$ – DaftWullie Jul 24 '18 at 18:15
  • 1
    $\begingroup$ I might be using a different definition for $S$ than you are. But the point is you can find some combination that results in $i Id_2$. $\endgroup$ – AHusain Jul 24 '18 at 18:31
  • 1
    $\begingroup$ Don't you have another term somewhere in those $\cdots$, that is the Hermitian conjugate? $H = i A B - i B^\dagger A^\dagger$ $\endgroup$ – AHusain Jul 24 '18 at 21:50
  • 1
    $\begingroup$ Or are all the terms of the form such that those cancel out? $\endgroup$ – AHusain Jul 24 '18 at 21:53
8
$\begingroup$

A conventional Hamiltonian is Hermitian. Hence, if it contains a non-Hermitian term, it must either also contain its Hermitian conjuagte as another term, or have 0 weight. In this particular case, since $Z\otimes X\otimes Y$ is Hermitian itself, the coefficient would have to be 0. So, if you're talking about conventional Hamiltonians, you've probably made a mistake in your calculation. Note that if the Hermitian conjugate of the term is not present, you cannot simply fix things by adding it in; it will give you a completely different result.

On the other hand, you might be wanting to implement a non-Hermitian Hamiltonian. These things do exist, often for the description of noise processes, but are not nearly so widespread. You need to explicitly include the "non-Hermitian" terminology, otherwise everyone will just think that what you're doing is wrong because it's not Hermitian, and a Hamiltonian should be Hermitian. I'm not overly familiar with what capabilities the various simulators provide, but I'd be surprised if they have non-Hermiticity built in.

However, you can simulate it, at the cost of non-deterministic implementation. There will be more sophisticated methods than this (see the links in this answer), but let me describe a particularly simply one: I'm going to assume there's only one non-Hermitian component, which is $i\times$(a tensor product of Paulis). I'll call this tensor product of Paulis $K$. The rest of the Hamiltonian is $H$. You want to create the evolution $$ e^{-iHt+Kt} $$ We start by Trotterising the evolution, $$ e^{-iHt+Kt}= \prod_{i=1}^Ne^{-iH\delta t+K\delta t} $$ where $N\delta t=t$. Now we work on simulating an individual term $e^{-iH\delta t+K\delta t}\approx e^{-iH\delta t}e^{K\delta t}$ (which becomes more accurate at large $N$). You already know how to deal with the Hermitian part so, focus on $$e^{K\delta t}=\cosh(\delta t)\mathbb{I}+\sinh(\delta t)K.$$

We introduce an ancilla qubit in the state $|\psi\rangle=\alpha|0\rangle+\beta|1\rangle$, and we use this as the control qubit in a controlled-$K$ gate. Then we measure the ancilla in the $\{|\psi\rangle,|\psi^\perp\rangle\}$ basis (where $\langle\psi|\psi^\perp\rangle=0$). If the outcome is $|\psi\rangle$, then on the target qubits we have implemented the operation $|\alpha|^2\mathbb{I}+|\beta|^2K$, up to normalisation. So, if you fix $(1-|\alpha|^2)/|\alpha|^2=\tanh(\delta t)$, you have perfectly implemented that operation. If the measurement fails, then it's up to you whether you want to try to recover (this may well not be possible) or start again.

$\endgroup$
3
$\begingroup$

This simple MATLAB/Octave code shows that $i0.12Z_1Y_2X_3$ is not Hermitian:

z=[1 0 ; 0 -1];
x=[0 1;  1  0];
y=[0 -1i; 1i 0];

z1 = kron(z,eye(4));
y2 = kron(kron(eye(2),y),eye(2));
x3 = kron(eye(4),x);

H=0.12*1i*z1*y2*x3

The output is H:

    0     0    0 0.12    0    0     0     0
    0     0 0.12    0    0    0     0     0
    0 -0.12    0    0    0    0     0     0
-0.12     0    0    0    0    0     0     0
    0     0    0    0    0    0     0 -0.12
    0     0    0    0    0    0 -0.12     0
    0     0    0    0    0 0.12     0     0
    0     0    0    0 0.12    0     0     0

Since it's a real matrix, Hermitian means symmetric, but this is not symmetric and therefore not Hermitian. The top-right triangle isn't equal to the bottom-right triangle.

However the top-right triangle is the negative of the bottom-right triangle, so it is anti-Hermitian.

So doing AHussain's suggestion of adding the conjugate transpose, results in 0. Just run this command:

H + H'

and you will get an 8x8 matrix of 0's.

So when you make your Hamiltonian Hermitian by adding the conjugate transpose, you get 0 for this term, and therefore you do not need to have any imaginary coefficients.

$\endgroup$
  • $\begingroup$ First of all, thanks for the thoughtful reply! However, I'm wondering about the implications of adding the conjugate transpose. The non-hermitian Hamiltonian that I'm facing is the mixer/driver Hamiltonian $H_M$ that I would like to use for QAOA (I generated it based on equations from a theoretical paper). If I know use $H_M + H_M'$ rather than $H_M$, doesn't that fundamentally change my results? $\endgroup$ – Mark Fingerhuth Jul 26 '18 at 15:49
  • 1
    $\begingroup$ That's why @DaftWullie's comment is mistaken without further assumptions. $\endgroup$ – AHusain Jul 26 '18 at 20:37
  • 1
    $\begingroup$ @MarkFingerhuth: Sorry for delay in the replay. I've been extremely busy during the days and have been getting home near midnight every day this month. If you can show me the paper where the equations come from, I can think about how your results get fundamentally different. I may change my answer to say "PyQuil does not support non-Hermitian matrices, but that doesn't mean a different program cannot". $\endgroup$ – user1271772 Jul 26 '18 at 21:55
  • 1
    $\begingroup$ @MarkFingerhuth: you say "I generated it based on equations from a theoretical paper" which equations from which theoretical paper? The paper linked in the question is 82 pages long, can you not just show me which equations you used to generate this "Hamiltonian" ? $\endgroup$ – user1271772 Aug 2 '18 at 19:36
  • 1
    $\begingroup$ @MarkFingerhuth, yes we can talk offline, however I won't get any points there for it. I only got 1 upvote for my effort here, so the incentive is low. $\endgroup$ – user1271772 Oct 22 '18 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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