Permalink
Fetching contributors…
Cannot retrieve contributors at this time
116 lines (115 sloc) 7.89 KB
<!DOCTYPE html>
<html data-require="math polynomials expressions math-format">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Solving quadratics by completing the square 2</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="problems">
<div id="original" data-weight="4">
<div class="vars">
<var id="X1">randRange( 1, 4 ) / randRangeNonZero( -2, 2 )</var>
<var id="X2" data-ensure="X1 !== X2">( randRange( -3, 3 ) * 2 + 1 ) / 2</var>
<var id="B">( X1 + X2 ) * -1</var>
<var id="B_SIGN">B &gt; 0 ? "+" : "-"</var>
<var id="C">X1 * X2</var>
<var id="MULT">getLCM( toFraction( B )[1], toFraction( C )[1] )</var>
<var id="POLY">new Polynomial( 0, 2, [MULT*C, MULT*B, MULT], "x" )</var>
<var id="POLY_TEXT">POLY.text()</var>
<var id="OR">i18n._("or")</var>
</div>
<p class="question">Complete the square to solve for <code>x</code>.</p>
<p><code><var>POLY_TEXT</var> = 0</code></p>
<div class="solution" data-type="set">
<div class="set-sol" data-type="multiple">
<span class="sol"><var>B / 2</var></span>
<span class="sol"><var>C * -1 + pow( B / 2, 2 )</var></span>
<span class="sol"><var>X1</var></span>
<span class="sol"><var>X2</var></span>
</div>
<div class="set-sol" data-type="multiple">
<span class="sol"><var>B / 2</var></span>
<span class="sol"><var>C * -1 + pow( B / 2, 2 )</var></span>
<span class="sol"><var>X2</var></span>
<span class="sol"><var>X1</var></span>
</div>
<div class="input-format">
<div class="entry" data-type="multiple">
<b>Completed Square:</b> <br>
<code>(x + {}</code><span class="sol short32"></span> <code>)^2 = {}</code> <span class="sol short40"></span> <br><br>
<b>Solution:</b> <br>
<code>x = {}</code><span class="sol short32"></span><code>\quad\text{<var>OR</var>}\quad x = {}</code><span class="sol short32"></span>
</div>
</div>
</div>
</div>
<div id="one-root" data-type="original" data-weight="1">
<div class="vars">
<var id="X1">( randRange( -4, 4 ) * 2 + 1 ) / 2</var>
<var id="X2">X1</var>
</div>
<div class="solution" data-type="multiple">
<p>
<b>Completed Square:</b> <br>
<code>(x + {}</code><span class="sol short32"><var>-X1</var></span> <code>)^2 = {}</code> <span class="sol short40">0</span> <br><br>
<b>Solution:</b> <br>
<code>x = \quad</code><span class="sol short32"><var>X1</var></span>
</p>
</div>
</div>
<div id="odds" data-type="original" data-weight="2">
<div class="vars">
<var id="X1">randRangeNonZero( -8, 8 )</var>
<var id="X2">randRange( -4, 4 ) * 2 + ( X1 % 2 - 1 )</var>
</div>
</div>
</div>
<div class="hints">
<div data-if="MULT !== 1">
<p>First, divide the polynomial by <code><var>MULT</var></code>, the coefficient of the <code>x^2</code> term.</p>
<p><code>x^2 <span data-if="B !== 0"><span data-if="abs( B ) !== 1"> + <var>decimalFraction( B, 1, 1 )</var></span><span data-else=""><var>B_SIGN</var></span>x</span> + <var>decimalFraction( C, 1, 1 )</var> = 0</code></p>
</div>
<div data-if="X1 !== X2" data-unwrap="">
<div data-if="C !== 0">
<p>Move the constant term to the right side of the equation.</p>
<p><code>x^2 <span data-if="B !== 0"><span data-if="abs( B ) !== 1"> + <var>decimalFraction( B, 1, 1 )</var></span><span data-else=""><var>B_SIGN</var></span>x</span> = <var>decimalFraction( C * -1, 1, 1 )</var></code></p>
</div>
<div data-if="B !== 0">
<p>We complete the square by taking half of the coefficient of our <code>x</code> term, squaring it, and adding it to both sides of the equation. The coefficient of our <code>x</code> term is <code><var>decimalFraction( B, 1, 1 )</var></code>, so half of it would be <code><var>decimalFraction( B / 2, 1, 1 )</var></code>, and squaring it gives us <code>\color{blue}{<var>decimalFraction( pow( B / 2, 2 ), 1, 1 )</var>}</code>.</p>
<p><code>x^2 <span data-if="abs( B ) !== 1"> + <var>decimalFraction( B, 1, 1 )</var></span><span data-else=""><var>B_SIGN</var></span>x \color{blue}{ + <var>decimalFraction( pow( B / 2, 2 ), 1, 1 )</var>} = <var>decimalFraction( C * -1, 1, 1 )</var> \color{blue}{ + <var>decimalFraction( pow( B / 2, 2 ), 1, 1 )</var>}</code></p>
</div>
<div data-if="B !== 0">
<p>We can now rewrite the left side of the equation as a squared term.</p>
<p><code>( x + <var>decimalFraction( B / 2, 1, 1 )</var> )^2 = <var>decimalFraction( C * -1 + pow( B / 2, 2 ), 1, 1 )</var></code></p>
</div>
</div>
<div data-else="" data-unwrap="">
<p>Note that the left side of the equation is already a perfect square trinomial. The coefficient of our <code>x</code> term is <code><var>decimalFraction( B, 1, 1 )</var></code>, half of it is <code><var>decimalFraction( B / 2, 1, 1 )</var></code>, and squaring it gives us <code>\color{blue}{<var>decimalFraction( pow( B / 2, 2 ), 1, 1 )</var>}</code>, our constant term.</p>
<div>
<p>Thus, we can rewrite the left side of the equation as a squared term.</p>
<p><code>( x + <var>decimalFraction( B / 2, 1, 1 )</var> )^2 = <var>decimalFraction( C * -1 + pow( B / 2, 2 ), 1, 1 )</var></code></p>
</div>
</div>
<div>
<p>Take the square root of both sides.</p>
<p><code>x <span data-if="B !== 0"> + <var>decimalFraction( B / 2, 1, 1 )</var></span> = <span data-if="sqrt( C * -1 + pow( B / 2, 2 ) ) !== 0">\pm</span><var>decimalFraction( sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 )</var></code></p>
</div>
<div data-if="B !== 0">
<p>Isolate <code>x</code> to find the solution(s).</p>
<p data-if="sqrt( C * -1 + pow( B / 2, 2 ) ) !== 0"><code>x = <var>decimalFraction( -B / 2, 1, 1 )</var>\pm<var>decimalFraction( sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 )</var></code></p>
</div>
<div>
<div data-if="sqrt( C * -1 + pow( B / 2, 2 ) ) !== 0">
<p>The solutions are: <code>x = <var>decimalFraction( -B / 2 + sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 )</var> \text{ <var>OR</var> } x = <var>decimalFraction( -B / 2 - sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 )</var></code></p>
</div>
<div data-else="">
<p>The solution is: <code>x = <var>decimalFraction( -B / 2 + sqrt( C * -1 + pow( B / 2, 2 ) ), 1, 1 )</var></code></p>
</div>
<p>We already found the completed square: <code>( x + <var>decimalFraction( B / 2, 1, 1 )</var> )^2 = <var>decimalFraction( C * -1 + pow( B / 2, 2 ), 1, 1 )</var></code></p>
</div>
</div>
</div>
</body>
</html>