3
$\begingroup$

I'm currently going through Introduction to Classical and Quantum Computing, by Thomas Wong, and I'm struggling with exercise 2.33 (page 108):

Exercise 2.33. Answer the following:

(a) Calculate $HTHTH\left| 0 \right>$.

Given the two following transformations the Hadamard gate does:

$$\begin{align} H\left| 0 \right> &= \frac{1}{\sqrt{2}}(\left| 0 \right> + \left| 1 \right>)\\ H\left| 1 \right> &= \frac{1}{\sqrt{2}}(\left| 0 \right> - \left| 1 \right>) \end{align}$$

And the two following transformations the T gate does:

$$\begin{align} T\left| 0 \right> &= \left| 0 \right>\\ T\left| 1 \right> &= e^{i\pi/4}\left| 1 \right> \end{align}$$

I did the following:

$$\begin{align} HTHTH\left| 0 \right> &= HTHT\frac{1}{\sqrt{2}}(\left| 0 \right> + \left| 1 \right>) &\text{(apply H gate)}\\ &= HTH\frac{1}{\sqrt{2}}(\left| 0 \right> + e^{i\pi/4}\left| 1 \right>) &\text{(apply T gate)}\\ &= HT\frac{1}{\sqrt{2}}(\frac{1}{\sqrt{2}}(\left| 0 \right> + \left| 1 \right>) + e^{i\pi/4}\frac{1}{\sqrt{2}}(\left| 0 \right> - \left| 1 \right>)) &\text{(apply H gate)}\\ &= H\frac{1}{\sqrt{2}}(\frac{1}{\sqrt{2}}(\left| 0 \right> + e^{i\pi/4}\left| 1 \right>) + e^{i\pi/4}\frac{1}{\sqrt{2}}(\left| 0 \right> - e^{i\pi/4}\left| 1 \right>)) &\text{(apply T gate)}\\ &= \frac{1}{\sqrt{2}}(\frac{1}{\sqrt{2}}(\left| + \right> + e^{i\pi/4}\left| - \right>) + e^{i\pi/4}\frac{1}{\sqrt{2}}(\left| + \right> - e^{i\pi/4}\left| - \right>)) &\text{(apply H gate)}\\ &= \frac{1 + e^{i\pi/4}}{2}\left| + \right> + \frac{e^{i\pi/4} - i}{2}\left| - \right> &\text{(simplify)}\\ &= \frac{1 + e^{i\pi/4}}{2}\frac{1}{\sqrt{2}}(\left| 0 \right> + \left| 1 \right>) + \frac{e^{i\pi/4} - i}{2}\frac{1}{\sqrt{2}}(\left| 0 \right> - \left| 1 \right>) &\text{(change base)}\\ &= \frac{1 + e^{i\pi/4}}{2\sqrt{2}}\left| 0 \right> + \frac{1 + e^{i\pi/4}}{2\sqrt{2}}\left| 1 \right> + \frac{e^{i\pi/4} - i}{2\sqrt{2}}\left| 0 \right> - \frac{e^{i\pi/4} - i}{2\sqrt{2}}\left| 1 \right> &\text{(distribute)}\\ &= \frac{1 + 2e^{i\pi/4} - i}{2\sqrt{2}}\left| 0 \right> + \frac{1 + i}{2\sqrt{2}}\left| 1 \right>&\text{(simplify)}\\ &= \frac{1}{2\sqrt{2}}[(1 - i + 2e^{i\pi/4})\left| 0 \right> + (1 + i)\left| 1 \right>]&\text{(simplify)}\\ \end{align}$$

However, the answer given at the back of the book (page 360) is (notice the $e^{i\pi/4}$ as opposed to $2e^{i\pi/4}$): $$\begin{align} HTHTH\left| 0 \right> &= \frac{1}{2\sqrt{2}}[(1 - i + e^{i\pi/4})\left| 0 \right> + (1 + i)\left| 1 \right>]\\ \end{align}$$

What am I doing wrong?

$\endgroup$

2 Answers 2

4
$\begingroup$

...

$$\frac{1}{2\sqrt{2}}[(1 - i + 2e^{i\pi/4})\left| 0 \right> + (1 + i)\left| 1 \right>]$$ ...

However, the answer given at the back of the book (page 360) is (notice the $e^{i\pi/4}$ as opposed to $2e^{i\pi/4}$): $$\begin{align} HTHTH\left| 0 \right> &= \frac{1}{2\sqrt{2}}[(1 - i + e^{i\pi/4})\left| 0 \right> + (1 + i)\left| 1 \right>]\\ \end{align}$$

What am I doing wrong?

You seem to have done nothing wrong.

For notational convenience, I denote $T$ by $$ T\equiv \left(\begin{matrix}1 & 0 \\ 0 & t\end{matrix}\right)\;, $$ where $t=e^{i\pi/4}$.

Then, by matrix multiplication: $$ HTH = \frac{1}{2}\left(\begin{matrix}1+t & 1-t \\ 1-t & 1+t\end{matrix}\right) $$ and $$ THTH = \frac{1}{2}\left(\begin{matrix}1+t & 1-t \\ t-t^2 & t+t^2\end{matrix}\right) $$ and $$ HTHTH = \frac{1}{2\sqrt{2}}\left(\begin{matrix}1+2t-t^2 & 1+t^2 \\ 1+t^2 & 1-2t-t^2\end{matrix}\right) $$ and so $$ HTHTH |0\rangle = \frac{1}{2\sqrt{2}}\left( (1+2t-t^2)|0\rangle +(1+t^2)|1\rangle \right)\;, $$ where, setting $t=e^{i\pi/4}$ and using $t^2 = i$, we see that: $$ HTHTH |0\rangle = \frac{1}{2\sqrt{2}}\left( (1+2e^{i\pi/4}-i)|0\rangle +(1+i)|1\rangle \right)\;. $$

$\endgroup$
1
  • 1
    $\begingroup$ That makes sense, appreciate it! $\endgroup$ Mar 15 at 1:06
3
$\begingroup$

I quickly computed in Mathematica. You are correct. The book is incorrect.

enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ Good to know, will see if I can check my answers in Mathematica next time. Thanks for the tip! $\endgroup$ Mar 15 at 1:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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