Skip to content

Khan/khan-exercises

Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

94 lines (82 sloc) 3.386 kb
 Solving for the y-intercept
randRangeNonZero(-10, 10) randRangeNonZero(-10, 10) randRangeNonZero(-10, 10) randRangeNonZero(-10, 10) abs(X1 - X2)/2 abs(Y1 - Y2)/2 max(X1, X2) + X_MARGIN min(X1, X2) - X_MARGIN max(Y1, Y2) + Y_MARGIN min(Y1, Y2) - Y_MARGIN Y1 - Y2 X1 - X2 SLOPE_NUMERATOR / SLOPE_DENOMINATOR Y1 - (X1 * M)

The following line passes through point (X1, Y1):

y = fractionReduce( SLOPE_NUMERATOR, SLOPE_DENOMINATOR ) x + b

What is the value of the y-intercept b?

(Y1 * SLOPE_DENOMINATOR - X1 * SLOPE_NUMERATOR) / SLOPE_DENOMINATOR

Substituting (X1, Y1) into the equation gives:

Y1 = fractionReduce( SLOPE_NUMERATOR, SLOPE_DENOMINATOR ) \cdot X1 + b

Y1 = fractionReduce( X1*SLOPE_NUMERATOR , SLOPE_DENOMINATOR ) + b

b = Y1 - fractionReduce( X1*SLOPE_NUMERATOR , SLOPE_DENOMINATOR )

b = fractionReduce( Y1 * SLOPE_DENOMINATOR - X1 * SLOPE_NUMERATOR, SLOPE_DENOMINATOR )

Plugging in fractionReduce( Y1 * SLOPE_DENOMINATOR - X1 * SLOPE_NUMERATOR, SLOPE_DENOMINATOR ) for b, we get y = fractionReduce( SLOPE_NUMERATOR, SLOPE_DENOMINATOR ) x + fractionReduce(Y1*SLOPE_DENOMINATOR-X1*SLOPE_NUMERATOR,SLOPE_DENOMINATOR).

graphInit({ range: max( abs(B) + 4 , 11 ), scale: 20, tickStep: 1, labelStep: 1, unityLabels: false, labelFormat: function( s ) { return "\\small{" + s + "}"; }, axisArrows: "<->" }); plot(function( x ) { return M * x + B; }, [min( ( -abs(B) -5 ), -12) , max( ( abs(B)+5 ), 12 )], { stroke: "#28ae7b" }); circle( [X1, Y1], 3/20, { stroke: "none", fill: "black" } ); label( [X1, Y1], "(" + X1 + ", " + Y1 + ")", p1Position( X1, Y1, X2, Y2 ) );
Something went wrong with that request. Please try again.