// Numbas version: exam_results_page_options {"name": "6. Step Function", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"rulesets": {}, "preamble": {"css": "", "js": ""}, "name": "6. Step Function", "variablesTest": {"maxRuns": 100, "condition": ""}, "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]}}]$.

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}

", "parts": [{"variableReplacements": [], "correctAnswerFraction": false, "maxValue": "{ans()}", "mustBeReduced": false, "showFeedbackIcon": true, "scripts": {}, "correctAnswerStyle": "plain", "type": "numberentry", "showCorrectAnswer": true, "notationStyles": ["plain", "en", "si-en"], "mustBeReducedPC": 0, "marks": 1, "variableReplacementStrategy": "originalfirst", "minValue": "{ans()}", "allowFractions": false}], "variable_groups": [{"name": "Spacing of columns/rows", "variables": ["sm", "sn", "m1", "m2", "m3", "m4", "n1", "n2", "n3", "n4"]}], "ungrouped_variables": ["x", "y", "M", "N", "p", "Q"], "variables": {"m1": {"definition": "random(sm)", "name": "m1", "description": "", "group": "Spacing of columns/rows", "templateType": "anything"}, "n4": {"definition": "N3+random(sn)", "name": "n4", "description": "", "group": "Spacing of columns/rows", "templateType": "anything"}, "n2": {"definition": "N1+random(sn)", "name": "n2", "description": "", "group": "Spacing of columns/rows", "templateType": "anything"}, "m4": {"definition": "M3+random(sm)", "name": "m4", "description": "", "group": "Spacing of columns/rows", "templateType": "anything"}, "p": {"definition": "0..9#1", "name": "p", "description": "", "group": "Ungrouped variables", "templateType": "range"}, "n3": {"definition": "N2+random(sn)", "name": "n3", "description": "", "group": "Spacing of columns/rows", "templateType": "anything"}, "Q": {"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", "description": "

x

", "group": "Ungrouped variables", "templateType": "anything"}, "m3": {"definition": "M2+random(sm)", "name": "m3", "description": "", "group": "Spacing of columns/rows", "templateType": "anything"}, "m2": {"definition": "M1+random(sm)", "name": "m2", "description": "", "group": "Spacing of columns/rows", "templateType": "anything"}, "M": {"definition": "vector(0,m1,m2,m3,m4)", "name": "M", "description": "", "group": "Ungrouped variables", "templateType": "anything"}, "N": {"definition": "vector(0,n1,n2,n3,n4)", "name": "N", "description": "", "group": "Ungrouped variables", "templateType": "anything"}, "y": {"definition": "random((5-X)..(6-X) except 1)", "name": "y", "description": "", "group": "Ungrouped variables", "templateType": "anything"}, "x": {"definition": "random(2..4#1)", "name": "x", "description": "", "group": "Ungrouped variables", "templateType": "randrange"}, "n1": {"definition": "random(sn)", "name": "n1", "description": "", "group": "Spacing of columns/rows", "templateType": "anything"}, "sn": {"definition": "1..5#1", "name": "sn", "description": "", "group": "Spacing of columns/rows", "templateType": "range"}, "sm": {"definition": "2..5#1", "name": "sm", "description": "", "group": "Spacing of columns/rows", "templateType": "range"}}, "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'.

"}, "extensions": ["jsxgraph"], "tags": [], "functions": {"ans": {"language": "javascript", "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;", "parameters": [], "type": "number"}, "NY": {"language": "javascript", "definition": "var Y = Numbas.jme.unwrapValue(scope.variables.y);\nvar N = Numbas.jme.unwrapValue(scope.variables.n);\n\nNY = N[Y];\n\nreturn NY;", "parameters": [], "type": "number"}, "MX": {"language": "javascript", "definition": "var X = Numbas.jme.unwrapValue(scope.variables.x);\nvar M = Numbas.jme.unwrapValue(scope.variables.m);\n\nMX = M[X];\n\nreturn MX;", "parameters": [], "type": "number"}, "domain": {"language": "javascript", "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", "parameters": [], "type": "html"}}, "type": "question", "contributors": [{"name": "Nicholas Barker", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1915/"}]}]}], "contributors": [{"name": "Nicholas Barker", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1915/"}]}