# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
398 lines (327 sloc) 22.6 KB
 Solving equations in terms of a variable
randFromArray([ ["a", "b", "c"], ["f", "g", "h"], ["m", "n", "p"], ["r", "s", "t"], ["p", "q", "r"], ["x", "y", "z"] ])
randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) random() < 0.5 random() < 0.5 G + X + ( X_HAS_Y ? Y : "" ) + ( X_HAS_Z ? Z : "" ) ( X_HAS_Y ? Y : "" ) + ( X_HAS_Z ? Z : "" ) getGCD(getGCD(abs(G), abs(D - A)), getGCD(abs(E - B), abs(F - C))) ( G < 0 ? -1 : 1 ) / GCD function( y, z, c, d ) { if (X_EXTRAS === "" && DIVISOR * d === 1) { return X + "= " + plus(round(DIVISOR * y) + Y, round(DIVISOR * z) + Z, round(DIVISOR * c)); } else { return X + "= \\dfrac{" + plus(round(DIVISOR * y) + Y, round(DIVISOR * z) + Z, round(DIVISOR * c)) + "}{" + plus(round(DIVISOR * d) + X_EXTRAS) + "}"; } }

plus( X_TERM, A+Y, B+Z, C ) = plus( D+Y, E+Z, F )

Solve for X.

ANSWER(D - A, E - B, F - C, G)

• ANSWER(D + A, E - B, F - C, G)
• ANSWER(D - A, E + B, F - C, G)
• ANSWER(D - A, E - B, F + C, G)
• ANSWER(D + A, E + B, F - C, G)
• ANSWER(D + A, E - B, F + C, G)
• ANSWER(D - A, E + B, F + C, G)
• ANSWER(D + A, E + B, F + C, G)

Combine constant terms on the right.

plus( X_TERM, A+Y, B+Z, color_( C, true ) ) = plus( D+Y, E+Z, color_( F, true ) )

plus( X_TERM, A+Y, B+Z ) = plus( D+Y, E+Z, color_( F-C, true ) )

Combine Z terms on the right.

plus( X_TERM, A+Y, color_( B+Z, false ) ) = plus( D+Y, color_( E+Z, false ), F-C )

plus( X_TERM, A+Y ) = plus( D+Y, color_( (E-B)+Z, false ), F-C )

Combine Y terms on the right.

plus( X_TERM, color_( A+Y, true ) ) = plus( color_( D+Y, true ), (E-B)+Z, F-C )

plus( X_TERM ) = plus( color_( (D-A)+Y, true ), (E-B)+Z, F-C )

Isolate X.

plus( color_( G, false ) + X + color_( X_EXTRAS, false ) ) = plus( (D-A)+Y, (E-B)+Z, F-C )

ANSWER(D - A, E - B, F - C, G)

X = \dfrac{plus((D - A) + Y, (E - B) + Z, F - C)}{plus(color_(G + X_EXTRAS, false))}

Simplify by dividing by GCD.

To avoid a negative denominator, we can multiply the numerator and denominator by -1.

ANSWER(D - A, E - B, F - C, G)

randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) getGCD(A, getGCD(getGCD(abs(E), abs(F - D)), getGCD(abs(A), abs(B)))) function(y1, c, y2, z, d, flip) { y1 /= GCD; y2 /= GCD; c /= GCD; z /= GCD; d /= GCD; if (typeof flip === "undefined" ? FLIP : flip) { y1 = -y1; c = -c; y2 = -y2; z = -z; d = -d; } return X + "= \\dfrac{" + plus(y1 + Y, c) + "}{" + plus(y2 + Y, z + Z, d) + "}"; } A < 0

plus( A+X+Y, B+X+Z, C+X, D ) = plus( E+Y, F )

Solve for X.

ANSWER( E, F-D, A, B, C )

