randRangeExclude( -8, 10, [0, 1, 2] ) randRangeExclude( -10, 8, [-1, -2, -3, -4] ) randRangeExclude( -8, 8, [-1, 0] ) randRangeExclude( -8, 8, [-1, 0] ) abs( X2 - X1 ) abs( Y2 - Y1 ) X_DIST * X_DIST + Y_DIST * Y_DIST

Find the distance between the points `\blue{(X1, Y1)}` and `\green{(X2, Y2)}`.

graphInit({ range: 11, scale: 20, tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); label([ X1, Y1 ], "(" + X1 + ", " + Y1 + ")", "left", { color: BLUE } ); label([ X2, Y2 ], "(" + X2 + ", " + Y2 + ")", "right", { color: GREEN } ); circle([ X1, Y1 ], 3 / 20, { stroke: "none", fill: BLUE } ); circle([ X2, Y2 ], 3 / 20, { stroke: "none", fill: GREEN } );
HYP2

Change in `\red{x} = \green{X2} - \blue{negParens(X1)} \blue{X1} - \green{negParens(X2)} = \red{X_DIST}`

style({ color: RED, stroke: RED }, function() { line( [ X1, Y1 ], [ X2, Y1 ] ); label( [ ( X1 + X2 ) / 2, Y1 ], X_DIST, "above" ); });

Change in `\purple{y} = \green{Y2} - \blue{negParens(Y1)} \blue{Y1} - \green{negParens(Y2)} = \purple{Y_DIST}`

style({ color: PURPLE, stroke: PURPLE }, function() { line( [ X2, Y1 ], [ X2, Y2 ] ); label( [ X2, ( Y1 + Y2 ) / 2 ], Y_DIST, "left" ); });

The distance is the length of the hypotenuse of this right triangle.

style({ stroke: PINK }, function() { line( [ X1, Y1 ], [ X2, Y2 ] ); });

By the Pythagorean Theorem, that length is equal to:

`\sqrt{X_DIST^2 + Y_DIST^2}`

`= \sqrt{X_DIST * X_DIST + Y_DIST * Y_DIST}`

`= formattedSquareRootOf(HYP2)`

The distance is equal to the length of the side, which is X_DIST + Y_DIST