// Numbas version: exam_results_page_options {"name": "Algebra: functions, approximate area under graph", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "name": "Algebra: functions, approximate area under graph", "ungrouped_variables": ["a", "b", "c", "x0", "x", "fx", "total"], "metadata": {"description": "

Graphs are given with areas underneath them shaded. The area of the shaded regions are given and from this the value of various integrals are to be deduced.

", "licence": "Creative Commons Attribution 4.0 International"}, "preamble": {"css": "", "js": ""}, "functions": {"plotgraph": {"definition": "// Shading under a graph! This functions plots a graph of y = a(x-r1)(x-r2)\n// It creates the board, sets it up, then returns an\n// HTML div tag containing the board.\n\n\n// Max and min x and y values for the axis.\nvar xmin = -2;\nvar xmax = 8;\nvar ymin = -60;\nvar ymax = 60;\n\n// First, make the JSXGraph board.\nvar div = Numbas.extensions.jsxgraph.makeBoard(\n '500px',\n '500px',\n {\n boundingBox: [xmin,ymax,xmax,ymin],\n axis: false,\n showNavigation: false,\n grid: false\n }\n);\n\n\n\n// div.board is the object created by JSXGraph, which you use to \n// manipulate elements\nvar board = div.board; \n\n// create the x-axis.\nvar xaxis = board.create('line',[[0,0],[1,0]], { strokeColor: 'black', fixed: true});\nvar xticks = board.create('ticks',[xaxis,1],{\n drawLabels: true,\n label: {offset: [-4, -10]},\n minorTicks: 1\n});\n\n// create the y-axis\nvar yaxis = board.create('line',[[0,0],[0,1]], { strokeColor: 'black', fixed: true });\nvar yticks = board.create('ticks',[yaxis,10],{\ndrawLabels: true,\nlabel: {offset: [-20, 0]},\nminorTicks: 0\n});\n\n\n\n// This function shades in the area below the graph of f\n// between the x values x1 and x2\n\nvar shade = function(f,x1,x2,colour,opacity) {\n var dataX1 = [x1,x1];\n var dataY1 = [0,f(x1)];\n\n var dataX2 = [];\n var dataY2 = [];\n for (var i = x1; i <= x2; i = i+0.1) {\n dataX2.push(i);\n dataY2.push(f(i));\n }\n\n var dataX3 = [x2,x2];\n var dataY3 = [f(x2),0];\n\n dataX = dataX1.concat(dataX2).concat(dataX3);\n dataY = dataY1.concat(dataY2).concat(dataY3);\n\nvar shading = board.create('curve', [dataX,dataY],{strokeWidth:0, fillColor:colour, fillOpacity:opacity});\n\nreturn shading;\n}\n\n\n//Define your functions\nvar f = function(x) {\n return a*(x-b)*(c-x);\n}\n\n\nvar f1 = function(x) {\n return a*(c-4-b)*(c-c+4);\n}\n\nvar f2 = function(x) {\n return a*(c-3-b)*(c-c+3);\n}\n\nvar f3 = function(x) {\n return a*(c-2-b)*(c-c+2);\n}\n\nvar f4 = function(x) {\n return a*(c-1-b)*(c-c+1);\n}\n\n\n\n//Plot the graph and do shading\nboard.create('functiongraph', [f]);\n\n\n\nswitch(num) {\n case 1:\n shade(f,c-2,c+2, 'red',0.2);\n break;\n case 2:\n for (i = 0; i < 8; i++) { \n var g = function(x) {\n return a*(c-(2-0.5*i)-b)*(c-(c-(2-0.5*i))); //defining horizontal function for ith column\n }\n if (i%2 == 0) { \n shade(g,c-(2-0.5*i),c-(2-0.5*(i+1)), 'blue',0.2); //shading ith column blue if i even\n } else {\n shade(g,c-(2-0.5*i),c-(2-0.5*(i+1)), 'green',0.6); // shading ith column green if i odd\n }\n } \n board.create('ellipse',[[c-2,f(c-2)+0.995],[c-2,f(c-2)-0.995],[c-2,f(c-2)+1]],{color:'black'});\n //brd.create('circle',[[c-4,f(c-4)],0.1],{color:'black'}); //adding a point\n board.create('text',[c-2,a*(c-2-b)*(c-c+2)+3,'A']);\n board.create('ellipse',[[c-1.5,f(c-1.5)+0.995],[c-1.5,f(c-1.5)-0.995],[c-1.5,f(c-1.5)+1]],{color:'black'});\n board.create('text',[c-1.5,a*(c-1.5-b)*(c-c+1.5)+3,'B']);\n break;\n}\n \n\n\nreturn div;", "parameters": [["a", "number"], ["b", "number"], ["c", "number"], ["num", "number"]], "type": "html", "language": "javascript"}}, "variables": {"b": {"description": "", "name": "b", "templateType": "anything", "definition": "random(-5..-2)", "group": "Ungrouped variables"}, "c": {"description": "", "name": "c", "templateType": "anything", "definition": "x0+2", "group": "Ungrouped variables"}, "total": {"description": "", "name": "total", "templateType": "anything", "definition": "sum(fx)*0.5", "group": "Ungrouped variables"}, "x0": {"description": "", "name": "x0", "templateType": "anything", "definition": "random(1..2)", "group": "Ungrouped variables"}, "fx": {"description": "", "name": "fx", "templateType": "anything", "definition": "vector(map(abs(a*(x[j]-b)*(c-x[j])),j,0..7))\n\n ", "group": "Ungrouped variables"}, "a": {"description": "", "name": "a", "templateType": "anything", "definition": "random(3)", "group": "Ungrouped variables"}, "x": {"description": "", "name": "x", "templateType": "anything", "definition": "[x0,x0+0.5,x0+1,x0+1.5,x0+2,x0+2.5,x0+3,x0+3.5]", "group": "Ungrouped variables"}}, "extensions": ["jsxgraph"], "parts": [{"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "type": "gapfill", "gaps": [{"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "type": "matrix", "tolerance": 0, "markPerCell": false, "correctAnswer": "matrix([x[0],fx[0]])", "unitTests": [], "showCorrectAnswer": true, "scripts": {}, "showFeedbackIcon": true, "customName": "", "marks": 1, "correctAnswerFractions": false, "numRows": 1, "adaptiveMarkingPenalty": 0, "useCustomName": false, "allowResize": false, "allowFractions": true, "numColumns": "2", "customMarkingAlgorithm": ""}, {"variableReplacements": [], "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "type": "matrix", "tolerance": 0, "markPerCell": false, "correctAnswer": "matrix([x[1],fx[1]])", "unitTests": [], "showCorrectAnswer": true, "scripts": {}, "showFeedbackIcon": true, "customName": "", "marks": 1, "correctAnswerFractions": false, "numRows": 1, "adaptiveMarkingPenalty": 0, "useCustomName": false, "allowResize": false, "allowFractions": true, "numColumns": "2", "customMarkingAlgorithm": ""}, {"customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "variableReplacementStrategy": "originalfirst", "showFractionHint": true, "variableReplacements": [], "showFeedbackIcon": true, "showCorrectAnswer": true, "adaptiveMarkingPenalty": 0, "useCustomName": false, "correctAnswerFraction": false, "allowFractions": true, "minValue": "{total}", "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "unitTests": [], "mustBeReducedPC": 0, "customName": "", "correctAnswerStyle": "plain", "scripts": {}, "maxValue": "{total}", "marks": "5", "mustBeReduced": false}], "prompt": "

