<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>HELM 30.5 E2 Iteration Matrix</text>
    </name>
    <questiontext format="markdown">
      <text><![CDATA[**30.5 E2 Iteration Matrix**

Consider the system of linear equations

\\\({@A@}\,{@x@}={@rhs@}.\\\) 

Provide the iteration matrices \\\(M\\\) and \\\(N\\\) for the Jacobi method such that \\\(X^{(i+1)}=MX^{(i)}+N\\\).

<table border="0">
 <tbody>
  <tr>
   <td>\( M = \) </td>
   <td>[[input:S_M]] </td>
   <td>\(\,\)</td>
   <td>[[validation:S_M]]</td>
  </tr>
 </tbody>
</table>
<p>[[feedback:M]]</p>

<table border="0">
 <tbody>
  <tr>
   <td>\(N = \) </td>
   <td>[[input:S_N]] </td>
   <td>\(\,\)</td>
   <td>[[validation:S_N]]</td>
  </tr>
 </tbody>
</table>
<p>[[feedback:N]]</p>

Calculate the infinity norm of the iteration matrix:

\\\(||M||_\infty=\\\) [[input:S_ki]] [[validation:S_ki]] [[feedback:ki]]

Perform the first three iterations of the Jakobi method using zero starting values.

<table border="0">
 <tbody>
  <tr>
   <td>\( X^{(1)} = \) </td>
   <td>[[input:S_X1]] </td>
   <td>\(\,\)</td>
   <td>[[validation:S_X1]]</td>
  </tr>
 </tbody>
</table>
<p>[[feedback:X1]]</p>

<table border="0">
 <tbody>
  <tr>
   <td>\( X^{(2)} = \) </td>
   <td>[[input:S_X2]] </td>
   <td>\(\,\)</td>
   <td>[[validation:S_X2]]</td>
  </tr>
 </tbody>
</table>
<p>[[feedback:X2]]</p>

<table border="0">
 <tbody>
  <tr>
   <td>\( X^{(3)} = \) </td>
   <td>[[input:S_X3]] </td>
   <td>\(\,\)</td>
   <td>[[validation:S_X3]]</td>
  </tr>
 </tbody>
</table>
<p>[[feedback:X3]]</p>

Hint: The solution of the problem is 

\\\({@x=sol@}\\\)]]></text>
    </questiontext>
    <generalfeedback format="markdown">
      <text/>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2024012900</text>
    </stackversion>
    <questionvariables>
      <text>d: rand_with_step(3,6,1);
d2: rand_with_prohib(-2,2,[0]);

A: matrix([d,d2,0,0], [d2,d,d2,0], [0,d2,d,d2], [0,0,d2,d]); 
L: matrix([0,0,0,0], [d2,0,0,0], [0,d2,0,0], [0,0,d2,0]); 
D: matrix([d,0,0,0], [0,d,0,0], [0,0,d,0], [0,0,0,d]); 
U: matrix([0,d2,0,0], [0,0,d2,0], [0,0,0,d2], [0,0,0,0]); 

m: 4
sol: matrix([rand_with_prohib(-m,m,[0])], [rand_with_prohib(-m,m,[0])], [rand_with_prohib(-m,m,[0])], [rand_with_prohib(-m,m,[0])]);
x: matrix([x1], [x2], [x3], [x4]);
rhs: A.sol;
M: -invert(D).(L+U);
N: invert(D).rhs;

ki: mat_norm(M,inf);

X0: matrix([0], [0], [0], [0]);
X1: float(M.X0+N);
X2: float(M.X1+N);
X3: float(M.X2+N);

