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.
The first order condition for minimum ($t$ is a scalar):
\begin{align} \frac{\partial f(t)}{\partial t} &=\frac{\partial}{\partial t}(A(x+ty)-b)^{\top}(A(x+ty)-b) \\ &=2\left[\frac{\partial}{\partial t}(tAy+Ax-b)\right]^{\top}(A(x+ty)-b) \\ &=2(Ay)^{\top}(A(x+ty)-b) \\ &=2y^{\top}A^{\top}(Ax-b)+2ty^{\top}A^{\top}Ay=0. \end{align} Thus,
$$ t^*=-\frac{y^{\top}A^{\top}(Ax-b)}{y^{\top}A^{\top}Ay}=\frac{y^{\top}A^{\top}(b-Ax)}{y^{\top}A^{\top}Ay}. $$