<s>[INST] Proving the perpendicular distance from a point to a line using vectors (the harder algebraic way) I want to prove that the distance from a point $P\left(x_{0},y_{0}\right)$ to line $l$: $ax+by+c=0$ is given by $\frac{\left|ax_{0}+by_{0}+c\right|}{\sqrt{a^{2}+b^{2}}}$.
So I am stuck on $$\left|\text{perp}_lAP\right|=\left|\binom{x_0}{y_0+\frac{c}{b}}-\frac{-bx_0+ay_0+\frac{ac}{b}}{\sqrt{a^2+b^2}}\:\binom{-b}{a}\right|$$
Where $l$ is the vector parallel to the line,and $AP$ is a vector. See diagram/graph for context.
So I took the projection of $AP$ onto $l$, then found the perpendicular by proj+perp=l
And this should work right? I see no error, but just a very messy simplification.
I know the better way is to do instead, the projection from $PA$ onto $l$, which we know is perpendicular anyway.
But me doing |perp| = |$l$-proj| SHOULD also work right?How do I simplify it (especially turning $bx_0$ into $ax_0$)
Diagram:
https://imgur.com/a/JXfSxko
 [/INST] The points where $ax+by+c=0$ can be parametrized as
$$
\left(\frac{-bt-ac}{a^2+b^2},\frac{at-bc}{a^2+b^2}\right)\tag1
$$
The square of the distance from $(x_0,y_0)$ is then
$$
\begin{align}
&\left(x_0+\frac{bt+ac}{a^2+b^2}\right)^2+\left(y_0+\frac{-at+bc}{a^2+b^2}\right)^2\\[6pt]
&=\left(x_0^2+y_0^2\right)+\frac{2x_0(bt+ac)+2y_0(-at+bc)}{a^2+b^2}+\overbrace{\frac{(bt+ac)^2+(-at+bc)^2}{\left(a^2+b^2\right)^2}}^{\large\frac{t^2+c^2}{a^2+b^2}}\tag{2a}\\
&=\frac{\left(a^2+b^2\right)\left(x_0^2+y_0^2\right)+2c(ax_0+by_0)+2(bx_0-ay_0)t+c^2+t^2}{a^2+b^2}\tag{2b}\\[3pt]
&=\frac{\left(a^2+b^2\right)\left(x_0^2+y_0^2\right)+2c(ax_0+by_0)+c^2-(bx_0-ay_0)^2+(t+bx_0-ay_0)^2}{a^2+b^2}\tag{2c}\\[3pt]
&=\frac{a^2x_0^2+b^2y_0^2+2abx_0y_0+2c(ax_0+by_0)+c^2+(t+bx_0-ay_0)^2}{a^2+b^2}\tag{2d}\\[3pt]
&=\frac{(ax_0+by_0+c)^2+(t+bx_0-ay_0)^2}{a^2+b^2}\tag{2e}
\end{align}
$$
Explanation:
$\text{(2a)}$: expand the squares collecting the first, middle, and last parts
$\text{(2b)}$: put over a common denominator and collect powers of $t$
$\text{(2c)}$: complete the square in $t$
$\text{(2d)}$: expand $\left(a^2+b^2\right)\left(x_0^2+y_0^2\right)-(bx_0-ay_0)^2$
$\text{(2e)}$: collect $(ax_0+by_0+c)^2$
$\text{(2e)}$ is minimized when $(t+bx_0-ay_0)^2=0$ which gives the minimum distance to be
$$
\frac{|ax_0+by_0+c|}{\sqrt{a^2+b^2}}\tag3
$$
</s>