This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
/
systems_of_equations.html
288 lines (274 loc) · 19.2 KB
/
systems_of_equations.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<!DOCTYPE html>
<html data-require="math math-format expressions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Systems of equations</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars" data-ensure="abs(X_DENOM) < 6 && abs(Y_DENOM) < 6 && abs(X_NUMER) < 11 && abs(Y_NUMER) < 11">
<var id="A1">randRangeNonZero(-6, 6)</var>
<var id="A2">randRangeNonZero(-6, 6)</var>
<var id="B1">randRangeNonZero(-6, 6)</var>
<var id="B2" data-ensure="(B1 * A2) !== (A1 * B2)">randRangeNonZero(-6, 6)</var>
<var id="C1">randRangeNonZero(-9, 9)</var>
<var id="C2">randRangeNonZero(-9, 9)</var>
<var id="MULT_1, MULT_2">(function() {
var lcm = getLCM(abs(A1), abs(A2));
var m1 = lcm / abs(A1);
var m2 = lcm / abs(A2);
if (A1 * A2 > 0) {
if (m1 === 1) {
m2 *= -1;
} else {
m1 *= -1;
}
}
return [m1, m2];
})()</var>
<var id="MULT_3, MULT_4">(function() {
var lcm = getLCM(abs(B1), abs(B2));
var m1 = lcm / abs(B1);
var m2 = lcm / abs(B2);
if (B1 * B2 > 0) {
if (m1 === 1) {
m2 *= -1;
} else {
m1 *= -1;
}
}
return [m1, m2];
})()</var>
<var id="XY_FLAG">abs(MULT_1 * MULT_2) < abs(MULT_3 * MULT_4) ? true : false</var>
<var id="MULT_A, MULT_B">XY_FLAG ? [MULT_1, MULT_2] : [MULT_3, MULT_4]</var>
<var id="X_NUMER1">C1 * (B1 * MULT_1 + B2 * MULT_2) - B1 * (C1 * MULT_1 + C2 * MULT_2)</var>
<var id="X_DENOM1">A1 * (B1 * MULT_1 + B2 * MULT_2)</var>
<var id="X_GCD">getGCD(X_NUMER1, X_DENOM1)</var>
<var id="X_NUMER">X_NUMER1 / X_GCD</var>
<var id="X_DENOM">X_DENOM1 / X_GCD</var>
<var id="X_NUMER2">C1 * MULT_3 + C2 * MULT_4</var>
<var id="X_DENOM2">A1 * MULT_3 + A2 * MULT_4</var>
<var id="Y_NUMER1">C1 * MULT_1 + C2 * MULT_2</var>
<var id="Y_DENOM1">B1 * MULT_1 + B2 * MULT_2</var>
<var id="Y_GCD">getGCD(Y_NUMER1, Y_DENOM1)</var>
<var id="Y_NUMER">Y_NUMER1 / Y_GCD</var>
<var id="Y_DENOM">Y_DENOM1 / Y_GCD</var>
</div>
<div class="problems">
<div id="elimination">
<p class="problem">Solve for <code>x</code> and <code>y</code>.</p>
<p class="question">
<code>\begin{align*}
<var>expr(["+", ["*", A1, "x"], ["*", B1, "y"]])</var> &= <var>C1</var> \\
<var>expr(["+", ["*", A2, "x"], ["*", B2, "y"]])</var> &= <var>C2</var>
\end{align*}</code>
</p>
<div class="solution" data-type="multiple">
<p><code>x</code> = <span class="sol"><var>X_NUMER2 / X_DENOM2</var></span></p>
<p><code>y</code> = <span class="sol"><var>Y_NUMER / Y_DENOM</var></span></p>
</div>
<div class="hints">
<div>
<p>One way to solve this system of equations is to use elimination.</p>
<p data-if="XY_FLAG">
In order to eliminate <code>\blue{x}</code>, we need to make its coefficient in one equation equal to
the negative of its coefficient for the other equation.
</p>
<p data-else="">
In order to eliminate <code>\green{y}</code>, we need to make its coefficient in one equation equal to
the negative of its coefficient for the other equation.
</p>
<p>
<code>\begin{align*}
\blue{<var>expr(["*", A1, "x"])</var>} <span data-if="B1 > 0">+</span>
\green{<var>expr(["*", B1, "y"])</var>} &= <var>C1</var> \\
\blue{<var>expr(["*", A2, "x"])</var>} <span data-if="B2 > 0">+</span>
\green{<var>expr(["*", B2, "y"])</var>} &= <var>C2</var>
\end{align*}</code>
</p>
</div>
<div data-if="MULT_A !== 1 || MULT_B !== 1">
<p>
Multiply <span data-if="MULT_A !== 1">the top equation by <code><var>MULT_A</var></code></span><span data-if="MULT_A !== 1 && MULT_B !== 1"> and </span><span data-if="MULT_B !== 1">the bottom equation by <code><var>MULT_B</var></code></span>.
</p>
<p>
<code>\begin{align*}
\blue{<var>expr(["*", A1 * MULT_A, "x"])</var>} <span data-if="B1 * MULT_A > 0">+</span>
\green{<var>expr(["*", B1 * MULT_A, "y"])</var>} &= <var>C1 * MULT_A</var> \\
\blue{<var>expr(["*", A2 * MULT_B, "x"])</var>} <span data-if="B2 * MULT_B > 0">+</span>
\green{<var>expr(["*", B2 * MULT_B, "y"])</var>} &= <var>C2 * MULT_B</var>
\end{align*}</code>
</p>
</div>
<div data-if="XY_FLAG" data-unwrap="">
<div>
<p>Add the top and bottom equations.</p>
<p><code>\green{<var>expr(["*", Y_DENOM1, "y"])</var>} = <var>Y_NUMER1</var></code></p>
</div>
<div data-if="Y_DENOM1 !== 1">
<p>
Divide both sides by <code><var>Y_DENOM1</var></code><span data-if="Y_NUMER !== 0 && Y_GCD !== 1"> and simplify</span>.
</p>
<p><code>\green{y = <var>fractionReduce(Y_NUMER, Y_DENOM)</var>}</code></p>
</div>
<p>Substitute <code>\green{<var>fractionReduce(Y_NUMER, Y_DENOM)</var>}</code> for <code>\green{y}</code> in the top equation.</p>
<div>
<p><code>
\blue{<var>expr(["*", A1, "x"])</var>} <span data-if="B1 > 0">+</span>
\green{<var>B1</var>}(\green{<var>fractionReduce(Y_NUMER, Y_DENOM)</var>}) = <var>C1</var>
</code></p>
<p><code data-if="Y_NUMER !== 0">
\blue{<var>expr(["*", A1, "x"])</var>} <span data-if="B1 * Y_NUMER * Y_DENOM > 0">+</span>
<var>fractionReduce(B1 * Y_NUMER, Y_DENOM)</var> = <var>C1</var>
</code></p>
<p><code>
\blue{<var>expr(["*", A1, "x"])</var>} = <var>fractionReduce(C1 * Y_DENOM - B1 * Y_NUMER, Y_DENOM)</var>
</code></p>
<p><code data-if="A1 !== 1">\blue{x = <var>fractionReduce(X_NUMER, X_DENOM)</var>}</code></p>
<p>
The solution is <code>\blue{x = <var>fractionReduce(X_NUMER, X_DENOM)</var>}, \enspace
\green{y = <var>fractionReduce(Y_NUMER, Y_DENOM)</var>}</code>.
</p>
</div>
</div>
<div data-else="" data-unwrap="">
<div>
<p>Add the top and bottom equations.</p>
<p><code>\blue{<var>expr(["*", X_DENOM2, "x"])</var>} = <var>X_NUMER2</var></code></p>
</div>
<div data-if="X_DENOM1 !== 1">
<p>
Divide both sides by <code><var>X_DENOM2</var></code><span data-if="getGCD(X_NUMER2, X_DENOM2) !== 1"> and simplify</span>.
</p>
<p><code>\blue{x = <var>fractionReduce(X_NUMER2, X_DENOM2)</var>}</code></p>
</div>
<p>Substitute <code>\blue{<var>fractionReduce(X_NUMER2, X_DENOM2)</var>}</code> for <code>\blue{x}</code> in the top equation.</p>
<div>
<p><code>
\blue{<var>A1</var>}(\blue{<var>fractionReduce(X_NUMER2, X_DENOM2)</var>}) <span data-if="B1 > 0">+</span>
\green{<var>expr(["*", B1, "y"])</var>} = <var>C1</var>
</code></p>
<p><code data-if="X_NUMER !== 0">
<var>fractionReduce(A1 * X_NUMER2, X_DENOM2)</var> <span data-if="B1 > 0">+</span>
\green{<var>expr(["*", B1, "y"])</var>} = <var>C1</var>
</code></p>
<p><code>
\green{<var>expr(["*", B1, "y"])</var>} = <var>fractionReduce(C1 * X_DENOM2 - A1 * X_NUMER2, X_DENOM2)</var>
</code></p>
<p><code data-if="A1 !== 1">\green{y = <var>fractionReduce(Y_NUMER, Y_DENOM)</var>}</code></p>
<p>
The solution is <code>\blue{x = <var>fractionReduce(X_NUMER2, X_DENOM2)</var>}, \enspace
\green{y = <var>fractionReduce(Y_NUMER, Y_DENOM)</var>}</code>.
</p>
</div>
</div>
</div>
</div>
<div id="substitution-y">
<div class="vars">
<var id="A1_SIGN">A1 > 0 ? "" : "-"</var>
<var id="B1_SIGN">B1 > 0 ? "+" : "-"</var>
<var id="SIGN_1">A2 / B2 > 0 ? "-" : ""</var>
<var id="SIGN_2">A2 / B2 * B1 > 0 ? "-" : ""</var>
</div>
<p class="problem">Solve for <code>x</code> and <code>y</code>.</p>
<p class="question"><code>\begin{align*}<var>expr(["+", ["*", A1, "x"], ["*", B1, "y"]])</var> &= <var>C1</var> \\
<var>expr(["+", ["*", A2, "x"], ["*", B2, "y"]])</var> &= <var>C2</var>\end{align*}</code></p>
<div class="solution" data-type="multiple">
<p><code>x</code> = <span class="sol"><var>X_NUMER / X_DENOM</var></span></p>
<p><code>y</code> = <span class="sol"><var>Y_NUMER / Y_DENOM</var></span></p>
</div>
<div class="hints">
<div>
<p>
One way to solve this system of equations is by deriving an expression for <code>y</code> from the second equation,
and substituting it back into the first equation.
</p>
<p>Begin by subtracting <code><var>expr(["*", A2, "x"])</var></code> from both sides of the second equation.</p>
<p><code><var>expr(["*", B2, "y"])</var> = <span data-if="B2 === 1">\blue{</span><var>expr(["+", ["*", -A2, "x"], C2])</var><span data-if="B2 === 1">}</span></code></p>
</div>
<div data-if="B2 !== 1">
<p>Divide both sides by <code><var>B2</var></code> to isolate <code>y</code>.</p>
<p><code>y = \blue{<span data-if="abs( abs( A2 / B2 ) - 1 ) < 0.0001"><var>SIGN_1</var></span><span data-else=""><var>decimalFraction( -A2 / B2, "true", "true" )</var></span>x + <var>decimalFraction( C2 / B2, "true", "true" )</var>}</code></p>
</div>
<div>
<p>Substitute this expression for <code>y</code> in the first equation.</p>
<p><code><var>expr(["*", A1, "x"])</var><var>B1_SIGN</var><span data-if="abs( B1 ) !== 1"><var>abs( B1 )</var></span>(\blue{<span data-if="abs( abs( A2 / B2 ) - 1 ) < 0.0001"><var>SIGN_1</var></span><span data-else=""><var>decimalFraction( -A2 / B2, "true", "true" )</var></span>x + <var>decimalFraction( C2 / B2, "true", "true" )</var>}) = <var>C1</var></code></p>
</div>
<p><code><var>expr(["*", A1, "x"])</var> + <span data-if="abs( abs( -A2 / B2 * B1 ) - 1 ) < 0.0001"><var>SIGN_2</var></span><span data-else=""><var>decimalFraction( -A2 / B2 * B1, "true", "true" )</var></span>x + <var>decimalFraction( C2 / B2 * B1, "true", "true" )</var> = <var>C1</var></code></p>
<div>
<p>Simplify by combining terms, then solve for <code>x</code>.</p>
<p><code><var>decimalFraction( A1 + ( -A2 / B2 * B1 ), "true", "true" )</var>x + <var>decimalFraction( C2 / B2 * B1, "true", "true" )</var> = <var>C1</var></code></p>
<p><code><var>decimalFraction( A1 + ( -A2 / B2 * B1 ), "true", "true" )</var>x = <var>decimalFraction( C1 - ( C2 / B2 * B1 ), "true", "true" )</var></code></p>
<p><code>x = <var>fractionReduce( X_NUMER, X_DENOM )</var></code></p>
</div>
<div>
<p>Substitute <code><var>fractionReduce( X_NUMER, X_DENOM )</var></code> for <code>x</code> back into the top equation.</p>
<p><code><var>expr(["+", ["*", A1, " " + fractionReduce( X_NUMER, X_DENOM )], ["*", B1, "y"]])</var> = <var>C1</var></code></p>
<p><code><var>expr(["+", fractionReduce( A1 * X_NUMER, X_DENOM ), ["*", B1, "y"]])</var> = <var>C1</var></code></p>
<p><code><var>expr(["*", B1, "y"])</var> = <var>fractionReduce( C1 * X_DENOM - A1 * X_NUMER, X_DENOM )</var></code></p>
<p><code data-if="B1 !== 1">y = <var>fractionReduce(Y_NUMER, Y_DENOM)</var></code></p>
</div>
<p>
The solution is <code>x = <var>fractionReduce(X_NUMER, X_DENOM)</var>, \enspace y = <var>fractionReduce(Y_NUMER, Y_DENOM)</var></code>.
</p>
</div>
</div>
<div id="substitution-x">
<div class="vars">
<var id="A1_SIGN">A1 > 0 ? "" : "-"</var>
<var id="B1_SIGN">B1 > 0 ? "+" : "-"</var>
<var id="SIGN_1">A2 / B2 > 0 ? "-" : ""</var>
<var id="SIGN_2">A2 / B2 * A1 > 0 ? "-" : ""</var>
</div>
<p class="problem">Solve for <code>x</code> and <code>y</code>.</p>
<p class="question"><code>\begin{align*}<var>expr(["+", ["*", A1, "x"], ["*", B1, "y"]])</var> &= <var>C1</var> \\
<var>expr(["+", ["*", A2, "x"], ["*", B2, "y"]])</var> &= <var>C2</var>\end{align*}</code></p>
<div class="solution" data-type="multiple">
<p><code>x</code> = <span class="sol"><var>X_NUMER / X_DENOM</var></span></p>
<p><code>y</code> = <span class="sol"><var>Y_NUMER / Y_DENOM</var></span></p>
</div>
<div class="hints">
<div>
<p>
One way to solve this system of equations is by deriving an expression for <code>x</code> from the second equation,
and substituting it back into the first equation.
</p>
<p>Begin by subtracting <code><var>expr(["*", B2, "y"])</var></code> from both sides of the second equation.</p>
<p><code>
<var>expr(["*", A2, "x"])</var> = <span data-if="A2 === 1">\blue{</span>
<var>expr(["+", ["*", -B2, "y"], C2])</var><span data-if="A2 === 1">}</span>
</code></p>
</div>
<div data-if="A2 !== 1">
<p>Divide both sides by <code><var>A2</var></code> to isolate <code>x</code>.</p>
<p><code>x = \blue{<span data-if="abs( abs( B2 / A2 ) - 1 ) < 0.0001"><var>SIGN_1</var></span><span data-else=""><var>decimalFraction( -B2 / A2, "true", "true" )</var></span>y + <var>decimalFraction( C2 / A2, "true", "true" )</var>}</code></p>
</div>
<div>
<p>Substitute this expression for <code>x</code> in the first equation.</p>
<p><code><var>A1_SIGN</var><span data-if="abs( A1 ) !== 1"><var>abs( A1 )</var></span>(\blue{<span data-if="abs( abs( A2 / B2 ) - 1 ) < 0.0001"><var>SIGN_1</var></span><span data-else=""><var>decimalFraction( -B2 / A2, "true", "true" )</var></span>y + <var>decimalFraction( C2 / A2, "true", "true" )</var>}) + <var>expr(["*", B1, "y"])</var> = <var>C1</var></code></p>
</div>
<p><code><span data-if="abs( abs( -B2 / A2 * A1 ) - 1 ) < 0.0001"><var>SIGN_2</var></span><span data-else=""><var>decimalFraction( -B2 / A2 * A1, "true", "true" )</var></span>y + <var>decimalFraction( C2 / A2 * A1, "true", "true" )</var> + <var>expr(["*", B1, "y"])</var> = <var>C1</var></code></p>
<div>
<p>Simplify by combining terms, then solve for <code>y</code>.</p>
<p><code><var>decimalFraction( B1 + ( -B2 / A2 * A1 ), "true", "true" )</var>y + <var>decimalFraction( C2 / A2 * A1, "true", "true" )</var> = <var>C1</var></code></p>
<p><code><var>decimalFraction( B1 + ( -B2 / A2 * A1 ), "true", "true" )</var>y = <var>decimalFraction( C1 - ( C2 / A2 * A1 ), "true", "true" )</var></code></p>
<p><code>y = <var>fractionReduce(Y_NUMER, Y_DENOM)</var></code></p>
</div>
<div>
<p>Substitute <code><var>fractionReduce( Y_NUMER, Y_DENOM )</var></code> for <code>y</code> in the top equation.</p>
<p><code><var>expr(["+", ["*", A1, "x"], ["*", B1, " " + fractionReduce( Y_NUMER, Y_DENOM )]])</var> = <var>C1</var></code></p>
<p><code><var>expr(["+", ["*", A1, "x"], fractionReduce( B1 * Y_NUMER, Y_DENOM )])</var> = <var>C1</var></code></p>
<p><code><var>expr(["*", A1, "x"])</var> = <var>fractionReduce(C1 * Y_DENOM - B1 * Y_NUMER, Y_DENOM)</var></code></p>
<p><code data-if="A1 !== 1">x = <var>fractionReduce(X_NUMER, X_DENOM)</var></code></p>
</div>
<p>
The solution is <code>x = <var>fractionReduce(X_NUMER, X_DENOM)</var>,\enspace y = <var>fractionReduce(Y_NUMER, Y_DENOM)</var></code>.
</p>
</div>
</div>
</div>
</div>
</body>
</html>