Distance formula
Distance formula is used to compute the distance between two definite points.
Distance formula for a line segment parallel to an axis:
Line segment parallel to \(x\)-axis: Let the points be \(A\) and \(B\), and let the coordinates be (\(x_1\), \(y\)) and (\(x_2\), \(y\)) respectively.
In both cases, \(y\) is common because both points lie on the same axis or are parallel to the same axis.
In this case, the points lie on the line is either \(x\)-axis or parallel to \(x\)-axis.
In such a case, the distance formula will be:
\(\text{Distance}\) \(=\) \(|x_2 - x_1|\)
Line segment parallel to \(y\)-axis: Let the points be \(A\) and \(B\), and let the coordinates be (\(x\), \(y_1\)) and (\(x\), \(y_2\)) respectively.
In both sets of coordinates, \(x\) is common because both points lie on the same axis or are parallel to the same axis.
In this case, the points lie on the line are either on the \(y\)-axis or parallel to \(y\)-axis.
In such a case, the distance formula will be:
\(\text{Distance} = |y_2 - y_1|\)
Distance formula if the line segment is not parallel to an axis:
Not all line segments are parallel to an axis.
Consider any two points \(A(x_1,y_1)\) and \(D(x_2,y_2)\). Draw \(AF\) perpendicular to \(FD\).
Then \(F = (x_1,y_2)\)
Thus, \(AFD\) is a right-angle triangle at \(F\).
Since \(A\) and \(F\) have the same \(x\)-coordinate, then the length of the vertical side is \(AF = y_2 - y_1\).
Similarly, \(D\) and \(F\) have the same \(y\)-coordinate, then the length of the horizontal side is \(DF = x_2 - x_1\)
Applying Baudhāyana–Pythagoras theorem, we have:
\(AD^2 = AF^2 + FD^2\)
\(AD^2 = (y_2 - y_1)^2 + (x_2 - x_1)^2\)
\(AD = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\)
Therefore, the distance between any two points can be determined using the formula \(d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\).

Let us look at the following example.
Find the distance between the points given in the figure below.
The coordinates of point \(A\)(\(x_1\), \(y_1\)) is (\(6\), \(4\)).
The coordinates of point \(B\)(\(x_2\), \(y_2\)) is (\(1\), \(-2\)).
\(x_1 = 6\)
\(x_2 = 1\)
\(y_1 = 4\)
\(y_2 = -2\)
Distance between the points \(A\) and \(B\) can be obtained using the distance formula.
\(\text{Distance} = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\)
\(= \sqrt{(1 - 6)^2 + (-2 - 4)^2}\)
\(= \sqrt{(-5)^2 + (-6)^2}\)
\(= \sqrt{25 + 36}\)
\(= \sqrt{61}\)
Important!
The distance of a point \(P(x,y)\) from the origin can be determined using the formula:
\(d = \sqrt{x^2 + y^2}\)
Midpoint
Look at the following image.
The midpoint of a line segment is the point that lies exactly halfway between its two endpoints. If a point \(M\) divides a segment \(AB\) into two equal parts, then the distance from \(A\) to \(M\) is equal to the distance from \(M\) to \(B\). This equal-distance idea can be used to find the midpoint between two points.
Therefore, \(AM = MB\) and \(AB = 2AM\) or \(AB = 2MB\).
Example:
Verify whether \(M(1,3)\) is the midpoint of the points \(A(-2,3)\) and \(B(4,3)\).
Solution:
Let us verify using distance formula, \(d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\)
\(AM = \sqrt{(1 - (-2))^2 + (3 - 3)^2}\)
\(= \sqrt{(3)^2 + (0)^2}\)
\(= \sqrt{9 + 0}\)
\(= \sqrt{9}\)
\(= 3\)
\(MB = \sqrt{(4 - 1)^2 + (3 - 3)^2}\)
\(= \sqrt{3^2 + 0^2}\)
\(= \sqrt{9}\)
\(= 3\)
Since \(AM = MB\), then \(M\) is the midpoint of \(AB\). Because the point \(M\) divides the line segment \(AB\) into two equal halves.