# Finding the angle $\theta$ of the line through the origin that matches the given points the best

How to find angle $\theta$, that the line passing through the origin that is the best fit for the points given below in the mean square sense makes with the horizontal axis. $$x_1=[1\;\; 2]^T$$ $$x_2=[2\;\; 1]^T$$ $$x_3=[2\;\; 3]^T$$

-
The tangent of the angle is equal to the ratio of the elements –  Elements in Space Jan 6 '13 at 9:16
Do you mean best fit in the least squares sense? –  mathemagician Jan 6 '13 at 9:45
yes, mean square sense symbalize best fit –  Iya Jan 6 '13 at 11:17

$Y=[2\;\; 1\;\; 3]^T$ $X=[1\;\; 2\;\; 2]^T$
You want to find a $\beta$ such that $X\beta=\hat{Y}$ minimizes the squared distance from $Y$. The scalar that you are looking for is $\beta=(X'X)^{-1}X'Y =\frac{1}{9}\cdot 10 = \frac{10}{9}$. If you are wondering about the formula, it comes from first and second order conditions that yield a minimum for the squared residuals. Then $\theta=arctan(\beta)$.
Hint: If the line passing through the points makes an angle of $\theta$ with the horizontal $x-$axis, passing through the origin, the equation of the line is $y=\tan(\theta)x$.