<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>27.1.4.2 Integration Over Rectangular Areas Task</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Evaluate the following double integral.</p>
<p>\(I=\displaystyle\int_{@bb@}^{@aa@}\displaystyle\int_{@dd@}^{@cc@}\left( x^{2}y+3y^{2}\right)\,\mathrm{d}y\mathrm{d}x\) </p>
<p>\(I=\) [[input:ans1]] [[validation:ans1]]</p>
<p>If your answer is not an integer, leave it in rational form e.g. <code>23/5</code>.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p> The integration takes place over the rectangle shown below. </p>
[[jsxgraph]]
        var board = JXG.JSXGraph.initBoard(divid, {
            boundingbox: [{#xmin#}, {#ymax#}, {#xmax#}, {#ymin#}],
            keepaspectratio: true,
            axis: true,
            showCopyright: false,
			showNavigation: false,
			grid: false
		});
		
		// Hide tick labels and ticks on x-axis but label it
		board.defaultAxes.x.setAttribute({
		  ticks: {
			drawLabels: false, // hide numbers
			majorHeight: 0,
			minorHeight: 0
		  },
		  name: 'x',
		  withLabel: true,
		  label: {
			position: 'rt',
			offset: [1, -10]
		  }
		});

		// Hide tick labels and ticks on y-axis but label it
		board.defaultAxes.y.setAttribute({
		  ticks: {
			drawLabels: false,
			majorHeight: 0,
			minorHeight: 0
		  },
		  name: 'y',
		  withLabel: true,
		  label: {
			position: 'rt',
			offset: [-15, 0]
		  }
		});
		
		
		// points
		var bl = board.create('point', [{#bb#},{#dd#}], {fixed: true, withLabel:false, visible: true, showInfobox: false, size: 3, face: 'o', fillColor: 'black', strokeColor: 'black'});
		var br = board.create('point', [{#aa#},{#dd#}], {fixed: true, withLabel:false, visible: true, showInfobox: false, size: 3, face: 'o', fillColor: 'black', strokeColor: 'black'})
		var tr = board.create('point', [{#aa#},{#cc#}], {fixed: true, withLabel:false, visible: true, showInfobox: false, size: 3, face: 'o', fillColor: 'black', strokeColor: 'black'});
		var tl = board.create('point', [{#bb#},{#cc#}], {fixed: true, withLabel:false, visible: true, showInfobox: false, size: 3, face: 'o', fillColor: 'black', strokeColor: 'black'});
		var rectangle = board.create('polygon', [bl, br, tr, tl],{name:"Rectangle",withLabel:false, color: 'white'});
		
		// Set all edges (borders) to black
		rectangle.borders.forEach(line => {
			line.setAttribute({strokeColor: 'darkblue'});
		});
		
		// Label coordinates dynamically
		[bl, br, tr, tl].forEach((pt) =>{
			board.create('text', [
				() => pt.X() + 0.1,
				() => pt.Y() + 0.1,
				() => `(${pt.X()}, ${pt.Y()})`
			], {
				fontSize: 12,
				fixed: true,
				highlight: false
			});
		});
[[/jsxgraph]]


<p>We have <br>\(\qquad\displaystyle\int_{@bb@}^{@aa@}\displaystyle\int_{@dd@}^{@cc@} \left(x^2y + 3y^2\right) \,\mathrm{d}y\mathrm{d}x\)</p>
<p>Computing the inner integral, we get <br>\(\qquad\displaystyle\int_{@dd@}^{@cc@}\left(x^2y + 3y^2\right) \,\mathrm{d}y\)</p>
<p>\(\qquad\displaystyle = \left[\frac{1}{2}x^2y^2 + y^3\right]_{@dd@}^{@cc@} \)</p>
<p>\(\qquad\displaystyle = \frac{{@(cc)^2@}x^2}{2} + {@(cc)^3@} - (\frac{{@(dd)^2@}x^2}{2} + ({@(dd)^3@}))\)</p>
<p>\(\qquad\displaystyle = {@((cc)^2*x^2)/2 + (cc)^3 - ((dd)^2*x^2)/2 - (dd)^3@}\)</p>

<p>This can then be put into the outer integral to give <br>\(\qquad\displaystyle\int_{@bb@}^{@aa@}\left({@((cc)^2*x^2)/2 + (cc)^3 - ((dd)^2*x^2)/2 - (dd)^3@}\right)\,\mathrm{d}x\)</p>
<p>\(\qquad\displaystyle = \left[{@((((cc)^2)*(x^3))/6 + ((cc)^3)*(x) - ((dd)^2)*(x^3)/6 - (dd)^3*(x))@}\right]_{@bb@}^{@aa@} \)</p>

<p>Substituting in the limits and simplifying, we get </p>
<p>\(\qquad\displaystyle = {@(((aa)^3*(cc)^2)/6 + (cc)^3*(aa) - ((aa)^3*(dd)^2)/6 - (dd)^3*aa)@} - \left({@(((bb)^3*(cc)^2)/6 + (cc)^3*(bb) - ((bb)^3*(dd)^2)/6 - (dd)^3*(bb))@}\right)\)</p>
<p>\(\qquad\displaystyle = {@(((aa)^3*(cc)^2)/6 + (cc)^3*(aa) - ((aa)^3*(dd)^2)/6 - (dd)^3*aa) - (((bb)^3*(cc)^2)/6 + (cc)^3*(bb) - ((bb)^3*(dd)^2)/6 - (dd)^3*(bb))@}\)</p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2025073100</text>
    </stackversion>
    <questionvariables>
      <text>bb: rand_with_step(-3,0,1);
aa: rand_with_prohib(0,3,[bb]);
dd: rand_with_step(-3,0,1);
cc: rand_with_prohib(0,3,[dd]);
xmax: aa + 1;
xmin: bb - 1;
ymax: cc + 1;
ymin: dd - 1;
exp: x^(2)*y + 3*y^(2);
inn: int(exp, y, dd, cc);
ta: int(inn, x, bb, aa);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text><![CDATA[<p>[[feedback:prt1]]</p>]]></text>
    </specificfeedback>
    <questionnote format="html">
      <text><![CDATA[<p>\[I=\int_{@bb@}^{@aa@}\displaystyle\int_{@dd@}^{@cc@}\left( x^{2}y+3y^{2}\right)\,\mathrm{d}y\mathrm{d}x = {@ev(ta, simp)@}\]</p>]]></text>
    </questionnote>
    <questiondescription format="html">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <prtcorrect format="html">
      <text><![CDATA[<p><i class="fa fa-check"></i> Correct answer, well done.</p>]]></text>
    </prtcorrect>
    <prtpartiallycorrect format="html">
      <text><![CDATA[<p><i class="fa fa-adjust"></i> Your answer is partially correct.</p>]]></text>
    </prtpartiallycorrect>
    <prtincorrect format="html">
      <text><![CDATA[<p><i class="fa fa-times"></i> Incorrect answer.</p>]]></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>ta</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>ta</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>1716029500</deployedseed>
    <deployedseed>762351935</deployedseed>
    <deployedseed>880045856</deployedseed>
    <deployedseed>328865677</deployedseed>
    <deployedseed>1105944835</deployedseed>
    <deployedseed>725517295</deployedseed>
    <deployedseed>1778468177</deployedseed>
    <deployedseed>1865644829</deployedseed>
    <deployedseed>484615313</deployedseed>
    <deployedseed>2133287569</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description>Test case assuming the teacher's input gets full marks.</description>
      <testinput>
        <name>ans1</name>
        <value>ta</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(ta + 1, simp)</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty/>
        <expectedanswernote>prt1-1-F</expectedanswernote>
      </expected>
    </qtest>
    <tags>
      <tag><text>jsxgraph_solution</text>
</tag>
    </tags>
  </question>
</quiz>
