I am reading Quantum Computing for Computer Scientists. Given the circuit for Deutsch's algorithm:
Denoting $H|0\rangle$ as $|x\rangle$, the book says that
$|\phi_2\rangle = (-1)^{f(x)}|x\rangle\left\lbrack \frac{|0\rangle - |1\rangle}{\sqrt{2}} \right\rbrack$
and then goes on to explain that because $|x\rangle$ is the superposed state $H|0\rangle$, this is the same as
$|\phi_2\rangle = \left\lbrack\frac{(-1)^{f(0)}|0\rangle + (-1)^{f(1)}|1\rangle}{\sqrt{2}}\right\rbrack\left\lbrack \frac{|0\rangle - |1\rangle}{\sqrt{2}} \right\rbrack$
How do they perform this step given that they need to evaluate $f(x)$ but $|x\rangle$ is superposed? I know I could multiply everything out, apply $U_f$ to the basic states, and then rearrange to get the desired form, but is there a simpler way to see that second equation from the first one? I can get the following:
$|\phi_2\rangle = \left\lbrack\frac{(-1)^{f(x)}|0\rangle + (-1)^{f(x)}|1\rangle}{\sqrt{2}}\right\rbrack\left\lbrack \frac{|0\rangle - |1\rangle}{\sqrt{2}} \right\rbrack$
but then I am lost. Does it always amount to going to basic states and then returning to a more compact form or can I do something smarter?
