<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>HELM 32.5 E1 Wave Equation, Single Time Step</text>
    </name>
    <questiontext format="markdown">
      <text><![CDATA[**32.5 E1 Wave Equation, Single Time Step**

Suppose that \\\( u = u(x, t) \\\) satisfies the wave equation \\\( u_{tt} = c^2 u_{xx} \\\) in \\\( t > 0 \\\) and \\\( 0 < x < {@L@} \\\).

It is given that \\\( u \\\) satisfies the boundary conditions \\\( u(0, t) = u({@L@}, t) = 0 \\\) (\\\( t > 0 \\\)) and initial conditions that need not be stated for the purposes of this question. The application is such that the wave speed \\\( c = 1.4 \\\).

The numerical method

\\\[
u_j^{n+1} = 2u_j^n - u_j^{n-1} + \mu^2(u_{j+1}^n - 2u_j^n + u_{j-1}^n)
\\\]

where \\\( \mu = \frac{c \, \delta t}{\delta x} \\\), is implemented using \\\( \delta x = {@dx@} \\\) and \\\( \delta t = {@dt@} \\\).

Suppose that, after 7 time-steps, the following data forms part of the numerical solution:

{@apply(table,append([[u_j^6,u_j^7]],args(transpose(matrix(u6,u7)))))@}

Carry out the next time-step to find an approximation to \\\( u \\\) at \\\( t = 8 \delta t \\\).


\\\(\mu=\\\) [[input:S_mu]] [[validation:S_mu]] [[feedback:mu]]

\\\(u_j^8\\\) at \\\(t=8\delta t\\\) with at least 4 d.p.
[[input:S_u8]] [[validation:S_u8]] [[feedback:u8]]]]></text>
    </questiontext>
    <generalfeedback format="markdown">
      <text/>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2024072400</text>
    </stackversion>
    <questionvariables>
      <text><![CDATA[[L,dx]: rand([[0.6,0.15], [0.8,0.2], [0.4,0.1] ]);
c: 1.4+rand([-0.1,0,0.1]);
dt: 0.1;
mu: c * dt / dx;

/* Given values after 6th and 7th time steps */
u6: [0.0000, 0.1024+rand_with_step(-0.02, 0.02,0.0001), 
             0.1986+rand_with_step(-0.02, 0.02,0.0001),
             0.2361+rand_with_step(-0.02, 0.02,0.0001), 0.0000];
u7: [0.0000, 0.0997+rand_with_step(-0.02, 0.02,0.0001), 
             0.1730+rand_with_step(-0.02, 0.02,0.0001), 
             0.1169+rand_with_step(-0.02, 0.02,0.0001), 0.0000];


/* Initialize the next time step (8th time step) */
u8: makelist(0.0, i, 1, 5);

/* Apply the numerical method for j = 2, 3, 4 (internal points) */
for j:2 thru 4 do (
    u8[j] : 2*u7[j] - u6[j] + mu^2 * (u7[j+1] - 2*u7[j] + u7[j-1])
);

u8: matrix(u8);

stack_include("https://raw.githubusercontent.com/mkraska/meclib/main/Maxima/fb_value_EN.mac");]]></text>
    </questionvariables>
    <specificfeedback format="markdown">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>{@'L=L@}, {@'dx=dx@}, {@'c=c@}, {@matrix(u6,u7, args(u8)[1])@}, {@'mu=mu@}</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/>
    <isbroken>0</isbroken>
    <variantsselectionseed/>
    <input>
      <name>S_mu</name>
      <type>numerical</type>
      <tans>dispsf(mu,3)</tans>
      <boxsize>6</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint>3 s.f.</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_u8</name>
      <type>matrix</type>
      <tans>u8</tans>
      <boxsize>4</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options/>
    </input>
    <prt>
      <name>mu</name>
      <value>0.2000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumSigFigs</answertest>
        <sans>S_mu</sans>
        <tans>mu</tans>
        <testoptions>3</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>mu-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>mu-1-F</falseanswernote>
        <falsefeedback format="html">
          <text>{@fb_unit(S_mu,mu,0.005)@}</text>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>u8</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text>toList(m):= args(m)[1];</text>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumAbsolute</answertest>
        <sans>toList(S_u8)</sans>
        <tans>toList(u8)</tans>
        <testoptions>0.0001</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>u8-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>u8-1-F</falseanswernote>
        <falsefeedback format="html">
          <text><![CDATA[<br>\(u_1\): {@fb_unit(S_u8[1,1], u8[1,1], 0.0001)@}
<br>\(u_2\): {@fb_unit(S_u8[1,2], u8[1,2], 0.0001)@}
<br>\(u_3\): {@fb_unit(S_u8[1,3], u8[1,3], 0.0001)@}
<br>\(u_4\): {@fb_unit(S_u8[1,4], u8[1,4], 0.0001)@}
<br>\(u_5\): {@fb_unit(S_u8[1,5], u8[1,5], 0.0001)@}]]></text>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>579624181</deployedseed>
    <deployedseed>1343186453</deployedseed>
    <deployedseed>1134831928</deployedseed>
    <deployedseed>2076650385</deployedseed>
    <deployedseed>1366787899</deployedseed>
    <deployedseed>1910156339</deployedseed>
    <deployedseed>336030133</deployedseed>
    <deployedseed>487474868</deployedseed>
    <deployedseed>1130909704</deployedseed>
    <deployedseed>624011609</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Test case assuming the teacher's input gets full marks.</description>
      <testinput>
        <name>S_mu</name>
        <value>dispsf(mu,3)</value>
      </testinput>
      <testinput>
        <name>S_u8</name>
        <value>u8</value>
      </testinput>
      <expected>
        <name>mu</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>mu-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>u8</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>u8-1-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description>Test case assuming the teacher's input gets full marks.</description>
      <testinput>
        <name>S_mu</name>
        <value>dispsf(mu,3)</value>
      </testinput>
      <testinput>
        <name>S_u8</name>
        <value>u8</value>
      </testinput>
      <expected>
        <name>mu</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>mu-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>u8</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>u8-1-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
