<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>HELM 32.5 E2 Wave equation, Two first timesteps</text>
    </name>
    <questiontext format="markdown">
      <text><![CDATA[**32.5 E2 Wave equation, Two first timesteps**

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(1, t) = 0 \\\) for \\\( t > 0 \\\). The initial elevation may be summarized as

{@apply(table,append([[float(x_i),f_i]],args(transpose(matrix(x,f)))))@}

and the string is initially at rest (that is, \\\( g(x) = 0 \\\)). The application is such that the wave speed \\\( c = {@c@} \\\).

Carry out the first two time-steps of the numerical method

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

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

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

Grid point values at \\\(t=\delta t\\\) with at least 3 s.f.

<table border="0"><tbody>
  <tr>
   <td>\( u_j^1=\) </td>
   <td>[[input:S_u1]]</td>
  </tr>
  <tr>
   <td></td>
   <td>[[validation:S_u1]]</td>
  </tr>
 </tbody>
</table>
<p>[[feedback:u1]]</p>

Grid point values at \\\(t=2\delta t\\\) with at least 3 s.f.

<table border="0"><tbody>
  <tr>
   <td>\( u_j^2=\) </td>
   <td>[[input:S_u2]]</td>
  </tr>
  <tr>
   <td></td>
   <td>[[validation:S_u2]]</td>
  </tr>
 </tbody>
</table>
<p>[[feedback:u2]]</p>]]></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[/* Solution generated by ChatGPT based on a prompt which consisted of pasting a copy of the question text preview.
/* Parameters */
L: rand([0.8,1,1.2]);
c:  rand_with_step(0.8,1.2,0.1);
dx: float(L/4);
dt: rand_with_step(0.1,0.2,0.02);
mu: c * dt / dx;
nx: round(L/dx)+1;
nt:
x: makelist(i*dx, i, 0, nx-1);
/* Initial conditions */
f: [0.0000, 0.7812+rand_with_step(-0.02, 0.02,0.0001), 
             0.2465+rand_with_step(-0.02, 0.02,0.0001),
             -0.1209+rand_with_step(-0.02, 0.02,0.0001), 0.0000];
/* Initialize u arrays for the first two time steps */
u0: f;
u1: makelist(0.0, i, 1, 5); /* This corresponds to t = delta t */

/* Boundary conditions: u0[1] = u0[5] = 0, and u1[1] = u1[5] = 0 */
u1[2] : u0[2] + 0.5*mu^2*(u0[3] - 2*u0[2] + u0[1]);
u1[3] : u0[3] + 0.5*mu^2*(u0[4] - 2*u0[3] + u0[2]);
u1[4] : u0[4] + 0.5*mu^2*(u0[5] - 2*u0[4] + u0[3]);

/* Now compute u2 corresponding to t = 2*delta t */
u2: makelist(0.0, i, 1, 5); /* This corresponds to t = 2*delta t */

/* Apply the numerical method */
u2[2] : 2*u1[2] - u0[2] + mu^2*(u1[3] - 2*u1[2] + u1[1]);
u2[3] : 2*u1[3] - u0[3] + mu^2*(u1[4] - 2*u1[3] + u1[2]);
u2[4] : 2*u1[4] - u0[4] + mu^2*(u1[5] - 2*u1[4] + u1[3]);

u1: matrix(u1); u2: matrix(u2);

stack_include("https://raw.githubusercontent.com/mkraska/meclib/main/Maxima/fb_value_EN.mac");

toList(m):= args(m)[1];]]></text>
    </questionvariables>
    <specificfeedback format="markdown">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>{@'L=L@}, {@'dx=dx@}, {@'c=c@}, {@u1@}, {@u2@}, {@'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_u1</name>
      <type>matrix</type>
      <tans>u1</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>
    <input>
      <name>S_u2</name>
      <type>matrix</type>
      <tans>u2</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>1.0000000</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="markdown">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>mu-1-F</falseanswernote>
        <falsefeedback format="markdown">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>u1</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumAbsolute</answertest>
        <sans>toList(S_u1)</sans>
        <tans>toList(u1)</tans>
        <testoptions>0.0001</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>u1-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>u1-1-F</falseanswernote>
        <falsefeedback format="html">
          <text><![CDATA[<br>\(u_1\): {@fb_unit(S_u1[1,1], u1[1,1], 0.0001)@}
<br>\(u_2\): {@fb_unit(S_u1[1,2], u1[1,2], 0.0001)@}
<br>\(u_3\): {@fb_unit(S_u1[1,3], u1[1,3], 0.0001)@}
<br>\(u_4\): {@fb_unit(S_u1[1,4], u1[1,4], 0.0001)@}
<br>\(u_5\): {@fb_unit(S_u1[1,5], u1[1,5], 0.0001)@}]]></text>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>u2</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>2</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>NumAbsolute</answertest>
        <sans>toList(S_u2)</sans>
        <tans>toList(u2)</tans>
        <testoptions>0.0001</testoptions>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>u2-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>u2-1-F</falseanswernote>
        <falsefeedback format="html">
          <text><![CDATA[<br>\(u_1\): {@fb_unit(S_u2[1,1], u2[1,1], 0.0001)@}
<br>\(u_2\): {@fb_unit(S_u2[1,2], u2[1,2], 0.0001)@}
<br>\(u_3\): {@fb_unit(S_u2[1,3], u2[1,3], 0.0001)@}
<br>\(u_4\): {@fb_unit(S_u2[1,4], u2[1,4], 0.0001)@}
<br>\(u_5\): {@fb_unit(S_u2[1,5], u2[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_u1</name>
        <value>u1</value>
      </testinput>
      <testinput>
        <name>S_u2</name>
        <value>u2</value>
      </testinput>
      <expected>
        <name>mu</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>mu-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>u1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>u1-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>u2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>u2-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_u1</name>
        <value>u1</value>
      </testinput>
      <testinput>
        <name>S_u2</name>
        <value>u2</value>
      </testinput>
      <expected>
        <name>mu</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>mu-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>u1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>u1-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>u2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>u2-1-T</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