toList(m):= args(transpose(m))[1];</text>
    </questionvariables>
    <specificfeedback format="markdown">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>{@A@}, {@rhs@}, {@X0@} {@float(X1)@} {@float(X2)@} {@float(X3)@} {@sol@}</text>
    </questionnote>
    <questiondescription format="markdown">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <prtcorrect format="markdown">
      <text>Richtige Antwort, gut gemacht!</text>
    </prtcorrect>
    <prtpartiallycorrect format="markdown">
      <text>Ihre Antwort ist teilweise korrekt.</text>
    </prtpartiallycorrect>
    <prtincorrect format="markdown">
      <text>Falsche Antwort.</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>S_ki</name>
      <type>algebraic</type>
      <tans>ki</tans>
      <boxsize>5</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>1</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>S_M</name>
      <type>matrix</type>
      <tans>M</tans>
      <boxsize>4</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>1</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>S_N</name>
      <type>matrix</type>
      <tans>N</tans>
      <boxsize>4</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>1</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>S_X1</name>
      <type>matrix</type>
      <tans>float(X1)</tans>
      <boxsize>4</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>1</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>S_X2</name>
      <type>matrix</type>
      <tans>float(X2)</tans>
      <boxsize>4</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>1</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <input>
      <name>S_X3</name>
      <type>matrix</type>
      <tans>float(X3)</tans>
      <boxsize>4</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>1</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <prt>
      <name>ki</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>S_ki</sans>
        <tans>ki</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>ki-1-T</trueanswernote>
        <truefeedback format="markdown">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>ki-1-F</falseanswernote>
        <falsefeedback format="markdown">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>M</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumRelative</answertest>
        <sans>toList(S_M)</sans>
        <tans>toList(M)</tans>
        <testoptions>0.005</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>M-1-T</trueanswernote>
        <truefeedback format="markdown">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>M-1-F</falseanswernote>
        <falsefeedback format="markdown">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>N</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumRelative</answertest>
        <sans>toList(S_N)</sans>
        <tans>toList(N)</tans>
        <testoptions>0.005</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>N-1-T</trueanswernote>
        <truefeedback format="markdown">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>N-1-F</falseanswernote>
        <falsefeedback format="markdown">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>X1</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumRelative</answertest>
        <sans>toList(S_X1)</sans>
        <tans>toList(X1)</tans>
        <testoptions>0.005</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>X1-1-T</trueanswernote>
        <truefeedback format="markdown">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>X1-1-F</falseanswernote>
        <falsefeedback format="markdown">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>X2</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumRelative</answertest>
        <sans>toList(S_X2)</sans>
        <tans>toList(X2)</tans>
        <testoptions>0.005</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>X2-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>X2-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>X3</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumRelative</answertest>
        <sans>toList(S_X3)</sans>
        <tans>toList(X3)</tans>
        <testoptions>0.005</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>X3-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>X3-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>97038521</deployedseed>
    <deployedseed>1517836361</deployedseed>
    <deployedseed>1662151632</deployedseed>
    <deployedseed>1855979355</deployedseed>
    <deployedseed>1379163910</deployedseed>
    <deployedseed>325160686</deployedseed>
    <deployedseed>1441994389</deployedseed>
    <deployedseed>202610921</deployedseed>
    <deployedseed>1151882138</deployedseed>
    <deployedseed>784559441</deployedseed>
    <deployedseed>241687863</deployedseed>
    <deployedseed>1425548922</deployedseed>
    <deployedseed>792135783</deployedseed>
    <deployedseed>1030761934</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Test case assuming the teacher's input gets full marks.</description>
      <testinput>
        <name>S_ki</name>
        <value>ki</value>
      </testinput>
      <testinput>
        <name>S_M</name>
        <value>M</value>
      </testinput>
      <testinput>
        <name>S_N</name>
        <value>N</value>
      </testinput>
      <testinput>
        <name>S_X1</name>
        <value>float(X1)</value>
      </testinput>
      <testinput>
        <name>S_X2</name>
        <value>float(X2)</value>
      </testinput>
      <testinput>
        <name>S_X3</name>
        <value>float(X3)</value>
      </testinput>
      <expected>
        <name>ki</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>ki-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>M</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>M-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>N</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>N-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>X1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>X1-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>X2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>X2-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>X3</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>X3-1-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Test case assuming the teacher's input gets full marks.</description>
      <testinput>
        <name>S_ki</name>
        <value>ki</value>
      </testinput>
      <testinput>
        <name>S_M</name>
        <value>M</value>
      </testinput>
      <testinput>
        <name>S_N</name>
        <value>N</value>
      </testinput>
      <testinput>
        <name>S_X1</name>
        <value>float(X1)</value>
      </testinput>
      <testinput>
        <name>S_X2</name>
        <value>float(X2)</value>
      </testinput>
      <testinput>
        <name>S_X3</name>
        <value>float(X3)</value>
      </testinput>
      <expected>
        <name>ki</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>ki-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>M</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>M-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>N</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>N-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>X1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>X1-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>X2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>X2-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>X3</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>X3-1-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
