Let \begin{align}f(t) &= \|A(x+ty)-b\|^2_2 = (A(x+ty)-b)^T(A(x+ty)-b))\\ &= x^TA^TAx + 2tx^TA^TAy+t^2y^TA^TAy-2b^TA(x+ty)\end{align}
Then, letting $f'(t) = 0$, we have $$ t = \frac{(b^TAy)-x^TA^TAy}{y^TA^TAy}$$
Ok I am confused by the whole thing. The answer I am getting is completely different. I also used the fact $Ax = b$ and $x^TA^T = b^T$ and cancelled each other. Can someone please help me to come up with this answer? Thanks.