Below is the graph of the function $v(t) =\\simplify{{a}(t-{b})*({c}-t)}$.  We would like to calculate the area of the shaded region.

\n

{plotgraph(a,b,c,1)}

\n

\n

You will learn how to do this in Maths 2 (using so-called integration), but for now we will just estimate the area. We do this by calculating the area of the strips in the diagram below:

\n

{plotgraph(a,b,c,2)}

\n

\n

To save you scrolling, the function was $v(t) =\\simplify{{a}(t-{b})*({c}-t)}$.

\n

(i) What are the coordinates of the points A and B?

\n

A. [[0]]

\n

B. [[1]]

\n

\n

(ii) Determine the total area of the strips. Do this by determining the area of each strip and adding them together. Remember to do simple estimates to check for big errors.

\n

Total area of columns  = [[2]]

", "unitTests": [], "showCorrectAnswer": true, "scripts": {}, "showFeedbackIcon": true, "customName": "", "sortAnswers": false, "marks": 0, "adaptiveMarkingPenalty": 0, "useCustomName": false, "customMarkingAlgorithm": ""}], "rulesets": {}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "

See Lecture 6.3 and Workshop 6.5 for background. The workshop contains a question similar to this but the lectures do not.

\n

It is easy to make a little mistake, and a single mistake will result in an incorrect answer.  As much as possible, find ways to check for mistakes e.g. you can make rough estimates of the length of each strip from the graph.

\n

(If you have studied integration before and you want a challenge, calculate the exact area of the original shaded region and check it is similar with this estimated value.)

", "statement": "

This is a calculator question.

", "tags": [], "contributors": [{"name": "Lovkush Agarwal", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1358/"}]}]}], "contributors": [{"name": "Lovkush Agarwal", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1358/"}]}