// Numbas version: exam_results_page_options {"name": "6. Step Function", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"preventleave": false, "showfrontpage": false, "allowregen": true}, "question_groups": [{"questions": [{"preamble": {"css": "", "js": ""}, "statement": "

The function $g(x,y)$ is a step function taking the following values on each of the rectangles shown below.

\n

{domain()}

\n

Calculate the integral

\n

\$\\iint_D g(x,y) dx dy \$

\n

of $g$ over the whole rectangle $D=[0,{\\var{MX()}}]\\times[0,{\\var{N[y]}}]$.

", "name": "6. Step Function", "tags": [], "extensions": ["jsxgraph"], "variable_groups": [{"variables": ["sm", "sn", "m1", "m2", "m3", "m4", "n1", "n2", "n3", "n4"], "name": "Spacing of columns/rows"}], "ungrouped_variables": ["x", "y", "M", "N", "p", "Q"], "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1915/", "name": "Nicholas Barker"}], "type": "question", "variablesTest": {"condition": "", "maxRuns": 100}, "parts": [{"showCorrectAnswer": true, "showFeedbackIcon": true, "notationStyles": ["plain", "en", "si-en"], "minValue": "{ans()}", "correctAnswerStyle": "plain", "type": "numberentry", "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "correctAnswerFraction": false, "maxValue": "{ans()}", "mustBeReduced": false, "allowFractions": false, "scripts": {}, "marks": 1}], "metadata": {"licence": "None specified", "description": "

I created this question, and every other question in Multiple Integration, for my dissertation `Computer-Aided Assessment of Multiple Integration'.

"}, "functions": {"NY": {"definition": "var Y = Numbas.jme.unwrapValue(scope.variables.y);\nvar N = Numbas.jme.unwrapValue(scope.variables.n);\n\nNY = N[Y];\n\nreturn NY;", "type": "number", "language": "javascript", "parameters": []}, "domain": {"definition": "var X = Numbas.jme.unwrapValue(scope.variables.x);\nvar Y = Numbas.jme.unwrapValue(scope.variables.y);\nvar M = Numbas.jme.unwrapValue(scope.variables.m);\nvar N = Numbas.jme.unwrapValue(scope.variables.n);\n\nM[X+1]=0; M[X+2]=0;\nN[Y+1]=0; N[Y+2]=0;\n\nvar makeboard = Numbas.extensions.jsxgraph.makeBoard(\n '250px','250px', \n {boundingBox:[-3/2,N[Y]+1/2,M[X]+3/2,-3/4], \n axis:true, \n grid:true\n } ); // define how the graph is displayed\n\nvar board = makeboard.board; // generate the graph\n\nvar column1 = board.create('curve',\n [function(y){return M[1];},\n function(y){return y;},\n 0, N[Y]]);\nvar column2 = board.create('curve',\n [function(y){return M[2];},\n function(y){return y;},\n 0, N[Y]]);\nvar column3 = board.create('curve',\n [function(y){return M[3];},\n function(y){return y;},\n 0, N[Y]]);\nvar column4 = board.create('curve',\n [function(y){return M[X];},\n function(y){return y;},\n 0, N[Y]]);\n\nvar row1 = board.create('curve',\n [function(y){return y;},\n function(y){return N[1];},\n 0, M[X]]);\nvar row2 = board.create('curve',\n [function(y){return y;},\n function(y){return N[2];},\n 0, M[X]]);\nvar row3 = board.create('curve',\n [function(y){return y;},\n function(y){return N[3];},\n 0, M[X]]);\nvar row4 = board.create('curve',\n [function(y){return y;},\n function(y){return N[Y];},\n 0, M[X]]);\n\nvar Q = Numbas.jme.unwrapValue(scope.variables.q);\nfor (i = 1; i < X+1; i++) {\n for (j = 1; j < Y+1; j++) {\n p = Q[j][i] // random integer in [-9,9]\n var points = board.create('point', [-2,0],\n {label:{fontSize:15,\n offset:[(125/(M[X]+3))*(4+ M[i-1]+M[i] + 0.10*(M[i-1]-M[i])),\n (125/(N[Y]+5/4))*(N[j-1]+N[j])]}, name:p, fixed:true});\n }\n}\n\nreturn makeboard; // update the board", "type": "html", "language": "javascript", "parameters": []}, "MX": {"definition": "var X = Numbas.jme.unwrapValue(scope.variables.x);\nvar M = Numbas.jme.unwrapValue(scope.variables.m);\n\nMX = M[X];\n\nreturn MX;", "type": "number", "language": "javascript", "parameters": []}, "ans": {"definition": "var X = Numbas.jme.unwrapValue(scope.variables.x);\nvar Y = Numbas.jme.unwrapValue(scope.variables.y);\nvar Q = Numbas.jme.unwrapValue(scope.variables.q);\nvar M = Numbas.jme.unwrapValue(scope.variables.m);\nvar N = Numbas.jme.unwrapValue(scope.variables.n);\n\nans = 0;\nfor (i = 1; i < X+1; i++) {\n for (j = 1; j < Y+1; j++) {\n ans = (M[i]-M[i-1])*(N[j]-N[j-1])*Q[j][i] + ans\n }\n}\n\nreturn ans;", "type": "number", "language": "javascript", "parameters": []}}, "variables": {"n3": {"description": "", "definition": "N2+random(sn)", "name": "n3", "templateType": "anything", "group": "Spacing of columns/rows"}, "m4": {"description": "", "definition": "M3+random(sm)", "name": "m4", "templateType": "anything", "group": "Spacing of columns/rows"}, "n4": {"description": "", "definition": "N3+random(sn)", "name": "n4", "templateType": "anything", "group": "Spacing of columns/rows"}, "y": {"description": "", "definition": "random((5-X)..(6-X) except 1)", "name": "y", "templateType": "anything", "group": "Ungrouped variables"}, "x": {"description": "", "definition": "random(2..4#1)", "name": "x", "templateType": "randrange", "group": "Ungrouped variables"}, "n1": {"description": "", "definition": "random(sn)", "name": "n1", "templateType": "anything", "group": "Spacing of columns/rows"}, "m1": {"description": "", "definition": "random(sm)", "name": "m1", "templateType": "anything", "group": "Spacing of columns/rows"}, "m2": {"description": "", "definition": "M1+random(sm)", "name": "m2", "templateType": "anything", "group": "Spacing of columns/rows"}, "m3": {"description": "", "definition": "M2+random(sm)", "name": "m3", "templateType": "anything", "group": "Spacing of columns/rows"}, "sn": {"description": "", "definition": "1..5#1", "name": "sn", "templateType": "range", "group": "Spacing of columns/rows"}, "Q": {"description": "

x

", "definition": "matrix([0,random(p),random(p),random(p),random(p)],\n [0,random(p),random(p),random(p),random(p)],\n [0,random(p),random(p),random(p),random(p)],\n [0,random(p),random(p),random(p),random(p)],\n [0,0,0,0,0])", "name": "Q", "templateType": "anything", "group": "Ungrouped variables"}, "sm": {"description": "", "definition": "2..5#1", "name": "sm", "templateType": "range", "group": "Spacing of columns/rows"}, "p": {"description": "", "definition": "0..9#1", "name": "p", "templateType": "range", "group": "Ungrouped variables"}, "M": {"description": "", "definition": "vector(0,m1,m2,m3,m4)", "name": "M", "templateType": "anything", "group": "Ungrouped variables"}, "n2": {"description": "", "definition": "N1+random(sn)", "name": "n2", "templateType": "anything", "group": "Spacing of columns/rows"}, "N": {"description": "", "definition": "vector(0,n1,n2,n3,n4)", "name": "N", "templateType": "anything", "group": "Ungrouped variables"}}, "rulesets": {}, "advice": "

To calculate the integral of the first rectangle $[0, \\var{M[1]}]\\times[0, \\var{N[1]}]$ we just need to find its area and multiply by the value of $g$ inside it, because $g$ is constant.

\n

\$I_{1,1} = \\int_0^{ \\var{N[1]}}\\int_0^{ \\var{M[1]}} g(x,y)\\, \\mathrm{d}x\\,\\mathrm{d}y = \\var{M[1]} \\cdot \\var{N[1]} \\cdot \\var{Q[1][1]} = \\var{M[1]*N[1]*Q[1][1]} \$

\n

To integrate over the whole grid we integrate over every other rectangle and add all the results together.

\n

\\begin{align}
I =& I_{1,1} &&+ I_{1,2} &&+... \\\\
& \\int_0^{\\var{N[1]}}\\int_0^{\\var{M[1]}} g(x,y)\\, \\mathrm{d}x\\,\\mathrm{d}y &&+ \\int_0^{\\var{N[1]}}\\int_{\\var{M[1]}}^{\\var{M[2]}} g(x,y)\\, \\mathrm{d}x\\,\\mathrm{d}y &&+ ... \\\\
=& \\var{M[1]} \\cdot \\var{N[1]} \\cdot \\var{Q[1][1]}                                           &&+ ( \\var{M[2]}-\\var{M[1]}) \\cdot \\var{N[1]} \\cdot \\var{Q[1][2]}                                                                       &&+ ... \\\\
=& \\var{M[1]*N[1]*Q[1][1]}                                                                             &&+ \\simplify{{(M[2]-M[1])*N[1]*Q[1][2]}}                                                                                                         &&+ ... \\\\
=& {\\var{ans()}}
\\end{align}

"}], "pickingStrategy": "all-ordered"}], "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1915/", "name": "Nicholas Barker"}]}