Distance of a point from a straight line in $\Bbb R^2$: doubts when I use the implicit form of a straight line $r$ Referring to a recent question at this link Distance of a point from a straight line in $\Bbb R^2$: are there other simple proofs?, I have used the implicit form of $r$ to have the formula:

$$d(P_0,r)=\frac{|ax_0+by_0+c|}{\sqrt{a^2+b^2}} \tag 1$$ 
Let be a straight line $r: ax+by+c=0$ and $P_0(x_0,y_0)\notin r$ I want to find the distance $P_0$ from $r$, called $d(P_0,r)$. Let be a straight line $s$ perpendicular to $r$ through to $P_0$:
$$s: b(x-x_0)-a(y-y_0)$$
$$
\begin{cases}
   ax+by+c=0 &\\
   b(x-x_0)-a(y-y_0)=0 &
\end{cases} \iff \begin{cases}
   y=-\dfrac ab x -\dfrac cb&\\
   bx-bx_0-a\left(-\dfrac ab x-\dfrac cb-y_0\right)=0&
\end{cases} 
$$
With some steps we find
$$
H\equiv\left(\dfrac{b^2x_0-ac-ay_0b}{a^2+b^2};-\dfrac ab \left(\dfrac{b^2x_0-ac-ay_0b}{a^2+b^2}\right)-\dfrac cb\right)
$$
where $\{H\}=r\cap s$. Therefore $d(P_0,H)\equiv d(P_0,r)$ is given by
$$ d(P_0,r)=\sqrt{\left(x_0+\frac{ac+ay_0b-b^2x_0}{a^2+b^2}\right)^2+\left(y_0+\left(\frac ab \left(\frac{b^2x_0-ac-ay_0b}{a^2+b^2}+\frac cb\right)\right)\right)^2} \tag 2$$
If $P_0\equiv O\equiv (0,0)$ we find into the square root (with other steps)
$$\frac{\require{cancel}\cancel{b^2}c^2(a^2+b^2)}{\require{cancel}\cancel{b^2}(a^2+b^2)}=\frac{c^2}{a^2+b^2}$$
Hence
$$d(O,r)=\frac{|c|}{\sqrt{a^2+b^2}} , \quad (\text{correct!})$$
But with the $(2)$ there are many long algebraic steps which should give the $(2)$. Is there any condition that I should use to delete some terms?
 A: You’re making a tacit assumption that $b\ne0$. Without that, many of the expressions in your derivation are undefined. Even if you make this assumption explicit, the proof is incomplete without also considering this case. If your students have learned Cramer’s rule for solving systems of linear equations, I recommend using that because it’s completely general and doesn’t involve a case analysis: it only requires that at least one of $a$ or $b$ is nonzero, which you also need for the original implicit equation to represent a line in the first place.  
The system of linear equations to be solved is, after rearranging $$ax+by=-c \\ bx-ay = bx_0-ay_0.$$ Using Cramer’s rule, we therefore have $$x_h = {\begin{vmatrix}-c&b\\bx_0-ay_0&-a\end{vmatrix} \over \begin{vmatrix}a&b\\b&-a\end{vmatrix}} = {b^2x_0-aby_0-ac\over a^2+b^2} \\
y_h = {\begin{vmatrix}a&-c\\b&bx_0-ay_0\end{vmatrix}\over\begin{vmatrix}a&b\\b&-a\end{vmatrix}} = {a^2y_0-abx_0-bc\over a^2+b^2}.$$ 
That aside, if following your derivation I would first simplify the expression for $y_H$ to the one above before computing the distance between the points. The necessary algebraic manipulations for the distance to a general point $P$ then don’t seem very daunting: $$x_0-x_H = {(a^2x_0+b^2x_0)-(b^2x_0-aby_0-ac)\over a^2+b^2} = {a(ax_0+by_0+c)\over a^2+b^2}$$ and similarly $$y_0-y_H = {b(ax_0+by_0+c)\over a^2+b^2}.$$ Squaring and adding produces $${(a^2+b^2)(ax_0+by_0+c)^2\over(a^2+b^2)^2}$$ and the rest is obvious.
A: Just curious, why didn’t You proceed this way:
$$
\begin{aligned}
b(x-x_{0})-a(y-y_{0})=0\rightarrow&\ (x-x_{0})=am\\
&\ (y-y_{0})=bm
\end{aligned}
$$
Where the distance is $d(P_{0},r)=\sqrt{(x-x_{0})^{2}-(y-y_{0})^{2}}\ \ =\sqrt{a^{2}+b^{2}}\ \ |m|$
$$
\begin{aligned}
ax_{0}+by_{0}+c&=a(x_{0}-x)+b(y_{0}-y)+ax+by+c\\
&= a(x_{0}-x)+b(y_{0}-y)\\
&=-a^{2}m-b^{2}m
\end{aligned}
$$
and therefore, $\frac{\left|ax_{0}+by_{0}+c\right|}{\sqrt{\ (a^{2}+b^{2})}}\ \ =d(P_{0}\ ,r)$
