<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>22.1.3.2 Multiplying diagonal matrices</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p class="HELM_exercise">Exercise</p>
<p>If \[A = {@A@},\] \[B = {@B@}\] and \[C = {@C@}\] find:</p>
<ol class="HELM_parts">
<li><div>\(AB =\) [[input:ans1]] [[validation:ans1]]</div>[[feedback:prt1]]
</li>
<li><div>\(BC =\) [[input:ans2]] [[validation:ans2]]</div>
[[feedback:prt2]]
</li>
</ol>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p>Here we have the following matrices:</span></p><p><span>\[ \bf A = {@A@}, B = {@B@}, C = {@C@}. \]<br></span></p><p>To multiply matrix \(\bf A\) by matrix \(\bf B\) we need to remember that the \((i,j)^{\textrm{th}}\) entry in the new matrix is the scalar product of the \(i^{\textrm{th}}\) row of \(\bf A\)&nbsp;with the \(j^{\textrm{th}}\) column of \(\bf B\).&nbsp;</p><p></p><p>For example to obtain the element in row 1, column 2 of the new matrix&nbsp;\(\bf A \bullet B\) we take row 1 of \(\bf A\), [{@A[1,1]@}, {@A[1,2]@}], and multiply it with column 2 of \(\bf B\), [{@B[1,2]@}, {@B[2,2]@}], in the usual way to produce \[ [{@A[1,1]@}\times{@B[1,2]@} +&nbsp;{@A[1,2]@}\times{@B[2,2]@}] = [{@ta1[1,2]@}]. \]</p><p><span style="color: inherit; font-size: 10pt;">So,</span></p><p>\[ \bf A\bullet B =&nbsp;{@A@} \bullet {@B@} = {@D1@} = {@ta1@}.\]<br></p><p>Similarly,</p><p>\[ \bf B\bullet C = {@B@} \bullet {@C@} = {@D2@} = {@ta2@}.\]<br></p><p></p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2020120600</text>
    </stackversion>
    <questionvariables>
      <text><![CDATA[A: ev(matrix([5,5,5],[5,5,5],[5,5,5])-rand(matrix([11,11,11],[11,11,11],[11,11,11])),simp);
B: ev(matrix([5,5],[5,5],[5,5])-rand(matrix([11,11],[11,11],[11,11])),simp);
C: ev(rand(matrix([3,3],[3,3])),simp);


BT:transpose(B);
D1:zeromatrix (first(matrix_size(A)), second(matrix_size(B)));
S1:for a:1 thru first(matrix_size(A)) do for b:1 thru second(matrix_size(B)) do D1[ev(a,simp),ev(b,simp)]:apply("+",zip_with("*",A[ev(a,simp)],BT[ev(b,simp)]));
ta1:ev(D1,simp);

CT:transpose(C);
D2:zeromatrix (first(matrix_size(B)), second(matrix_size(C)));
S2:for a:1 thru first(matrix_size(B)) do for b:1 thru second(matrix_size(C)) do D2[ev(a,simp),ev(b,simp)]:apply("+",zip_with("*",B[ev(a,simp)],CT[ev(b,simp)]));
ta2:ev(D2,simp);]]></text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>\({\bf A} = {@A@}, {\bf B} = {@B@}, {\bf C} = {@C@}, {\bf A \bullet B} ={@ta1@}, {\bf B \bullet C} ={@ta2@}\)</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>0</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <prtcorrect format="html">
      <text>Correct answer, well done.</text>
    </prtcorrect>
    <prtpartiallycorrect format="html">
      <text>Your answer is partially correct.</text>
    </prtpartiallycorrect>
    <prtincorrect format="html">
      <text>Incorrect answer.</text>
    </prtincorrect>
    <decimals>.</decimals>
    <scientificnotation>*10</scientificnotation>
    <multiplicationsign>dot</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>matrix</type>
      <tans>ta1</tans>
      <boxsize>5</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>ans2</name>
      <type>matrix</type>
      <tans>ta2</tans>
      <boxsize>5</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</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>ans1</sans>
        <tans>ta1</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-1-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>AlgEquiv</answertest>
        <sans>ans2</sans>
        <tans>ta2</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt2-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt2-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>69686578</deployedseed>
    <deployedseed>674158823</deployedseed>
    <deployedseed>183189682</deployedseed>
    <deployedseed>1748467189</deployedseed>
    <deployedseed>504143148</deployedseed>
    <deployedseed>381634708</deployedseed>
    <deployedseed>366538900</deployedseed>
    <deployedseed>1254247099</deployedseed>
    <deployedseed>910980823</deployedseed>
    <deployedseed>1217811482</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ta1</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>ta2</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt2-1-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ev(2*ta1,simp)</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>ev(2*ta2,simp)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-1-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt2-1-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