• ANSWER( E, F+D, A, B, C )
• ANSWER( 0, F-D, A, B, C )
• ANSWER( E, 0, A, B, C )
• ANSWER( E, F-D, 0, B, C )
• ANSWER( E, F-D, A, 0, C )
• ANSWER( E, F-D, A, B, 0 )
• ANSWER( E+A, F-D, A, B, C )
• ANSWER( E-A, F-D, A, B, C )
• ANSWER( E, F-D, A+B, B, C )
• ANSWER( E, F-D, A-B, B, C )
• ANSWER( E, F-D, A, A+B, C )
• ANSWER( E, F-D, A, A-B, C )
• ANSWER( E, F-D, A, B, A+C )
• ANSWER( E, F-D, A, B, A-C )

Combine constant terms on the right.

plus( A+X+Y, B+X+Z, C+X, color_( D, true ) ) = plus( E+Y, color_( F, true ) )

plus( A+X+Y, B+X+Z, C+X ) = plus( E+Y, color_( F-D, true ) )

Notice that all the terms on the left-hand side of the equation have X in them.

plus( A+color_( X, false )+Y, B+color_( X, false )+Z, C+color_( X, false ) ) = plus( E+Y, F-D )

Factor out the X.

color_( X, false ) \cdot \left( plus( A+Y, B+Z, C ) \right) = plus( E+Y, F-D )

Isolate the X.

X \cdot \left( color_( plus( A+Y, B+Z, C ), true ) \right) = plus( E+Y, F-D )

X = \dfrac{ plus( E+Y, F-D ) }{ color_( plus( A+Y, B+Z, C ), true ) }

Simplify by dividing by GCD.

ANSWER(E, F - D, A, B, C)

To avoid a negative denominator, we can multiply the numerator and denominator by -1.

ANSWER(E, F - D, A, B, C)

randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeExclude( -10, 10, [ 0, -1, 1 ] ) randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRangeExclude( -10, 10, [ 0, -1, 1 ] ) ( function() { if ( C === F || C === -F || C % F === 0 ) { return A; } else { return A*F; } })() ( function() { if ( C === F || C === -F || C % F === 0 ) { return B; } else { return B*F; } })() ( function() { if ( C === F ) { return D; } else if ( C === -F ) { return -D; } else if ( C % F === 0 ) { return D*(C/F); } else { return D*C; } })() ( function() { if ( C === F ) { return E; } else if ( C === -F ) { return -E; } else if ( C % F === 0 ) { return E*(C/F); } else { return E*C; } })() getGCD( getGCD( abs( E_TERM ), abs( B_TERM ) ), abs( A_TERM - D_TERM ) ) ( A_TERM-D_TERM < 0 ? -1 : 1 ) / GCD function( z, y, c ) { return X + " = \\dfrac{" + plus( round( z*DIVISOR )+Z, round( y*DIVISOR )+Y ) + "}{" + round( c*DIVISOR ) + "}"; }

\dfrac{ plus( A+X, B+Y ) }{ C } = \dfrac{ plus( D+X, E+Z ) }{ F }

Solve for X.

• ANSWER( E_TERM, B_TERM, A_TERM-D_TERM )
• ANSWER( -E_TERM, -B_TERM, A_TERM-D_TERM )
• ANSWER( -E_TERM, B_TERM, A_TERM-D_TERM )
• ANSWER( E_TERM, -B_TERM, A_TERM+D_TERM )
• ANSWER( E_TERM, B_TERM, A_TERM+D_TERM )
• ANSWER( -E_TERM, -B_TERM, A_TERM+D_TERM )
• ANSWER( -E_TERM, B_TERM, A_TERM+D_TERM )
• ANSWER( E_TERM, -B_TERM, -A_TERM-D_TERM )
• ANSWER( E_TERM, B_TERM, -A_TERM-D_TERM )
• ANSWER( -E_TERM, B_TERM, -A_TERM-D_TERM )
• ANSWER( -E_TERM, -B_TERM, -A_TERM-D_TERM )

Notice that the left- and right- denominators are the sameopposite.

\dfrac{ plus( A+X, B+Y ) }{ color_( C, true ) } = \dfrac{ plus( D+X, E+Z ) }{ color_( F, true ) }

