<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>AlgMap-15.3</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[Give the following quadratic in completed square form
i.e. in the form \(\left( x+a \right)^2+b.\)
<br>
\[ {@tq@} \] 
<br>
[[input:ans1]] [[validation:ans1]]
[[feedback:prt2]]
<br>
Solve the quadratic equation \({@tq@}=0\). 
Give your answer as a set 
\(\left(\mbox e.g.\ \left\{x_1 , x_2\right\} \right)\): <br>
[[input:ans2]] [[validation:ans2]] 
[[feedback:prt1]]]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[When solving a more complicated quadratic a better option, than factorising, is completing the square (The method by which we remove the {@v@} term). The general rule is:
<br>
\[ ax^2+bx+c = a\left(x^2+\frac{b}{a}x+\frac{c}{a}x \right) = a\left(\left(x+\frac{b}{2a} \right)^2-\frac{b^2}{4a^2}+\frac{c}{a} = a\left(x+\frac{b}{2a} \right)^2-\frac{b^2}{4a}+c \right). \]
<br>
Once you have removed the \(x\) term you can rearrange the formula to find \((x+\frac{b}{2a})^2\). Then you simply need to square root and rearrange to find \(x\).

In this example:
\[ {@ta@} = 0, \]
we extract the {@v^2@} coefficient, \({@a@}\):
\[ {@a*(v^2+(2*b)*v+(b^2+c/a))@} = 0. \]
Then we complete the square:
\[ {@ta@} = 0. \]
Rearranging gives:
\[ {@(v+b)^2@} = {@-c/a@}. \]
Square root (remember to take plus and minus):
\[ {@(v+b)@} = \pm {@sqrt(-c/a)@}. \]
Finally:
\[ {@v@} = {@-b@} \pm {@sqrt(-c/a)@}. \]
Therefeore, our solution set is:

\[ {@ts@} \]]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text/>
    </stackversion>
    <questionvariables>
      <text>v:rand([x,y,z,t]);
a:1;
b:rand(2)+2;
c:-(rand(5)+1)^2;
ta:a*(v+b)^2+c;
tq:expand(ta);
ts:{sqrt(-c/a)-b,-sqrt(-c/a)-b};</text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>\( {@ta@} \) has solutions \({@ts@}\).</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <prtcorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:green;"><i class="fa fa-check"></i></span> Correct answer, well done.]]></text>
    </prtcorrect>
    <prtpartiallycorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:orange;"><i class="fa fa-adjust"></i></span> Your answer is partially correct.]]></text>
    </prtpartiallycorrect>
    <prtincorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:red;"><i class="fa fa-times"></i></span> Incorrect answer.]]></text>
    </prtincorrect>
    <decimals>.</decimals>
    <scientificnotation>*10</scientificnotation>
    <multiplicationsign>none</multiplicationsign>
    <sqrtsign>1</sqrtsign>
    <complexno>i</complexno>
    <inversetrig>cos-1</inversetrig>
    <logicsymbol>lang</logicsymbol>
    <matrixparens>[</matrixparens>
    <isbroken>0</isbroken>
    <variantsselectionseed/>
    <input>
      <name>ans1</name>
      <type>algebraic</type>
      <tans>ta</tans>
      <boxsize>15</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>1</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans2</name>
      <type>algebraic</type>
      <tans>ts</tans>
      <boxsize>15</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>1</requirelowestterms>
      <checkanswertype>1</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options/>
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans2</sans>
        <tans>ts</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>1-0-T </trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>1-0-F </falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>prt2</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>CompSquare</answertest>
        <sans>ans1</sans>
        <tans>ta</tans>
        <testoptions>v</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>2-0-T </trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>2-0-F </falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>983629879</deployedseed>
    <deployedseed>1803285387</deployedseed>
    <deployedseed>367958076</deployedseed>
    <deployedseed>1987762954</deployedseed>
    <deployedseed>713100903</deployedseed>
    <deployedseed>1242498637</deployedseed>
    <deployedseed>408111443</deployedseed>
    <deployedseed>2113337421</deployedseed>
    <deployedseed>1489681694</deployedseed>
    <deployedseed>1900079047</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ta</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>ts</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>1-0-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>2-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>tq</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value/>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore/>
        <expectedpenalty/>
        <expectedanswernote>NULL</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>2-0-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
