Find Distance between a Point $(-4,2)$ and a Line having equation $3x−y−10=0$
My attempt:
I used a graphing calculator to graph the equation $3x−y−10=0$ and the point $(-4,2)$. I found the x-intercept and y-intercept of the equation as $\dfrac{10}{3}$, and $-10$ respectively.
I used the Midpoint Formula to get the midpoint of $AB$;
$$ \left(x_{m}, y_{m}\right)=\left(\frac{x_{1}+x_{2}}{2}, \frac{y_{1}+y_{2}}{2}\right) $$ $$= \left(\dfrac{\dfrac{10}{3} + 0}{2}, \; \dfrac{0 + -10}{2}\right) = \left(\dfrac{5}{3}, \; -5\right)$$
Now, Can I use the distance formula $d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$ to find the distance between the point and the midpoint of the line? By distance formula, $d=9$. Is my approach correct?
But the solution given in my textbook uses some other distance formula, $d=\left| \dfrac{ax_{1}+by_{1}+c}{\sqrt{a^{2}+b^{2}}}\right|$. Can you please explain to me how we got this formula and how to solve this problem with this formula?


By the distance formula, I found the length of $AB$ as $\dfrac{10}{3} \sqrt{10}$ units. Now, suppose that $PQ$ is the perpendicular drawn from $P$ to $\overleftrightarrow{l}$. Now, the area of a triangle is given as:
$$Area =\dfrac{1}{2}× Base × Height$$
So, using this result, we can write: \begin{align*} &\hphantom{{}\implies{}} \text{area}\,\triangle PAB = \frac{1}{2} \times AB \times PQ \\ &\implies \text{area}\,\triangle PAB = \frac{1}{2} \times \frac{10\sqrt{10}}{3} \times PQ \\ &\implies PQ = \frac{3}{5\sqrt{10}} \text{area}\,\triangle PAB \end{align*}
Consider the above △PAB again; Now, the area of a triangle having vertices at $(x_1,y_1),(x_2,y_2)$ and $(x_3,y_3)$ is given as $$ Area = \frac{1}{2}\left|x_{1}\left(y_{2}-y_{3}\right)+x_{2}\left(y_{3}-y_{1}\right)+x_{3}\left(y_{1}-y_{2}\right)\right| $$
So, using the above result, we can say that Area △PAB= 40 sq. units. Now, substituting the value of ‘Area △PAB’, we’ll get $PQ=\dfrac{24}{\sqrt{10}}$.
Therefore, the distance between the point $P$ and the line $\overleftrightarrow{l}$ is $\dfrac{24}{\sqrt{10}}$ units.