<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>27.1.4.5 Integrations Over Rectangular Areas Exercise</text>
    </name>
    <questiontext format="moodle_auto_format">
      <text><![CDATA[<p class="HELM_exercise">Exercise</p>
<p>Evaluate the following double integral.</p>
<p> \(I= \displaystyle \int_{0}^{\pi } \displaystyle \int_{@aa@}^{@bb@}y \sin ^{@cc@}x \, \mathrm{d}y \mathrm{d}x \) </p>
<p> \(I=\) [[input:ans1]] [[validation:ans1]]</p>]]></text>
    </questiontext>
    <generalfeedback format="moodle_auto_format">
      <text><![CDATA[<p> The integration takes place over the rectangle shown below. </p>
[[jsxgraph]]
(function() {
    var board = JXG.JSXGraph.initBoard(divid, {
        boundingbox: [-1, {#ymax#}, {#xmax#}, {#ymin#}],
        keepaspectratio: true,
        axis: true,
        showCopyright: false,
        showNavigation: false,
        grid: false
    });

    // Hide ticks but label axes
    board.defaultAxes.x.setAttribute({
        ticks: {
            drawLabels: false,
            majorHeight: 0,
            minorHeight: 0
        },
        name: 'x',
        withLabel: true,
        label: {
            position: 'rt',
            offset: [1, -10]
        }
    });

    board.defaultAxes.y.setAttribute({
        ticks: {
            drawLabels: false,
            majorHeight: 0,
            minorHeight: 0
        },
        name: 'y',
        withLabel: true,
        label: {
            position: 'rt',
            offset: [-15, 0]
        }
    });

    // Define rectangle corners dynamically
    var bl = board.create('point', [0, {#aa#}], {fixed: true, withLabel:false, visible: true, size: 3, face: 'o', fillColor: 'black', strokeColor: 'black'});
    var br = board.create('point', [Math.PI, {#aa#}], {fixed: true, withLabel:false, size: 3, face: 'o', fillColor: 'black', strokeColor: 'black'});
    var tr = board.create('point', [Math.PI, {#bb#}], {fixed: true, withLabel:false, size: 3, face: 'o', fillColor: 'black', strokeColor: 'black'});
    var tl = board.create('point', [0, {#bb#}], {fixed: true, withLabel:false, visible: true, size: 3, face: 'o', fillColor: 'black', strokeColor: 'black'});

    var rectangle = board.create('polygon', [bl, br, tr, tl], {
        name: "Rectangle",
        withLabel: false,
        color: 'white'
    });

    // Labels for x = 0 points
    [bl, tl].forEach((pt) => {
        board.create('text', [
            () => pt.X() + 0.1,
            () => pt.Y() + 0.1,
            () => `(${Math.round(pt.X())}, ${Math.round(pt.Y())})`
        ], {
            fontSize: 12,
            fixed: true,
            highlight: false
        });
    });

    // Labels for x = π points
    [br, tr].forEach((pt) => {
        board.create('text', [
            () => Math.PI + 0.1,
            () => pt.Y() + 0.1,
            () => `(π, ${Math.round(pt.Y())})`
        ], {
            fontSize: 12,
            fixed: true,
            highlight: false
        });
    });

    // Edge styling
    rectangle.borders.forEach(line => {
        line.setAttribute({strokeColor: 'darkblue'});
    });
})();
[[/jsxgraph]]
<p> We have </p>
<p> \(\qquad \displaystyle I = \int_{0}^{\pi } \displaystyle \int_{@aa@}^{@bb@}y \sin ^{@cc@}x \, \mathrm{d}y \mathrm{d}x \) </p>

<p> Computing the inner integral, we get </p>
<p>\(\qquad \displaystyle \text{Inner} = \int_{@aa@}^{@bb@}y \sin ^{@cc@}x \, \mathrm{d}y \) </p>
<p> \(\qquad \displaystyle \qquad \; = \left[\dfrac{y^2}{2} \sin^{@cc@}x \right]_{@aa@}^{@bb@} \) </p>
<p> \(\qquad \displaystyle \qquad \; = \dfrac{@(bb)^2@}{2} \sin^{@cc@}x - \dfrac{@(aa)^2@}{2} \sin^{@cc@}x \) </p>
<p> \(\qquad \displaystyle \qquad \; = {@ (bb)^2/2 * sin(x)^(cc) - (aa)^2/2 * sin(x)^(cc) @} \) </p>

<p> This can then be put into the outer integral to give </p>
<p>\(\qquad \displaystyle I = \int_{0}^{\pi} 0 \, \mathrm{d}x \) </p>
<p> Which, trivially </p>
<p> \(\qquad \quad \displaystyle  = 0 \) </p>
<p> as the definite integral of 0 is always 0, no matter the limits. </p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2025040100</text>
    </stackversion>
    <questionvariables>
      <text>bb: rand(3) + 1;
aa: -bb;
xmax: float(%pi + 1);
xmin: -1;
ymax: bb + 1;
ymin: aa - 1
cc: rand_with_step(2,5,1);
exp: y*(sinx)^cc;
inn: int(exp, y, aa, bb);
ta1: int(inn, x, 0, %pi);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text>[[feedback:prt1]]</text>
    </specificfeedback>
    <questionnote format="html">
      <text><![CDATA[<p>\[I= \int_{0}^{\pi } \int_{@aa@}^{@bb@}y \sin ^{@cc@}x \, \mathrm{d}y \mathrm{d}x = {@ev(ta1, simp)@}\]</p>]]></text>
    </questionnote>
    <questiondescription format="html">
      <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>ans1</name>
      <type>algebraic</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>
    <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</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>628685211</deployedseed>
    <deployedseed>1529757035</deployedseed>
    <deployedseed>851630603</deployedseed>
    <deployedseed>900530221</deployedseed>
    <deployedseed>1618526369</deployedseed>
    <deployedseed>391948103</deployedseed>
    <deployedseed>1267044346</deployedseed>
    <deployedseed>14820839</deployedseed>
    <deployedseed>602457399</deployedseed>
    <deployedseed>413646405</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Test case assuming the teacher's input gets full marks.</description>
      <testinput>
        <name>ans1</name>
        <value>ta1</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-1-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ev(ta1 + 1, simp)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-1-F</expectedanswernote>
      </expected>
    </qtest>
    <tags>
      <tag><text>jsxgraph_solution</text>
</tag>
    </tags>
  </question>
</quiz>
