Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

94 lines (77 sloc) 4.082 kb
<!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 &lt; 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) ) &lt; 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>
Jump to Line
Something went wrong with that request. Please try again.