So we can multiply both sides by C.

color_( C, true ) \cdot \dfrac{ plus( A+X, B+Y ) }{ color_( C, true ) } = color_( C, true ) \cdot \dfrac{ plus( D+X, E+Z ) }{ color_( F, true ) }

plus( A+X, B+Y ) = plus( D+X, E+Z ) color_( "-", true ) \cdot \left( plus( D+X, E+Z ) \right)

Distribute the negative sign on the right side.

plus( A+X, B+Y ) = plus( D_TERM+X, E_TERM+Z )

plus( color_( A_TERM, true )+X, color_( B_TERM, true )+Y ) = plus( color_( D_TERM, true )+X, color_( E_TERM, true )+Z )

Multiply both sides by the left denominator.

\dfrac{ plus( A+X, B+Y ) }{ color_( C, true ) } = \dfrac{ plus( D+X, E+Z ) }{ F }

color_( C, true ) \cdot \dfrac{ plus( A+X, B+Y ) }{ color_( C, true ) } = color_( C, true ) \cdot \dfrac{ plus( D+X, E+Z ) }{ F }

plus( A+X, B+Y ) = color_( C, true ) \cdot \dfrac { plus( D+X, E+Z ) }{ F }

Reduce the right side.

plus( A+X, B+Y ) = color_( C, false ) \cdot \dfrac{ plus( D+X, E+Z ) }{ color_( F, false ) }

plus( A+X, B+Y ) = color_( C / F, false ) \cdot \left( plus( D+X, E+Z ) \right)

Multiply both sides by the right denominator.

plus( A+X, B+Y ) = C \cdot \dfrac{ plus( D+X, E+Z ) }{ color_( F, false ) }

color_( F, false ) \cdot \left( plus( A+X, B+Y ) \right) = color_( F, false ) \cdot C \cdot \dfrac{ plus( D+X, E+Z ) }{ color_( F, false ) }

color_( F, false ) \cdot \left( plus( A+X, B+Y ) \right) = C \cdot \left( plus( D+X, E+Z ) \right)

Distribute the right sideboth sides.

plus( A+X, B+Y ) = color_( C / F, true ) \cdot \left( plus( color_( D+X, true ), color_( E+Z, true ) ) \right)

color_( F, true ) \cdot \left( plus( A+X, B+Y ) \right) = color_( C, true ) \cdot \left( plus( D+X, E+Z ) \right)

plus( A_TERM+X, B_TERM+Y ) = plus( color_( D_TERM, true )+X, color_( E_TERM, true )+Z )

plus( color_( A_TERM, true )+X, color_( B_TERM, true )+Y ) = plus( color_( D_TERM, true )+X, color_( E_TERM, true )+Z )

Combine X terms on the left.

plus( color_( A_TERM+X, false ), B_TERM+Y ) = plus( color_( D_TERM+X, false ), E_TERM+Z )

plus( color_( (A_TERM-D_TERM)+X, false ), (B_TERM)+Y ) = (E_TERM)+Z

Move the Y term to the right.

plus( (A_TERM-D_TERM)+X, color_( B_TERM+Y, true ) ) = E_TERM+Z

(A_TERM-D_TERM)+X = plus( E_TERM+Z, color_( (-B_TERM)+Y, true ) )

Isolate X by dividing both sides by its coefficient.

color_( A_TERM-D_TERM, false )+X = plus( E_TERM+Z, (-B_TERM)+Y )

X = \dfrac{ plus( E_TERM+Z, (-B_TERM)+Y ) }{ color_( A_TERM-D_TERM, false ) }

Simplify by dividing by GCD.

To avoid a negative denominator, we can multiply the numerator and denominator by -1.

X = \dfrac{ plus( color_( round( E_TERM*DIVISOR ), true )+Z, color_( round( -B_TERM*DIVISOR ), true )+Y ) }{ color_( round( (A_TERM-D_TERM)*DIVISOR ), true ) }