The distance formula for two points P1: (x1,y1) and P2: (x2,y2) is:
d = √( (x2-x1)2 + (y2-y1)2 )
On the number line a and b are the x-coordinates and the y-coordinates are both 0. The points are (a,0) and (b,0).
In the Distance Formula, this makes the distance:
d = √( (x2-x1)2 )
Now, since the square root may have either both positive and negative roots, we write the value as:
d = ± (x2-x1)
This is either (x2-x1) or (-(x2 - x1))
When considering distance (a measurement without a sign attached), we write the positive distance: |x2 - x1|.