# Minimization and Least Squares

Prove that the distance from the point $(x_0,y_0)^T$ to the line ax + by = 0 is $\frac{|ax_0 + by_0|}{\sqrt{a^2 +b^2}}$, also what is the minimum distance to the line ax + by + c = 0?

My attempt:

$\left( \left( \begin{matrix} x_0 \\ y_0 \end{matrix} \right) - c \left( \begin{matrix} a/b \\ -a/b \end{matrix} \right) \right) . \left( \begin{matrix} a/b \\ -a/b \end{matrix} \right) = 0$ so $\frac{\left( \begin{matrix} x_0 \\ y_0 \end{matrix} \right) . \left( \begin{matrix} a/b \\ -a/b \end{matrix} \right)}{\left( \begin{matrix} a/b \\ -a/b \end{matrix} \right). \left( \begin{matrix} a/b \\ -a/b \end{matrix} \right)} . \left( \begin{matrix} a/b \\ -a/b \end{matrix} \right) = \left( \begin{matrix} \frac{a}{b}(x_0 - y_0) \\ \frac{2a^2}{b} \end{matrix} \right)$ , but how can I complete this to match the the answer given in the question. Also, I do not know how to do part II of this problem.

• What is this $(a/b,-a/b)$ you are using? Is that supposed to be a point on the line? Is it actually on the line? Oct 14, 2012 at 4:21

Given line $ax+by=0$ and point $(x_0,y_0)$, we want to find the distance from the point to the line. This distance is a perpendicular from the point $(x_0,y_0)$ to given line.

Rewriting line equation, $ax+by=0$, to $y=-\frac{a}{b}x$ we can see that the slope, $m$, is $m=-\frac{a}{b}$. We know that the slope of a normal, $m_n$ to given slope, $m$, has the following property:

$$m\cdot m_n=-1$$

Thus, in our case, $m_n=\frac{b}{a}$; and a point $(x_0,y_0)$. We can construct our normal line to the given one.

$$y-y_0=m_n(x-x_0)$$ $$y=\frac{b}{a}x-\frac{b}{a}x_0+y_0$$

We are ready to find the intersection point of two these lines:

$$\begin{cases}y=-\frac{a}{b}x \\ y=\frac{b}{a}x-\frac{b}{a}x_0+y_0\end{cases}$$

$$x(\frac{a}{b}+\frac{b}{a})=\frac{b}{a}x_0-y_0$$

$$x=\frac{\frac{b}{a}x_0-y_0}{\frac{a^2+b^2}{ab}}=\frac{bx_0-ay_0}{\frac{a^2+b^2}{b}}$$

And,

$$y=-\frac{a}{b}x=-\frac{a}{b}\frac{bx_0-ay_0}{\frac{a^2+b^2}{b}}=-\frac{a(bx_0-ay_0)}{a^2+b^2}$$

Point of intersection is:

$$P(\frac{bx_0-ay_0}{\frac{a^2+b^2}{b}},-\frac{a(bx_0-ay_0)}{a^2+b^2})$$

Now we compute the distance from $(x_0,y_0)$ to $P$.

$$d^2=(\frac{a^2+b^2}{a^2+b^2}x_0-\frac{b^2x_0-aby_0}{{a^2+b^2}})^2+(\frac{a^2+b^2}{a^2+b^2}y_0+\frac{a(bx_0-ay_0)}{a^2+b^2})$$

After calculations, we left with:

$$d^2=\frac{(ax_0+by_0)^2}{(a^2+b^2)}$$

Or,

$$d=\frac{|ax_0+by_0|}{\sqrt{a^2+b^2}}$$

• Wow, beautiful ! Thank you very much Salech!!!! Oct 14, 2012 at 23:51
• Sorry to bother you again with this question Salech, but how did you get "We know that the slope of a normal, $m_n$ to given slope, m, has the following property: m⋅$m_n$=−1. Thus, in our case, $m_n=b/a$; and a point $(x_0,y_0)$. Normal line". I've never seen this before, what is called? Oct 16, 2012 at 3:33
• @diimension: "the slope of a normal" = "the slope of a perpendicular". I found perpendicular to $ax+by=0$. How I did that? First, by finding $m$ - slope, then by applying $mm_n=-1$ I found $m_n$, and constructed line equation(normal to given line) Oct 18, 2012 at 10:03
• Thank you very much!! Toda Raba! Oct 19, 2012 at 16:58
• @diimension: bevakasha -- You are welcome! :) Oct 19, 2012 at 19:11

1) Find the directional vector of the line $v$.

2) Find the projection $P_{v}^{b}$ of $b=(x_0,y_0)$ on $v$ which is a scalar value.

3) Multiply the unit vector of $v$ by $P_{v}^{b}$ and name it $w$.

4) Find the distance between $w$ and $v$ which is the distance between the point and the line.

• I haven't learned projections yet. It is in a couple of more sections. Oct 14, 2012 at 4:27

The line $ax+by=0$ is the set of all points $(bt,-at)$, $-\infty\lt t\lt\infty$. The square of the distance from $(x_0,y_0)$ to such a point is $$f(t)=(x_0-bt)^2+(y_0+at)^2$$ You should be able to find, by the usual calculas techniques, the value of $t$ that minimizes $f$, and then the corresponding minimal value of $f$, and then what you want is the square root of that.

• Thank you very much Gerry. So I will take the partial derivative which will provide me the minimization? Oct 14, 2012 at 4:29
• Partial? I only see one variable. Oct 14, 2012 at 4:50