# Khan/khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

128 lines (127 sloc) 10.305 kb
 Systems of equations with substitution
randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRange( 1, 6 ) * randRangeNonZero( -1, 1 ) randRange( 1, 6 ) * randRangeNonZero( -1, 1 ) A1 * X + B1 * Y 1 randRange( 1, 6 ) * randRangeNonZero( -1, 1 ) A2 * X + B2 * Y B1 * C2 > 0 ? "-" : "+" A1 * X > 0 ? "-" : "+"

Solve for x and y using substitution.

\color{BLUE}{expr(["+", ["*", A1, "x"], ["*", B1, "y"]]) = C1}
y = expr(["+", ["*", -A2, "x"], C2])

x = X

y = Y

Since y has already been solved for, substitute expr(["+", ["*", -A2, "x"], C2]) for y in the first equation.

\color{BLUE}{expr(["*", A1, "x"]) + B1-}\color{GREEN}{(expr(["+", ["*", -A2, "x"], C2]))}\color{BLUE}{= C1}

Simplify and solve for x.

expr(["+", ["*", A1, "x"], ["*", B1 * -A2, "x"]]) + B1 * C2 = C1

expr(["+", ["*", A1 + B1 * -A2, "x"], B1 * C2]) = C1

expr(["+", ["*", A1 + B1 * -A2, "x"], B1 * C2])\color{BLUE}{SIGN_1abs( B1 * C2 )} = C1\color{BLUE}{SIGN_1abs( B1 * C2 )}

expr(["*", A1 + B1 * -A2, "x"]) = C1 - B1 * C2

\dfrac{expr(["*", A1 + B1 * -A2, "x"])}{\color{BLUE}{A1 + B1 * -A2}} = \dfrac{C1 - B1 * C2}{\color{BLUE}{A1 + B1 * -A2}}

\color{red}{x = X}

Now that you know \color{red}{x = X}, plug it back into \thinspace \color{GREEN}{y = expr(["+", ["*", -A2, "x"], C2])}\thinspace to find y.

\color{GREEN}{y = -A2-}\color{red}{(X)}\color{GREEN}{ + C2}

y = -A2 * X + C2

y = Y

You can also plug \color{red}{x = X} into \thinspace \color{BLUE}{expr(["+", ["*", A1, "x"], ["*", B1, "y"]]) = C1}\thinspace and get the same answer for y:

\color{BLUE}{A1-}\color{red}{(X)}\color{BLUE}{ + expr(["*", B1, "y"]) = C1}

\color{ORANGE}{y = Y}

randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 ) randRange( 1, 6 ) * randRangeNonZero( -1, 1 ) randRange( 1, 6 ) * randRangeNonZero( -1, 1 ) A1 * X + B1 * Y 1 randRange( 1, 6 ) * randRangeNonZero( -1, 1 ) A2 * X + B2 * Y A1 * C2 > 0 ? "-" : "+" B1 * Y > 0 ? "-" : "+"

Solve for x and y using substitution.

\color{BLUE}{expr(["+", ["*", A1, "x"], ["*", B1, "y"]]) = C1}
x = expr(["+", ["*", -B2, "y"], C2])

x = X

y = Y

Since x has already been solved for, substitute expr(["+", ["*", -B2, "y"], C2]) for x in the first equation.

\color{BLUE}{A1-}\color{GREEN}{(expr(["+", ["*", -B2, "y"], C2]))}\color{BLUE}{+ expr(["*", B1, "y"]) = C1}

Simplify and solve for y.

expr(["+", ["*", A1 * -B2, "y"], A1 * C2]) + expr(["*", B1, "y"]) = C1

expr(["+", ["*", A1 * -B2 + B1, "y"], A1 * C2]) = C1

expr(["+", ["*", A1 * -B2 + B1, "y"], A1 * C2])\color{BLUE}{SIGN_1abs( A1 * C2 )} = C1\color{BLUE}{SIGN_1abs( A1 * C2 )}

expr(["*", A1 * -B2 + B1, "y"]) = C1 - A1 * C2

\dfrac{expr(["*", A1 * -B2 + B1, "y"])}{\color{BLUE}{A1 * -B2 + B1}} = \dfrac{C1 - A1 * C2}{\color{BLUE}{A1 * -B2 + B1}}

\color{ORANGE}{y = Y}

Now that you know \color{ORANGE}{y = Y}, plug it back into \thinspace \color{GREEN}{x = expr(["+", ["*", -B2, "y"], C2])}\thinspace to find x.

\color{GREEN}{x = -B2-}\color{ORANGE}{(Y)}\color{GREEN}{ + C2}

x = -B2 * Y + C2

\color{red}{x = X}

You can also plug \color{ORANGE}{y = Y} into \thinspace \color{BLUE}{expr(["+", ["*", A1, "x"], ["*", B1, "y"]]) = C1}\thinspace and get the same answer for x:

\color{BLUE}{expr(["*", A1, "x"]) + B1-}\color{ORANGE}{(Y)}\color{BLUE}{= C1}

\color{red}{x = X}

Something went wrong with that request. Please try again.