0
$\begingroup$

first of all, I would probably report this as a bug if I was confident enough in my QC abilities. As it stands, I've just started out, so I'm phrasing it as a question.

From what I can tell, adding two PauliOps in this specific case does not result in the expected operator matrix:

import qiskit as qk
from qiskit.opflow.primitive_ops import PauliOp

(PauliOp(qk.quantum_info.Pauli("X")) + PauliOp(qk.quantum_info.Pauli("iY"))).to_matrix()

results in

array([[0.+0.j, 1.-1.j],
       [1.+1.j, 0.+0.j]])

whereas the result that I would expect is the one i get when I run the following code:

PauliOp(qk.quantum_info.Pauli("X")).to_matrix() + PauliOp(qk.quantum_info.Pauli("iY")).to_matrix()

Result:

array([[0.+0.j, 2.+0.j],
       [0.+0.j, 0.+0.j]])

What further confuses me is that the deprecated version of PauliOp actually results in the expected operator. Running this code:

import qiskit as qk
from qiskit.aqua.operators.primitive_ops import PauliOp

(PauliOp(qk.quantum_info.Pauli("X")) + PauliOp(qk.quantum_info.Pauli("iY"))).to_matrix()

gives a deprecation warning and the [[0,2],[0,0]]-array that I want.

Has the behaviour of the addition changed or is this a bug? In any case, how can I construct the operator that I want (in a non-deprecated way)?

I'm running qiskit version 0.29.0

Thanks in advance!

$\endgroup$

1 Answer 1

0
$\begingroup$

You can do this instead:

(PauliOp(qk.quantum_info.Pauli("X")) + 1j*PauliOp(qk.quantum_info.Pauli("Y"))).to_matrix()

which gives what you expect:

array([[0.+0.j, 2.+0.j],
       [0.+0.j, 0.+0.j]])
$\endgroup$

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.