# Equation for Distance of the Straight line from the Origin.

By reduction of the equation $ax + by + c = 0$ of a straight line to the normal form , we get $$\left(\frac{-a}{\sqrt{a^2 + b^2}}\right)x + \left(\frac{-b}{\sqrt{a^2 + b^2}}\right)y = \frac{c}{\sqrt{a^2 + b^2}}$$ And, $$p= \frac{∣c∣}{\sqrt{a^2 + b^2}}$$ And my textbook says that $p$ is the distance of the straight line from the origin. I don't know why we are getting it as a distance from origin?

I know $p= x\cos\theta + y\sin\theta$ ( where $p$ is distance of line from origin).

Also I want to know how can we relate both equations?

• Have you tried to check what's written about this on Wikipedia or in other posts on this site like this or this? Oct 8, 2016 at 10:09
• @THE, you have made edits to about 30 questions in a matter of minutes, flooding the front page and driving other, newer questions off it. Please don't do that! Please edit three or four questions a day, not 30 in half an hour. Jan 4, 2017 at 3:47
• @GerryMyerson, I knew that soon something like that will come to me, and I appologise for what I did. But II did not took them from previous pages, they were already on the front page (Someone else had edited them), I just revised small mistakes. Jan 4, 2017 at 3:51
• @THE, yes, so I see. I have also left a comment for the other editor who is, if I'm not mistaken, a repeat offender. Jan 4, 2017 at 3:52
• Okay, @Garry, you do not need to worry shot it now. Nothing such will happen again from my side Jan 4, 2017 at 4:23

There is a simple derivation of what you want to know. Without going into details, let me introduce the result:

The perpendicular distance of a line $(Ax+By+c=0)$from a point is equal to $|\frac{Ax'+By'+c}{\sqrt{A^2+B^2}}|$. Where $(x',y')$ are coordinates of the point.

Since you want distance of line from origin, the coordinates become $(0,0)$ and hence the perpendicular distance of a line from origin is $|\frac{Ax'+By'+c}{\sqrt{A^2+B^2}}|=|\frac{0+0+c}{\sqrt{A^2+B^2}}|=|\frac{c}{\sqrt{A^2+B^2}}|$.

