<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>AlgMap-15.5</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[Solve the following quadratic equation by using the quadratic formula:

\[ {@a*v^2+b*v+c@} = 0. \] 
<br>
Give your answer as a set \(\left(\mbox {e.g.} \ \left\{x_1 , x_2\right\} \right)\): <br>
<br>
\({@v@} \in \) [[input:ans]] [[validation:ans]]]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[A good method for solving any quadratic is the 'quadratic formula'. Solving a general quadratic by completing the square gives a general formula for \(x\) in terms of the coefficients of the quadratic. It is best to simply learn the quadratic formula: <br>
<br>
For \(ax^2+bx+c = 0 \):

\[ x = \frac{ -b\pm\sqrt{b^2-4ac} }{2a}.  \]

However it can be derived, as mentioned above, by completing the square:

\[ ax^2+bx+c = 0 \]

Factor out the \(x^2\) coefficient \(a\):

\[ a\left(x^2+\frac{b}{a}x+\frac{c}{a}x \right) = 0. \]

Complete the square:

\[ a\left(\left(x+\frac{b}{2a} \right)^2-\frac{b^2}{4a^2}+\frac{c}{a}\right) = 0. \]

Multiply back through by \(a\):

\[ a\left(x+\frac{b}{2a} \right)^2-\frac{b^2}{4a}+c = 0. \]

Rearranging gives:

\[ \left(x+\frac{b}{2a}\right)^2 = \frac{b^2}{4a^2}-\frac{c}{a}. \]

Simplify RHS into a single fraction:

\[ \left(x+\frac{b}{2a}\right)^2 = \frac{b^2-4ac}{4a^2}. \]

Square root (remember to take plus and minus):

\[ \left(x+\frac{b}{2a}\right) = \pm \frac{\sqrt{b^2-4ac}}{2a}. \]

Finally:

\[ x = \frac {-b \pm \sqrt{b^2-4ac} }{2a}. \]

In this exmaple: \(a = {@a@}\), \(b = {@b@}\), \(c = {@c@}\), so subbing these into the quadratic formula gives:

\[ {@v@} = \frac{{@(-b)@} \pm \sqrt{{@b^2@}-({@4*a*c@})}}{@2*a@} = {@-b/(2*a)@} \pm {@(sqrt(b^2-4*a*c))/(2*a)@}. \]

Therefore \( {@v@} = {@ta1@}\) or \( {@v@} = {@ta2@}\) and so the solution set is: 

\[ {@v@} \in {@{ta1  , ta2}@}. \]]]></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:(rand(2)+2)*rand([-1,1]);
b:(rand(5)+8)*rand([-1,1]);
c:(rand(3)+1)*rand([-1,1]);
ta1:-b/(2*a)+sqrt(b^2-4*a*c)/(2*a);
ta2:-b/(2*a)-sqrt(b^2-4*a*c)/(2*a);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text><![CDATA[<p>[[feedback:prt1]]</p>]]></text>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>\[ {@a*v^2+b*v+c@} = 0. \] 
\[ {@v@} \in {@{ta1  , ta2}@}. \]</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>ans</name>
      <type>algebraic</type>
      <tans>{ta1,ta2}</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>ans</sans>
        <tans>{ta1, ta2 }</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>
    <deployedseed>1362638154</deployedseed>
    <deployedseed>431010716</deployedseed>
    <deployedseed>738666292</deployedseed>
    <deployedseed>1905711107</deployedseed>
    <deployedseed>1678857446</deployedseed>
    <deployedseed>1830586576</deployedseed>
    <deployedseed>1883529941</deployedseed>
    <deployedseed>1565156671</deployedseed>
    <deployedseed>1517343997</deployedseed>
    <deployedseed>864583069</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans</name>
        <value>{ta1, ta2}</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>1-0-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans</name>
        <value>{?,?}</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore/>
        <expectedpenalty/>
        <expectedanswernote>NULL</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
