randRangeNonZero( -3, 3 ) INDEX > 0 ? INDEX * randRangeNonZero( -1, 1 ) : 1 / INDEX * randRangeNonZero( -1, 1 ) decimalFraction( M1, "true", "true" ) M1 > 0 ? "" : "-" -1 / M1 decimalFraction( M2, "true", "true" ) M2 > 0 ? "" : "-" randRange( 2, 8 ) * randRangeNonZero( -1, 1 ) randRange( -8, 8 ) toFraction( M1 )[1] * randRangeNonZero( -3, 3 ) M1 * X1 + B1 round( ( B2 - B1 ) / ( M1 - M2 ), 0 ) M2 * X2 + B2 pow( X1 - X2, 2 ) + pow( Y1 - Y2, 2 )

Find the distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{y = M2_FRACM2_SIGNx + B2}\thinspace.

graphInit({ range: [[-10, 10], [-10, 10]], scale: [18, 18], tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); plot(function( x ) { return ( M2 * x + B2 ); }, [-10, 10], { stroke: BLUE }); circle( [X1, Y1], 1/4, { stroke: "none", fill: "#ff0000" } );

DISTANCE

First, find the equation of the perpendicular line that passes through \color{red}{(X1, Y1)}.

The slope of the blue line is \color{BLUE}{M2_FRAC}, and its negative reciprocal is \color{GREEN}{M1_FRAC}.

Thus, the equation of our perpendicular line will be of the form \enspace \color{GREEN}{y = M1_FRACM1_SIGNx + b}\thinspace.

We can plug our point, \color{red}{(X1, Y1)}, into this equation to solve for \color{GREEN}{b}, the y-intercept.

Y1 = \color{GREEN}{M1_FRACM1_SIGN}(X1) + \color{GREEN}{b}

Y1 = decimalFraction( M1 * X1, "true", "true" ) + \color{GREEN}{b}

Y1 - decimalFraction( M1 * X1, "true", "true" ) = \color{GREEN}{b} = decimalFraction( Y1 - M1 * X1, "true", "true" )

The equation of the perpendicular line is \enspace \color{GREEN}{y = M1_FRACM1_SIGNx + B1}\thinspace.

plot(function( x ) { return ( M1 * x + B1 ); }, [-10, 10], { stroke: GREEN });

We can see from the graph (or by setting the equations equal to one another) that the two lines intersect at the point \color{red}{(X2, Y2)}. Thus, the distance we're looking for is the distance between the two red points.

circle( [X2, Y2], 1/4, { stroke: "none", fill: "#ff0000" } );

The distance formula tells us that the distance between two points is equal to: \sqrt{( x_{1} - x_{2} )^2 + ( y_{1} - y_{2} )^2}

Plugging in our points \color{red}{(X1, Y1)} and \color{red}{(X2, Y2)} gives us: \sqrt{( \color{red}{X1} - \color{red}{X2} )^2 + ( \color{red}{Y1} - \color{red}{Y2} )^2}

= \sqrt{( X1 - X2 )^2 + ( Y1 - Y2 )^2} = \sqrt{DISTANCE} = formattedSquareRootOf( DISTANCE )

The distance between the point \color{red}{(X1, Y1)} and the line \thinspace \color{BLUE}{y = M2_FRACM2_SIGNx + B2}\enspace is \thinspaceformattedSquareRootOf( DISTANCE ).

0 99999 randRange( 2, 8 ) * randRangeNonZero( -1, 1 ) 0 randRangeNonZero( -8, 8 ) randRange( -8, 8 ) 0

Find the distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{y = B1}\thinspace.

graphInit({ range: [[-10, 10], [-10, 10]], scale: [18, 18], tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); plot(function( x ) { return ( M1 * x + B1 ); }, [-10, 10], { stroke: BLUE }); circle( [X1, Y1], 1/4, { stroke: "none", fill: "#ff0000" } );

pow( Y1 - B1, 2 )

First, find the equation of the perpendicular line that passes through \color{red}{(X1, Y1)}.

Since the slope of the blue line is 0, the perpendicular line will have an infinite slope and therefore will be a vertical line.

The equation of the vertical line that passes through \color{red}{(X1, Y1)} is \enspace \color{GREEN}{x = X1}\thinspace.

plot(function( x ) { return ( M2 * ( x - X1 ) ); }, [-10, 10], { stroke: GREEN });

We can see from the graph that the two lines intersect at the point \color{red}{(X1, B1)}. Thus, the distance we're looking for is the distance between the two red points.

circle( [X1, B1], 1/4, { stroke: "none", fill: "#ff0000" } );

Since their x components are the same, the distance between the two points is simply the change in y:

|\color{red}{Y1} - ( \color{red}{B1} )| = abs( Y1 - B1 )

The distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{y = B1}\enspace is \thinspaceabs( Y1 - B1 ).

99999 0 randRange( 2, 8 ) * randRangeNonZero( -1, 1 ) 0 randRange( -8, 8 ) randRangeNonZero( -8, 8 ) 0

Find the distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{x = B1}\thinspace.

graphInit({ range: [[-10, 10], [-10, 10]], scale: [18, 18], tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); line( [ B1, -10 ], [ B1, 10 ], { stroke: BLUE }); circle( [X1, Y1], 1/4, { stroke: "none", fill: "#ff0000" } );

pow( X1 - B1, 2 )

First, find the equation of the perpendicular line that passes through \color{red}{(X1, Y1)}.

Since the blue line has an infinite slope, the perpendicular line will have a slope of \color{GREEN}{0} and therefore will be a horizontal line.

The equation of the perpendicular line that passes through \color{red}{(X1, Y1)} is \enspace \color{GREEN}{y = Y1}\thinspace.

plot(function( x ) { return ( M2 * x + Y1 ); }, [-10, 10], { stroke: GREEN });

We can see from the graph that the two lines intersect at the point \color{red}{(B1, Y1)}. Thus, the distance we're looking for is the distance between the two red points.

circle( [B1, Y1], 1/4, { stroke: "none", fill: "#ff0000" } );

Since their y components are the same, the distance between the two points is simply the change in x:

|\color{red}{X1} - ( \color{red}{B1} )| = abs( X1 - B1 )

The distance between the point \color{red}{(X1, Y1)} and the line \enspace \color{BLUE}{x = B1}\enspace is \thinspaceabs( X1 - B1 ).