randRange(-9, 9) randRange(-9, 9) randRange(-9, 9) randRange(-9, 9) (Y1 - Y2) / (X1 - X2) Y1 - M * X1
(function() { var coords = []; coords.push( [ X1, [ Y1, 1 ] ] ); coords.push( [ X2, [ Y2, 1 ] ] ); var xs = randRangeUnique( -10, 10, 5 ); for ( var i = 0; i < 5; i++ ) { var x = xs[ i ]; if( x !== X1 && x !== X2 ) { var denom = X1 - X2, num = x * ( Y1 - Y2 ) + B * denom, negative = ( num * denom < 0 ? -1 : 1 ); num = round( abs( num ) * negative ); denom = round( abs( denom ) ); coords.push( [ x, [ num / getGCD( num, denom ), denom / getGCD( num, denom )] ] ); } } return coords.sort( function(a, b) { return a[ 0 ] - b[ 0 ]; }); })()

A line goes through the following points, and the equation of that line is written in y = mx + b form.

What is the equation of the line?

xy
coord[ 0 ]coord[ 1 ][ 1 ] === 1 ? coord[ 1 ][ 0 ] : coord[ 1 ].join( "/" )

y = M\enspace\cdot\enspace x + B

We can plot all the points and the line that connects them.

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

We can choose any two points to determine the equation of the line.

Let's choose (X1, Y1) and (X2, Y2).

The equation for the slope is m = \dfrac{y_2 - y_1}{x_2 - x_1}.

Substitute both points.

m = \dfrac{Y2 - negParens(Y1)}{X2 - negParens(X1)} = fractionReduce( Y2 - Y1, X2 - X1 )

Writing the equation of the line, we have y = ( M === -1 ? "-" : ( M === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 ))) x + b (the value of m is equal to M).

To find b, we can substitute in either of the two points into the above equation. Let's go through both cases:

Using the first point (X1, Y1), substitute y = Y1 and x = X1:

Y1 = (fractionReduce( Y2 - Y1, X2 - X1 ))(X1) + b

b = Y1 - fractionReduce( X1 * ( Y2 - Y1 ), X2 - X1 ) = fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 )

Using the second point (X2, Y2), substitute y = Y2 and x = X2:

Y2 = (fractionReduce( Y2 - Y1, X2 - X1 ))(X2) + b

b = Y2 - fractionReduce( X2 * ( Y2 - Y1 ), X2 - X1 ) = fractionReduce( Y2 * (X2 - X1) - X2 * ( Y2 - Y1 ), X2 - X1 )

In both cases, the equation of the line is y = ( M === -1 ? "-" : ( M === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 ))) x + fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 ) (the value of m is equal to M).

randRange( 0, 1 )

The equation of the line through the points (X1, Y1) and (X2, Y2) is written in the form y = mx + b.

What is the equation of the line?

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

y = M\enspace\cdot\enspace x + B

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

The equation for the slope is m = \dfrac{y_2 - y_1}{x_2 - x_1}.

Substitute both points.

m = \dfrac{Y2 - negParens(Y1)}{X2 - negParens(X1)} = fractionReduce( Y2 - Y1, X2 - X1 )

Writing the equation of the line, we have y = ( M === -1 ? "-" : ( M === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 ))) x + b (the value of m is equal to M).

To find b, we can substitute in either of the two points into the above equation. Let's go through both cases:

Using the first point (X1, Y1), substitute y = Y1 and x = X1:

Y1 = (fractionReduce( Y2 - Y1, X2 - X1 ))(X1) + b

b = Y1 - fractionReduce( X1 * ( Y2 - Y1 ), X2 - X1 ) = fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 )

Using the second point (X2, Y2), substitute y = Y2 and x = X2:

Y2 = (fractionReduce( Y2 - Y1, X2 - X1 ))(X2) + b

b = Y2 - fractionReduce( X2 * ( Y2 - Y1 ), X2 - X1 ) = fractionReduce( Y2 * (X2 - X1) - X2 * ( Y2 - Y1 ), X2 - X1 )

In both cases, the equation of the line is y = ( M === -1 ? "-" : ( M === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 ))) x + fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 ) (the value of m is equal to M).