Stuck on Codercise I.7.1

In order to act as the same as a Hadamard gate, I need to produce 1/sqrt(2), so I think theta = np.pi / 2.
To the phi and omega, I has no idea, so I established equation: RZ(phi)* RX(np.pi / 2)* RZ(omega) = H with unknowns phi and omega, and the final result is phi=2 * np. pi omega=2 * np. pi, but it is still incorrect. How can I get the correct answer?

Hi @boyuzhang1218, welcome to the PennyLane forum!

You’re on the right path but you’ve got the wrong angle for phi and omega. Notice that if phi and omega are 2*pi that’s equivalent to zero so it would mean that you wouldn’t be performing any rotation. Maybe that factor of two shouldn’t be multiplying but instead doing something else… I hope this helps!

Thank you for your help!

No problem!

I hope you’re enjoying the Codebook :grinning:

I suspect there is a bug in the problem, using the definition,

Rz(\omega)Rx(\theta)Rz(\phi)=\begin{bmatrix} e^{-i\pi(\phi+\omega)/2}\cos(\theta/2)& -ie^{i\pi(\phi-\omega)/2}\sin(\theta/2)\\ -ie^{-i\pi(\phi-\omega)/2}\sin(\theta/2) & e^{i\pi(\phi+\omega)/2}\cos(\theta/2) \end{bmatrix}

There is no real value of x that can make e^{-i\pi x}=1 while e^{i\pi x} = -1 so I think the problem has no solution.

Did I missed something?

Welp I figured I did not understand the phrase “up to a global phase”, it is clear to me now.

Hey @LdBeth! Welcome to the forum :sunglasses:

I’m assuming you answered your question? If so, that’s great! We also really appreciate you trying out the codebook. We’re migrating it over to the pennylane website ( so that whoever uses it can better store their progress and have a smoother experience with the entire PennyLane ecosystem. Those changes are coming on May 13! Definitely recommend checking it out. You just need to create a PennyLane account :slight_smile:

1 Like