So, I am trying to solve a least square problem. I have the matrix $$ A= \begin{bmatrix} \ 1&-1 \\ 1 & 1 \\ 1&2 \end{bmatrix}. $$
and the matrix
$$ b = \begin{bmatrix} 7 \\ 7 \\ 21 \end{bmatrix} $$
Now, I have found the least square line normally with the equation being $$y(t) = 4x + 9$$. However, I know am trying to find a straight line through the origin that best fits the data in a least square sense. So, my thinking is $y(0) = m \cdot 0 + b = 0$. So I know b, must equal to zero, I wanna say that $m = \frac{21}{2}$ since both the 7's would be on either side. I got y(t) by using $A^t Ax = A^Tb$. Thanks.
@Algebraic Pavel provides an elegant solution. A less rigorous solution follows.
The function which forces the solution through the origin has the form $y(x) = ax$ where $a$ is the slope. With these data the sum of the squares of the residuals is $$ r^2(a) = \Bigg\Vert \left[ \begin{array}{r} -1 \\ 1 \\ 2 \end{array} \right] \left[ \begin{array}{r} a \end{array} \right] - \left[ \begin{array}{r} 7 \\ 7 \\ 21 \end{array} \right] \Bigg\Vert^{2} $$
The problem reduces to finding the minimum of $r^2(a) = 6a^2 - 84 a + 539$, that is, solve $$ \frac{\partial}{\partial a} r^2 = 12 a - 84 = 0 $$
As shown earlier, the solution is that the slope $a = 7$.