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?