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?
x
y
coord[ 0 ]
coord[ 1 ][ 1 ] === 1 ? coord[ 1 ][ 0 ] : coord[ 1 ].join( "/" )
y = {}
M x + {}
B
We can plot all the points and the line that connects them.
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
).
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?
y =
M\enspace\cdot\enspace x +
B
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
).