# Stuck with I.8.2

**URL:** https://discuss.pennylane.ai/t/stuck-with-i-8-2/3693
**Category:** Codebook
**Created:** [November 17, 2023, 4:46pm UTC](https://discuss.pennylane.ai/t/stuck-with-i-8-2/3693 "2023-11-17T16:46:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Cap\_Cap](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/cap_cap/32/2086_2.png) [@Cap\_Cap](https://discuss.pennylane.ai/u/Cap_Cap)
#### Post date: [November 17, 2023, 4:46pm UTC](https://discuss.pennylane.ai/t/stuck-with-i-8-2/3693/1 "2023-11-17T16:46:17Z")

</div>

Hi, I’m back again a bit deeper in the codebook.  
I needed some time to get through 1.7 and get a feeling for the RX/RZ/RY gates but I got through them just now I’m feeling a bit stuck with 1.8.2

It looks like you need a H gate and transform the result with an RX gate for the final configuration, so my answer was qml.H(0) and qml.RX(np.pi/6). Where do I take the wrong turn?

For now, I kinda go with my gut feeling and a bit of research because I didn’t work with cos/sin for some time, so I’m not used to throwing them around anymore. Any suggestions how dissect such a problem more throughly to get consisten answers ?

Small questions to 1.8.1 I found the solution but I’m a bit unsure how the 5/4 gets resolved because after my idea it should still be 1/4 at the end of the transformation

---

<div class="post-metadata">

### Author: ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)
#### Post date: [November 17, 2023, 11:03pm UTC](https://discuss.pennylane.ai/t/stuck-with-i-8-2/3693/2 "2023-11-17T23:03:18Z")

</div>

Hey @Cap_Cap !

Regarding 1.8.2, the answer is much simpler! All you need is an `RX` gate with an angle of rotation of \pi / 3 🙂

R\_x (\pi / 3) = \begin{pmatrix} \cos(\pi / 6) & -i\sin(\pi / 6) \\ -i\sin(\pi / 6) & \cos(\pi / 6) \end{pmatrix}

\begin{align\*} R\_x (\pi / 3) |0 \rangle &= \begin{pmatrix} \cos(\pi / 6) & -i\sin(\pi / 6) \\ -i\sin(\pi / 6) & \cos(\pi / 6) \end{pmatrix} \begin{pmatrix} 1 \\ 0\end{pmatrix} \\ &= \begin{pmatrix} \cos(\pi / 6) \\ -i\sin(\pi / 6) \end{pmatrix} \\ &= \begin{pmatrix} \sqrt{3} / 2 \\ -i/2 \end{pmatrix} \\ &= \frac{\sqrt{3}}{2} | 0 \rangle - \frac{i}{2} | 1 \rangle \end{align\*}

For I.8.1, the hint says to look at just the amplitudes first (i.e., ignore the e^{i5\pi/4}). The amplitudes are 1/\sqrt{2} — an equal superposition! The Hadamard gate is the one to use here 🙂. Then, to get e^{i5\pi/4} just on | 1 \rangle you can use an `RZ` gate with an angle of rotation of 5\pi/4. That’ll get you this:

\frac{1}{\sqrt{2}} \left( e^{-i5\pi/8} | 0 \rangle + e^{i5\pi/8} | 1 \rangle\right)

The problem says you only need to get the correct answer to a global phase. The above ends up being exactly that (up to a global phase of e^{-i5\pi/8}):

\frac{1}{\sqrt{2}} e^{-i5\pi/8} \left(| 0 \rangle + e^{i5\pi/4} | 1 \rangle\right)

Hope this helps!
