<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>22.2.4.3 1st order diff Exercise (c)</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Solve by decoupling the following first order systems:
\(\dfrac{d \underline{x}}{dt}=A\underline{x}\) where \(A={@matC@}, \underline{x}(0)={@init_c@}\).</p>
<div>\(\underline{x}=\) [[input:ans3]] [[validation:ans3]] [[feedback:prt3]]</div>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text>(c) We find that {@matC@} only has two eigenvalues: {@evals_c[1][1]@},{@evals_c[1][2]@}, where the latter is repeated. However, we find a full set of linearly independent eigenvectors \({@evecs_c[2][1][1]@}^T,{@evecs_c[2][2][1]@}^T,{@evecs_c[2][2][2]@}^T\), the latter two corresponding to the eigenvalue {@evals_c[2][1]@}. Hence we proceed as normal, substituting \(\underline{x}={@p_c@}\underline{y}\) to get \(\dot{\underline{y}}={@matD_c@}\underline{y}\), which is solved by \(\underline{y}={@soly_3@}\). Written in terms of \(\underline{x}\), this becomes \(\underline{x}=P\underline{y}={@p_c@}{@soly_3@}={@sol3_gen@}\). To find the specific solution we solve \(\underline{x}(0)={@init_c@}\), which leads to the final solution \(\underline{x}={@sol3@}\).</text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2024072400</text>
    </stackversion>
    <questionvariables>
      <text><![CDATA[/*part (c)*/
/*For this one, it was easier to pick from some prepicked "simple" matrices*/
matrices_c:[matrix([2,2,1],[1,3,1],[1,2,2]),matrix([0,-4,2],[-2,2,1],[2,2,3]),matrix([-1,1,3],[-6,4,6],[3,-1,-1]),matrix([0,2,3],[-3,5,3],[3,-2,0]),matrix([2,-2,-8],[0,2,0],[0,-1,-2])];
inits_c:[matrix([0],[0],[1]),matrix([3],[3],[0]),matrix([2],[0],[1]),matrix([0],[2],[2]),matrix([3],[3],[0])];
index_c:rand(5)+1;

matC:matrices_c[index_c];
init_c:inits_c[index_c];
evals_c:eigenvalues(matC);
evecs_c:eigenvectors(matC);

p_c:transpose(matrix(evecs_c[2][1][1],evecs_c[2][2][1],evecs_c[2][2][2]));
matD_c:matrix([evals_c[1][1],0,0],[0,evals_c[1][2],0],[0,0,evals_c[1][2]]);

soly_3:matrix([A*e^(evals_c[1][1]*t)],[B*e^(evals_c[1][2]*t)],[C*e^(evals_c[1][2]*t)]);
/*Deduce the solution by finding the general form...(Note by construction, the greater eigenvalue is repeated)*/
sol3_gen:p_c.soly_3;
/*...Deducing a particular solution by substituting t=0...*/
sol3_subst:subst(t=0,sol3_gen);
/*...finding A,B,C s.t. it equals the initial conditions...*/
abc_c:solve([sol3_subst[1,1]=init_c[1,1],sol3_subst[2,1]=init_c[2,1],sol3_subst[3,1]=init_c[3,1]],[A,B,C]);
/*... and substituting back into the general form*/
sol3:subst(abc_c[1][3],subst(abc_c[1][2],subst(abc_c[1][1],sol3_gen)));

/*Other variables used for testing*/
null2:matrix([0],[0]);
null3:matrix([0],[0],[0]);]]></text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>\(A={@matC@}\), evecs:\({@evecs_c@}\), solution\(= {@sol3@}\)</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>dot</multiplicationsign>
    <sqrtsign>1</sqrtsign>
    <complexno>i</complexno>
    <inversetrig>cos-1</inversetrig>
    <logicsymbol>lang</logicsymbol>
    <matrixparens>[</matrixparens>
    <isbroken>0</isbroken>
    <variantsselectionseed/>
    <input>
      <name>ans3</name>
      <type>matrix</type>
      <tans>sol3</tans>
      <boxsize>20</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>prt3</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text>ans3_prime:matrix([diff(ans3[1,1],t)],[diff(ans3[2,1],t)],[diff(ans3[3,1],t)])
ans3_subst:subst(t=0,ans3)</text>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans3_prime</sans>
        <tans>matC.ans3</tans>
        <testoptions/>
        <quiet>1</quiet>
        <truescoremode>+</truescoremode>
        <truescore>0.5</truescore>
        <truepenalty/>
        <truenextnode>1</truenextnode>
        <trueanswernote>prt3-1-T</trueanswernote>
        <truefeedback format="html">
          <text><![CDATA[Your answer satisfies \(\dot{\underline{x}}= A\underline{x}\).<br>]]></text>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt3-1-F</falseanswernote>
        <falsefeedback format="html">
          <text><![CDATA[Your answer should satisfy \(\dot{\underline{x}}= A\underline{x}\). In your case,
<br>\(\dot{\underline{x}}={@ans3_prime@}\),
<br>\(A\underline{x}={@matC.ans3@}\).
<br>Please try again.]]></text>
        </falsefeedback>
      </node>
      <node>
        <name>1</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans3_subst</sans>
        <tans>init_c</tans>
        <testoptions/>
        <quiet>1</quiet>
        <truescoremode>+</truescoremode>
        <truescore>0.5</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt3-2-T</trueanswernote>
        <truefeedback format="html">
          <text><![CDATA[Your answer satisfies \(\underline{x}(0)={@init_c@}\).<br>
Hence your answer is correct. Well done.]]></text>
        </truefeedback>
        <falsescoremode>-</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>2</falsenextnode>
        <falseanswernote>prt3-2-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
      <node>
        <name>2</name>
        <description/>
        <answertest>SubstEquiv</answertest>
        <sans>ans3</sans>
        <tans>sol3_gen</tans>
        <testoptions/>
        <quiet>1</quiet>
        <truescoremode>+</truescoremode>
        <truescore>0</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt3-3-T</trueanswernote>
        <truefeedback format="html">
          <text><![CDATA[However, it looks like you forgot to use the initial conditions to find a specific solution. <br>Please try again.]]></text>
        </truefeedback>
        <falsescoremode>-</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt3-3-F</falseanswernote>
        <falsefeedback format="html">
          <text><![CDATA[However, your answer should satisfy \(\underline{x}(0)={@init_c@}\), when in your case \(\underline{x}(0)={@ans3_subst@}\). <br>Please try again.]]></text>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>687040085</deployedseed>
    <deployedseed>145083942</deployedseed>
    <deployedseed>1429258930</deployedseed>
    <deployedseed>1355869172</deployedseed>
    <deployedseed>1362483430</deployedseed>
    <deployedseed>1353129757</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans3</name>
        <value>sol3</value>
      </testinput>
      <expected>
        <name>prt3</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt3-2-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans3</name>
        <value>sol3_gen</value>
      </testinput>
      <expected>
        <name>prt3</name>
        <expectedscore>0.5000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt3-3-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>3</testcase>
      <description/>
      <testinput>
        <name>ans3</name>
        <value>null3</value>
      </testinput>
      <expected>
        <name>prt3</name>
        <expectedscore>0.5000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt3-3-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
