<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>10.1.2.14 Dividing complex numbers</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p class="HELM_exercise">Exercise </p>
<p>If <span class="math inline">\(z={@exp1@}\)</span> and <span class="math inline">\(w={@exp2@}\)</span> find <span class="math inline">\(\displaystyle \frac{2z+3w}{2z-3w}\)</span>.</p>
<p>[[input:ans1]] [[validation:ans1]]&nbsp;[[feedback:Result]]</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p>We first find \(\displaystyle \frac{2z+3w}{2z-3w}\) by substituting \(z ={@exp1@}\) and \(w={@exp2@}\) and simplifing.</p>
<p>\[ \frac{2z+3w}{2z-3w} = \frac{2({@exp1@})+3({@exp2@})}{2({@exp1@})-3({@exp2@})} = \frac{{@num1@}}{{@den1@}}.\];</p>
<p>Multiplying the top and bottom by the conjugate of the denominator gives</p>
<p>\[ \frac{{@num1@}}{{@den1@}} \times \frac{{@conjugate(den1)@}}{{@conjugate(den1)@}} = 
 \frac{{@ratsimp(num1*conjugate(den1))@}}{{@ratsimp(den1*conjugate(den1))@}} ={@correctanswer@}.\]</p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2022071300</text>
    </stackversion>
    <questionvariables>
      <text>n1:ev(rand(5)+1,simp);
n2:ev(rand(5)+2,simp);
n3:ev(n1+rand(3)+1,simp);
n4:ev(n2+rand(2)+2,simp);
exp1: n1+n2*%i;
exp2: n3+n4*%i;
num:ev(2*exp1+3*exp2,simp);
num1:ratsimp(num);
den:ev(2*exp1-3*exp2,simp);
den1:ratsimp(den);

pval:ev((4*n1^2-9*n3^2+4*n2^2-9*n4^2)/(4*n1^2+9*n3^2-12*n1*n3+4*n2^2+9*n4^2-12*n2*n4),simp);

s:(2*n2+3*n4)*(2*n1-3*n3)-(2*n1+3*n3)*(2*n2-3*n4);
qval:ev(s/(4*n1^2+9*n3^2-12*n1*n3+4*n2^2+9*n4^2-12*n2*n4),simp);

correctanswer:ev(pval+qval*%i,simp);
correctanswer2:ev(pval,simp)+ev(qval,simp)*%i;
pvalwr:(n1*n3+n2*n4);
qvalwr:(n2*n3-n1*n4);
wrong1:ev(pvalwr+qvalwr*%i,simp)/(n3*n3+n4*n4);
simp:true
tempc:ev(n1*n3+n2*n3*%i - n1*n4*%i - n2*n4*(-1),simp)</text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>\(z={@exp1@}, \; w={@exp2@}, \qquad   \dfrac{2z+3w}{2z-3w} = \dfrac{{@n1@} + {@n2@}\,{@%i@}}{{@n3@} + {@n4@}\,{@%i@}} = \displaystyle {@correctanswer@}\)</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>0</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>correctanswer</tans>
      <boxsize>10</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>3</showvalidation>
      <options/>
    </input>
    <prt>
      <name>Result</name>
      <value>1.0000000</value>
      <autosimplify>0</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text>sansr:ev(realpart(ans1),simp);
  sansi:ev(imagpart(ans1),simp);</text>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>EqualComAss</answertest>
        <sans>ans1</sans>
        <tans>correctanswer</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>CMP-QUOT-TRUE</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>4</falsenextnode>
        <falseanswernote>CMP-QUOT-FALSE-0</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>1</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>sansr</sans>
        <tans>pval</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>0</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>REAL_PART_CORRECT</trueanswernote>
        <truefeedback format="html">
          <text><![CDATA[<p>The real part of your answer is correct.</p>]]></text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>2</falsenextnode>
        <falseanswernote>CMP-QUOT-FALSE-2</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>2</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>sansi</sans>
        <tans>qval</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>0</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>IM_PART_CORRECT</trueanswernote>
        <truefeedback format="html">
          <text><![CDATA[<p>The imaginary part of your answer is correct.</p>]]></text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>CMP-QUOT-FALSE-3</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>3</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans1</sans>
        <tans>wrong1</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>0</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>NOT_SIMPLIFIED_ENOUGH</trueanswernote>
        <truefeedback format="html">
          <text><![CDATA[<p>Your answer is equivalent to the correct answer, but not in the required form \(p + q\,i\).</p>]]></text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>1</falsenextnode>
        <falseanswernote>CMP-QUOT-FALSE-1</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>4</name>
        <description/>
        <answertest>EqualComAss</answertest>
        <sans>ans1</sans>
        <tans>correctanswer2</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>Result-5-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>-</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>3</falsenextnode>
        <falseanswernote>Result-5-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>157081349</deployedseed>
    <deployedseed>1134948131</deployedseed>
    <deployedseed>1795887772</deployedseed>
    <deployedseed>305010098</deployedseed>
    <deployedseed>1114946893</deployedseed>
    <deployedseed>1266657170</deployedseed>
    <deployedseed>1715326793</deployedseed>
    <deployedseed>615872831</deployedseed>
    <deployedseed>1681553214</deployedseed>
    <deployedseed>1947893437</deployedseed>
    <deployedseed>1609880002</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>correctanswer</value>
      </testinput>
      <expected>
        <name>Result</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>CMP-QUOT-TRUE</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>wrong1</value>
      </testinput>
      <expected>
        <name>Result</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>NOT_SIMPLIFIED_ENOUGH</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ev(correctanswer + 1,simp)</value>
      </testinput>
      <expected>
        <name>Result</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>IM_PART_CORRECT</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>4</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ev(correctanswer + %i,simp)</value>
      </testinput>
      <expected>
        <name>Result</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>REAL_PART_CORRECT</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>5</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>0</value>
      </testinput>
      <expected>
        <name>Result</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>CMP-QUOT-FALSE-3</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
