We will show this for a two-dimensional plane.
We will define two points P1, with coordinates (x1,y1) and P2, with coordinates (x2,y2).
The midpoint will be in the exact middle of the segment formed by this two points.
Its coordinates will be the average between the respective coordinates of the two points of the segment.
Let M=(xm,ym) be the midpoint, the coordinates are calculated as:
[tex]\begin{gathered} x_m=\frac{x_1+x_2}{2} \\ y_m=\frac{y_1+y_2}{2} \end{gathered}[/tex]
The length of the segment is equal to the distance between the two points. It is an scalar value and can be calculated as the square root of the square of the difference between each of the coordinates. It can be deduced from the Pythagorean theorem.
Let D be the length of the segment, it can be calculated as:
[tex]D=\sqrt{\left(x_1-x_2\right)^2+\left(y_1-y_2\right)^2}[/tex]