<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>27.2.1.3 Functions as Limits of Integration Task</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Integrate the function \(z = x^2 y\) over the trapezium with vertices at \((0,0)\), \(({@bb@},1)\), \(({@bb@},{@cc@})\) and \((0,{@aa@})\).</p>
<p>\(I=\) [[input:ans1]] [[validation:ans1]]</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p>The integration takes place over the trapezium shown below</p>
[[jsxgraph]]

        var board = JXG.JSXGraph.initBoard(divid, { // STACK: when moving to STACK change 'jxgboard' for divid
            boundingbox: [-0.25, {#aa +1#}, {#bb+0.5#}, -1],
            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: [8, -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', [0,0], {fixed: true, withLabel:false, visible: false});
		var br = board.create('point', [{#bb#},1], {fixed: true, withLabel:false, visible: false});
		var tr = board.create('point', [{#bb#},{#cc#}], {fixed: true, withLabel:false, visible: false});
		var tl = board.create('point', [0,{#aa#}], {fixed: true, withLabel:false, visible: false});
		var trapezium = board.create('polygon', [bl, br, tr, tl],{name:"Trapezium",withLabel:false, color: 'white'});
		
		// Set all edges (borders) to black
		trapezium.borders.forEach(line => {
			line.setAttribute({strokeColor: 'black'});
		});
		
		// 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>Considering variable \(x\) on the outer integral and variable \(y\) on the inner integral, the trapezium has an extent in \(x\) of \(x=0\) to \(x={@bb@}\). So, the limits on the outer integral (limits on \(x\)) are \(x=0\) and \(x={@bb@}\).</p>

<p>For each value of \(x\), \(y\) varies from \(y = \dfrac{x}{@bb@}\) (line joining \((0,0)\)to \(({@bb@},1)\)) to \(y = {@dd*x + aa@}\) (line joining \(({@bb@},{@cc@})\) and \((0,{@aa@})\)). So the limits on the inner integral (limits on \(y\)) are \(y = \dfrac{x}{@bb@}\) to \(y = {@dd*x + aa@}\).</p>

<p>The double integral thus becomes</p>
<p>\(\qquad \displaystyle\int_{x=0}^{@bb@} \int_{y={@x/bb@}}^{@dd*x + aa@} x^2 y \, \mathrm{d}y \, \mathrm{d}x\)</p>

<p>The inner integral is</p>
<p>\[\begin{align}
\text{Inner}\hspace{0.1cm} \text{Integral} = \int_{@x/bb@}^{@dd*x + aa@} x^2 y \, \mathrm{d}y = \left[ x^2 \frac{y^2}{2} \right]_{@x/bb@}^{@dd*x + aa@} 
&= x^2 \frac{({@dd*x+aa@})^2}{2} - x^2 \frac{({@x/bb@})^2}{2} \\
&= {@dd^2*x^4/2 + 2*aa*dd*x^3/2 + aa^2*x^2/2 - x^4/2*bb^2@}  \end{align}\]</p>

<p>Putting this into the outer integral gives</p>
<p>\[\begin{align}
\text{Outer}\hspace{0.1cm} \text{Integral} = \int_{x=0}^{@bb@} \left({@dd^2*x^4/2 + 2*aa*dd*x^3/2 + aa^2*x^2/2 - x^4/2*bb^2@}\right)\, \mathrm{d}x 
&= \left[{@(dd^2/10)*x^5 + (aa*dd/4)*x^4 + (aa^2/6)*x^3 - (1/10*bb^2)*x^5@} \right]_0^{@bb@} \\
&= \left({@(dd^2/10) - (1/10*bb^2)@}\times({@bb@})^5 {@(aa*dd/4)@}\times ({@bb@})^4 + {@(aa^2/6)@}\times({@bb@})^3 \right) - 0 \\
&= {@ta1@}.  \end{align}\]</p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2025040100</text>
    </stackversion>
    <questionvariables>
      <text>aa: rand([4,5]);
bb: rand(3) + 1;
cc: rand([2,3]);
dd: -(aa-cc)/bb;
exp: x^2*y;
inn: int(exp, y, x/bb, dd*x + aa);
ta1: int(inn, x, 0, bb);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text><![CDATA[<p>[[feedback:prt1]]</p>]]></text>
    </specificfeedback>
    <questionnote format="html">
      <text><![CDATA[<p>Vertices: \((0,0)\), \(({@bb@},1)\), \(({@bb@},{@cc@})\) and \((0,{@aa@})\), I = {@ta1@}</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>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>938611913</deployedseed>
    <deployedseed>861631846</deployedseed>
    <deployedseed>1836195257</deployedseed>
    <deployedseed>175630426</deployedseed>
    <deployedseed>1972265027</deployedseed>
    <deployedseed>1220806837</deployedseed>
    <deployedseed>563700608</deployedseed>
    <deployedseed>1399251336</deployedseed>
    <deployedseed>480915049</deployedseed>
    <deployedseed>653657380</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/>
        <expectedanswernote>prt1-1-F</expectedanswernote>
      </expected>
    </qtest>
    <tags>
      <tag><text>jsxgraph_solution</text>
</tag>
    </tags>
  </question>
</quiz>