• I got that after few weeks I posted that. But I still don't know why $\cos\theta$ and $\sin\theta$ is getting when divided by $\sqrt{a^2 + b^2}$ Jan 4, 2017 at 11:22
• Wait, Have you got the book, SL Loney ?? Jan 4, 2017 at 11:23
• Of coordinate geometry?? Jan 4, 2017 at 11:23
• No :( I only follow my Textbook Jan 4, 2017 at 11:24
• Okay, then I m gonna send you pictures from that book of the section we are discussing here, I m sure it will help you, But where can I send you them ?? Jan 4, 2017 at 11:25

Note that by Cauchy Schwarz, if $(x, y)$ satisfies $ax+by+c = 0$, then

$$c^2= (-c)^2 = (ax+by)^2 \le (a^2+b^2)(x^2+y^2).$$

(The last inequality can be checked directly). Thus every points $(x, y)$ on the line satisfies

$$\tag{1} \sqrt{x^2+y^2} \ge \frac{|c|}{\sqrt{a^2+ b^2}}.$$

On the other hand, the point

$$(x,y)= \left(\frac{-ac}{\sqrt{a^2+b^2}}, \frac{-bc}{\sqrt{a^2+b^2}}\right)$$

lies on the line and has distance

$$\frac{|c|}{\sqrt{a^2+b^2}}$$

from the origin. Thus we are done.

• I can't get any thing from your answer, can you explain in any simple way? Oct 8, 2016 at 10:25
• Which part do you not understand, @Ramanujan?
– user99914
Oct 8, 2016 at 10:53
• After $-c = ax+by =$ to last Oct 8, 2016 at 10:58
• Please see the edit @Ramanujan
– user99914
Oct 8, 2016 at 11:01
• @JohnMa I suppose you wanted to write $(ax+by)^2 \le (a^2+b^2)(x^2+y^2)$ rather than $(ax+by)^2 = (a^2+b^2)(x^2+y^2)$...? Oct 8, 2016 at 13:12

For this derivation, we won’t be needing any trigonometric equation nor you have to prior study trigonometry. For this derivation we just need the following things:

• Pythagoras Theorem
• Algebra
• Area of triangle $$\frac{1}{2} \times \text{height} \times \text{base}$$

Let us take the line equation $$Ax+By+C = 0$$.

So by putting first $$y = 0$$ solving for $$x$$ and then putting $$x = 0$$ and solving for $$y$$.

• By putting $$y = 0$$ and solve for $$x$$: \begin{align} Ax+By+C &= 0, \quad y = 0 \\ Ax+B(0)+C &= 0 \\ Ax+C &= 0 \\ Ax &= -C \\ x &= -\frac C A \end{align}

• By putting $$x = 0$$ and solve for $$y$$: \begin{align} Ax+By+C &= 0, \quad x = 0 \\ A(0)+By+C &= 0 \\ By+C &= 0 \\ By &= -C \\ y &= -\frac C B \end{align}

By doing the above we get the base distance and perpendicular distance of the triangle formed by the line equation $$Ax+By+C = 0$$.

Since the triangle formed is a right-angled triangle, we can get its area and hypotenuse with no problem.

• So first, deriving the hypotenuse: $$\text{Rise} = \left|\frac{-C}{A}\right|,\ \text{Run} = \left|\frac{-C}{B}\right|$$ Pythagoras Thm.: Hyp.$${}^2$$ = Rise$${}^2$$ + Run$${}^2$$: \begin{align} \text{Hyp.}^2 &= \left|\frac{-C}{A}\right|^2 + \left|\frac{-C}{B}\right|^2 \\ &= \frac{C^2}{A^2} + \frac{C^2}{B^2} \\ &= \frac{C^2(A^2+B^2)}{(AB)^2}; \\ \text{Hyp.} &= \sqrt\frac{C^2(A^2+B^2)}{(AB)^2} \\ &= \frac{|C|\sqrt{A^2+B^2}}{|AB|}. \end{align}

• Deriving the Area: \begin{align} \text{Base} &= \left|\frac{-C}{A}\right|, \\ \text{Height} &= \left|\frac{-C}{B}\right|; \\ \text{Area} &= \frac 1 2 \times \left|\frac{-C}{A}\right| \times \left|\frac{-C}{B}\right| \\ &= \frac{C^2}{2|AB|}. \end{align}

We can also write the area as half the hypotenuse times the height that is perpendicular to the hypotenuse (Note: the height perpendicular to the hypotenuse is the shortest distance to the origin, so let us call this height $$w$$). \begin{align} \text{Area} &= \frac 1 2 \times \text{hypotenuse} \times \text{perp. height} \\ \frac{C^2}{2|AB|} &= \frac 1 2 \times \frac{|C| \sqrt{A^2+B^2}}{|AB|} \times w \\ \frac{C^2}{|AB|} &= \frac{|C|\sqrt{A^2+B^2}}{|AB|} \times w \\ |C| &= \sqrt{A^2+B^2} \times w \\ \frac{|C|}{\sqrt{A^2+B^2}} &= w. \end{align}

By simple identification, the two equations are identical when

$$-\frac a{\sqrt{a^2+b^2}}=\cos\theta,\\ -\frac b{\sqrt{a^2+b^2}}=\sin\theta,\\ \frac c{\sqrt{a^2+b^2}}=p.$$

This is coherent as you verify $\cos^2\theta+\sin^2\theta=1$. If $c$ is negative, change all signs.

As one can verify by substitution,

$$x=p\cos\theta-t\sin\theta,\\y=p\sin\theta+t\cos\theta.$$ describes any point along the line, by varying $t$.

The distance from the origin to this point is given by, after simplification,

$$d=\sqrt{x^2+y^2}=\sqrt{p^2+t^2}.$$

The minimum value is indeed $p$.

• How we get$x=p\cos\theta-t\sin\theta,\\y=p\sin\theta+t\cos\theta.$ Oct 8, 2016 at 10:19