# Khan/khan-exercises

### Subversion checkout URL

You can clone with
or
.
Fetching contributors…

Cannot retrieve contributors at this time

109 lines (93 sloc) 5.939 kB
 Systems of equations
randRangeNonZero( -9, 9 ) randRangeNonZero( -9, 9 ) randRangeNonZero( -9, 9 ) randRangeNonZero( -9, 9 ) randRangeNonZero( -9, 9 ) randRangeNonZero( -9, 9 ) getLCM( abs( A1 ), abs( A2 ) ) ( A_LCM / abs( A1 ) ) * ( A1 * A2 > 0 ? -1 : 1 ) A_LCM / abs( A2 ) max( abs( MULT_1 ), abs( MULT_2 ) ) getLCM( abs( B1 ), abs( B2 ) ) ( B_LCM / abs( B1 ) ) * ( B1 * B2 > 0 ? -1 : 1 ) B_LCM / abs( B2 ) max( abs( MULT_3 ), abs( MULT_4 ) ) X_MAX < Y_MAX ? true : false (C1*(B1*MULT_1+B2*MULT_2)-B1*(C1*MULT_1+C2*MULT_2))/getGCD((C1*(B1*MULT_1+B2*MULT_2)-B1*(C1*MULT_1+C2*MULT_2)),(A1*(B1*MULT_1+B2*MULT_2))) (A1*(B1*MULT_1+B2*MULT_2))/getGCD((C1*(B1*MULT_1+B2*MULT_2)-B1*(C1*MULT_1+C2*MULT_2)),(A1*(B1*MULT_1+B2*MULT_2))) ( C1 * MULT_1 + C2 * MULT_2 ) / getGCD( C1 * MULT_1 + C2 * MULT_2, B1 * MULT_1 + B2 * MULT_2 ) ( B1 * MULT_1 + B2 * MULT_2 ) / getGCD( C1 * MULT_1 + C2 * MULT_2, B1 * MULT_1 + B2 * MULT_2 )

Solve for x and y using elimination.

\begin{align*}expr(["+", ["*", A1, "x"], ["*", B1, "y"]]) &= C1 \\ expr(["+", ["*", A2, "x"], ["*", B2, "y"]]) &= C2\end{align*}

x = X_NUMER / X_DENOM

y = Y_NUMER / Y_DENOM

We can eliminate ( XY_FLAG ? "x" : "y" ) when its corresponding coefficients are negative inverses.

Recalling our knowledge of least common multiples, multiply the top equation by MULT_1 and the bottom equation by MULT_2.

\begin{align*}expr(["+", ["*", A1*MULT_1, "x"], ["*", B1*MULT_1, "y"]]) &= C1*MULT_1\\ expr(["+", ["*", A2*MULT_2, "x"], ["*", B2*MULT_2, "y"]]) &= C2*MULT_2\end{align*}

Add the top and bottom equations.

expr(["*", B1*MULT_1+B2*MULT_2, "y"]) = C1*MULT_1+C2*MULT_2

Divide both sides by B1*MULT_1+B2*MULT_2 and reduce as necessary.

y = fractionReduce( Y_NUMER, Y_DENOM )

Substitute fractionReduce( Y_NUMER, Y_DENOM ) for y in the top equation.

expr(["+", ["*", A1, "x"], ["*", B1, " " + fractionReduce( Y_NUMER, Y_DENOM )]]) = C1

expr(["+", ["*", A1, "x"], fractionReduce( B1 * Y_NUMER, Y_DENOM )]) = C1

expr(["*", A1, "x"]) = fractionReduce( C1 * Y_DENOM - B1 * Y_NUMER, Y_DENOM )

x = fractionReduce(X_NUMER,X_DENOM)

x = fractionReduce(X_NUMER,X_DENOM), y = fractionReduce( Y_NUMER, Y_DENOM )

Recalling our knowledge of least common multiples, multiply the top equation by MULT_3 and the bottom equation by MULT_4.

\begin{align*}expr(["+", ["*", A1*MULT_3, "x"], ["*", B1*MULT_3, "y"]]) &= C1*MULT_3\\ expr(["+", ["*", A2*MULT_4, "x"], ["*", B2*MULT_4, "y"]]) &= C2*MULT_4\end{align*}

Add the top and bottom equations.

expr(["*", A1*MULT_3+A2*MULT_4, "x"]) = C1*MULT_3+C2*MULT_4

Divide both sides by A1*MULT_3+A2*MULT_4 and reduce as necessary.

x = fractionReduce( X_NUMER, X_DENOM )

Substitute fractionReduce( X_NUMER, X_DENOM ) for x in the top equation.

expr(["+", ["*", A1, " " + fractionReduce( X_NUMER, X_DENOM )], ["*", B1, "y"]]) = C1

expr(["+", fractionReduce( A1 * X_NUMER, X_DENOM ), ["*", B1, "y"]]) = C1

expr(["*", B1, "y"]) = fractionReduce( C1 * X_DENOM - A1 * X_NUMER, X_DENOM )

y = fractionReduce( Y_NUMER, Y_DENOM )

x = fractionReduce( X_NUMER, X_DENOM ), y = fractionReduce( Y_NUMER, Y_DENOM )

Something went wrong with that request. Please try again.