i found this tutorial about MaxCut and QAOA from pennylane and i do not understand how the equation and the circuit should be equal.

enter image description here

When i do the math i come to this conclusion:

enter image description here (result of CNOT - RZ - CNOT)

and this

enter image description here (result of e^{...} - equation)

When i change the equation to

enter image description here

So if I remove the identity matrix and the minus sign, I get the result of the circuit, but is that correct? And if so, why?

Thanks for your help!

  • 1
    $\begingroup$ The matrix only has to be equal up to a scalar factor for the operation to be correct. Unless you are going to be applying operation modifiers such as controlling the two qubit gate with a third qubit, in which case the scalar factor becomes relevant. $\endgroup$ Sep 14, 2021 at 17:00
  • $\begingroup$ Just adding to what @Craig said, divide the first matrix by $e^{-it/2}$ and you’ll see how they are equal up to a global phase $\endgroup$
    – epelaez
    Sep 14, 2021 at 17:40
  • $\begingroup$ please note that you can use mathjax to add equations to the post. See e.g. quantumcomputing.meta.stackexchange.com/questions/49 $\endgroup$
    – glS
    Sep 15, 2021 at 10:24
  • $\begingroup$ As others have already said, one of the major differences is a global phase. There's also a sign difference in your phases. This may be due to however you're defining the $R_z$ function - some sources take $R_z(\theta)=e^{i Z\theta/2}$, others take $R_z(\theta)=e^{-i Z\theta/2}$. That difference would be enough of fix it. $\endgroup$
    – DaftWullie
    Sep 15, 2021 at 10:28

1 Answer 1


Thanks for the help in the comments. The solution is a global phase and the sign difference.


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.