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
/
quadratic_equation.html
93 lines (77 loc) · 3.99 KB
/
quadratic_equation.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
<!DOCTYPE html>
<html data-require="math polynomials expressions math-format">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quadratic formula</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars" data-ensure="( (B*B) - 4*A*C ) >= 0">
<var id="A">randRangeNonZero(-10, 10)</var>
<var id="B">randRangeNonZero(-10, 10)</var>
<var id="C">randRangeNonZero(-10, 10)</var>
<var id="OUT_REDUCE">splitRadical(B*B - 4*A*C)[0]</var>
<var id="UNDER_ROOT">splitRadical(B*B - 4*A*C)[1]</var>
<var id="F">new Polynomial( 0, 2, [C, B, A], "x" )</var>
<var id="F_TEXT">F.text()</var>
<var id="DISC_FACTOR">splitRadical(B*B - 4*A*C)</var>
<var id="DIVISOR">getGCD( B, 2 * A, Math.sqrt( DISC_FACTOR[0] ) )</var>
<var id="WRONGS">
(function() {
var wrongs = [];
for ( var i = 0; i < 5; i++ ) {
var bad_a = randRangeNonZero(-10, 10);
var bad_b = randRangeNonZero(-10, 10);
var bad_c = randRangeNonZero(-10, 10);
var good_gcd = getGCD( A, B, C );
var bad_gcd = getGCD( bad_a, bad_b, bad_c );
while (( abs(A*bad_gcd) === abs(bad_a*good_gcd) &&
abs(B*bad_gcd) === abs(bad_b*good_gcd) &&
abs(C*bad_gcd) === abs(bad_c*good_gcd) ) ||
(( (bad_b * bad_b) - (4 * bad_a * bad_c) ) < 0))
{
bad_a = randRangeNonZero(-10, 10);
bad_b = randRangeNonZero(-10, 10);
bad_c = randRangeNonZero(-10, 10);
good_gcd = getGCD( A, B, C );
bad_gcd = getGCD( bad_a, bad_b, bad_c );
}
wrongs.push(quadraticRoots(bad_a, bad_b, bad_c));
}
return wrongs;
})()
</var>
</div>
<div class="problems">
<div>
<p class="problem">Let <code>f(x) = <var>F_TEXT</var></code>.</p>
<p class="question">Where does this function intersect the x-axis (i.e. what are the roots or zeroes of <code>f(x)</code>)?</p>
<p class="solution"><code><var>quadraticRoots(A, B, C)</var></code></p>
<ul class="choices" data-none="true" data-show="5">
<li><code><var>WRONGS[0]</var></code></li>
<li><code><var>WRONGS[1]</var></code></li>
<li><code><var>WRONGS[2]</var></code></li>
<li><code><var>WRONGS[3]</var></code></li>
<li><code><var>WRONGS[4]</var></code></li>
</ul>
</div>
</div>
<div class="hints">
<div>
<p>The function intersects the x-axis when <code>f(x) = 0</code>, so you need to solve the equation:</p>
<p><code><var>F_TEXT</var> = 0</code></p>
</div>
<div>
<p>Use the quadratic formula to solve <code>ax^2 + bx + c = 0</code>:</p>
<p><code>x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}</code></p>
</div>
<p><code>a = <var>A</var>, b = <var>B</var>, c = <var>C</var></code></p>
<p><code> x = \frac{-<var>B</var> \pm \sqrt{<var>B</var>^2 - 4 \cdot <var>A</var> \cdot <var>C</var>}}{2 \cdot <var>A</var>}</code></p>
<p><code> x = \frac{<var>-1*B</var> \pm \sqrt{<var>B*B - 4*A*C</var>}}{<var>2*A</var>}</code></p>
<p><code> x = \frac{<var>-1*B</var> \pm <var>formattedSquareRootOf(B*B-4*A*C)</var>}{<var>2*A</var>}</code></p>
<p><code><var>quadraticRoots(A, B, C)</var></code></p>
</div>
</div>
</body>
</html>