randRange(-9, 9) randRange(-9, 9) randRange(-9, 9) randRange(-9, 9) (Y1 - Y2) / (X1 - X2) randRange( 0, 1 )

What is the slope of the line through the points (X1, Y1) and (X2, Y2)?

graphInit({ range: 10, scale: 20, tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); line( [X1 - 19, Y1 - 19 * M], [X2 + 19, Y2 + 19 * M], { stroke: "#888" } ); style({ fill: ORANGE, stroke: ORANGE }); circle( [X1, Y1], 3/20 ); style({ fill: BLUE, stroke: BLUE }); circle( [X2, Y2], 3/20 );
(Y1 - Y2) / (X1 - X2)
graphInit({ range: 10, scale: 20, tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); line( [X1 - 19, Y1 - 19 * M], [X2 + 19, Y2 + 19 * M], { stroke: "#888" } ); style({ fill: ORANGE, stroke: ORANGE }); circle( [X1, Y1], 3/20 ); style({ fill: BLUE, stroke: BLUE }); circle( [X2, Y2], 3/20 );

The equation for the slope is m = \dfrac{\color{BLUE}{y_2} - \color{ORANGE}{y_1}}{\color{BLUE}{x_2} - \color{ORANGE}{x_1}} for points (\color{ORANGE}{X1}, \color{ORANGE}{Y1}) and (\color{BLUE}{X2}, \color{BLUE}{Y2}).

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

Substituting in, we get m = \dfrac{\color{BLUE}{Y2} - \color{ORANGE}{negParens(Y1)}}{\color{BLUE}{X2} - \color{ORANGE}{negParens(X1)}} = \dfrac{\color{GREEN}{Y2 - Y1}}{\color{PINK}{X2 - X1}}

So, the slope m is fractionReduce( Y2 - Y1, X2 - X1 ).