From f967cdef95e9706b4f228cac3e45e0a535f2b36e Mon Sep 17 00:00:00 2001 From: Peter Kuperman Date: Mon, 11 Jul 2011 11:54:47 -0700 Subject: [PATCH] Add exercise -- systems of equations --- exercises/systems_of_equations.html | 108 ++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 exercises/systems_of_equations.html diff --git a/exercises/systems_of_equations.html b/exercises/systems_of_equations.html new file mode 100644 index 000000000..c96f1b3d5 --- /dev/null +++ b/exercises/systems_of_equations.html @@ -0,0 +1,108 @@ + + + + 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 )

+
+
+
+
+ + \ No newline at end of file