// Numbas version: finer_feedback_settings {"name": "Line", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"advice": "
(i) To find $f(\\var{x1})$, you start at $\\var{x1}$ on the $x$-axis, go up or down until you reach the blue line, and then look at the $y$-coordinate. This $y$-coordinate is the answer. In this question, after going up/down from $\\var{x1}$, we reach the $y$-coordinate $\\var{y1}$, so the answer is $f(\\var{x1})=\\var{y1}$.
\n(ii) There are two options. The first option (which is not efficient) is trial-and-error: pick some random value of $x$ and determine $f(x)$. If $f(x) = \\var{y2}$, then your pick is the answer. If not, then try a different value of $x$, hopefully getting closer and closer each time. The second (and better) option is to 'work backwards' - we know what $f(x)$ should be, which means we know what the $y$-coordinate should be. So start at $\\var{y2}$ on the $y$-axis, go left or right until you reach the blue line, and look at the $x$-coordinate. In this question, after going left/right from $\\var{y2}$, we reach the $x$-coordinate $\\var{x2}$, so this is the answer. You can check this is correct: what is $f(\\var{x2})$? It is $\\var{y2}$, as we wanted!
\n(iii) The $y$-intercept is the height at which the blue line touches the $y$-axis. In this question, the blue line crosses the $y$-axis at a height of $\\var{c}$, so the answer is $\\var{c}$.
\n(iv) To calculate the gradient, you choose two points which lie on the line, and calculate the change in height divided by the change in $x$. It does not matter which two points you choose, but to make it easier, you should pick points whose coordinates are easy to read. In this question, two points which are on the line are $(\\var{x1}, \\var{y1})$ and $(\\var{x2},\\var{y2})$. Then the change of height is $\\var{y2} - \\var{y1}$ and the change in $x$ is $\\var{x2} - \\var{x1}$. Dividing gives the answer $\\var{m}$, which is the number we want.
\n(v) The equation of a line can be written as $y = mx + c$. $m$ is the gradient and $c$ is the $y$-intercept. But we have calculated these two quantities in the previous two questions: the $y$-intercept was $\\var{c}$ and the gradient was $\\var{m}$. Replacing $m$ and $c$ with these numbers gives the equation $y= \\var{m}x + \\var{c}$, which is the answer.
\n(vi) This question is asking exactly the same thing as the question in (ii), but is phrased differently. This is because the definition of $f^{-1}$ is that it is the function which un-does what $f$ does. For example, we know that $f(\\var{x1})=\\var{y1}$ - therefore, automatically, $f^{-1}(\\var{y1})$ has to be $\\var{x1}$. Re-worded, $f$ maps $\\var{x1}$ to $\\var{y1}$, so because $f^{-1}$ un-does this, it means $f^{-1}$ maps $\\var{y1}$ back to $\\var{x1}$. Back to the question at hand, it asked what $f^{-1}(\\var{y2})$ is. By definition, this means we want to know what value of $x$ is needed to get $f(x) = \\var{y2}$, which is exactly what was asked in (ii).
", "variables": {"x1": {"definition": "random(5..20)", "templateType": "anything", "group": "Ungrouped variables", "name": "x1", "description": ""}, "y1": {"definition": "random(5..20)", "templateType": "anything", "group": "Ungrouped variables", "name": "y1", "description": ""}, "units": {"definition": "random(1..4)", "templateType": "anything", "group": "Ungrouped variables", "name": "units", "description": ""}, "y2": {"definition": "random(25..45 except y1)", "templateType": "anything", "group": "Ungrouped variables", "name": "y2", "description": ""}, "x2": {"definition": "random(25..45 except x1)", "templateType": "anything", "group": "Ungrouped variables", "name": "x2", "description": ""}, "unitList": {"definition": "[ \"mm\", \"cm\", \"m\", \"km\" ]", "templateType": "list of strings", "group": "Ungrouped variables", "name": "unitList", "description": "Units that are to be used for the question.
"}}, "functions": {"plotgraph": {"language": "javascript", "definition": "// This functions plots a line\n// It creates a board, sets it up, then returns an\n// HTML div tag containing the board.\n// Max and min x and y values for the axis.\nvar x_min = 0;\nvar x_max = 50;\nvar y_min = 0;\nvar y_max = 50;\n//TODO check whether these are necessary for larger graphs\nvar offset = 0.5;\nvar scale = 1;\nvar scaleOffset = offset*scale;\n\n//Browser compatibility\nJXG.Options.text.display = 'internal';\n\n// Make the JSXGraph board.\nvar div = Numbas.extensions.jsxgraph.makeBoard(\n '400px',\n '400px',\n {\n boundingBox: [x_min,y_max,x_max,y_min],\n axis: false,\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//Draw two points\nvar A = board.create('point', [x1, y1], \n {size:0, fixed:true,\n label:{offset: [-10,-10]}});\n\nvar B = board.create('point', [x2, y2], {size:2, fixed:false, face:'+'});\n\n//Draw a line between them\nvar AB = board.create('line',[A,B],{fixed:true, straightFirst:false, straightLast:false, strokeWidth: 1});\n\n//Calculate midpoint\n//TODO Check whether these are useful or not\nvar midABx = (A.X() + B.X())/2;\nvar midABy = (A.Y() + B.Y())/2;\n\ntextAB = board.create('text', \n [function () {return (A.X() + B.X())/2},\n function () {return ((A.Y() + B.Y())/2)+scaleOffset},\n function () {return +A.Dist(B).toFixed(1) + ''}],\n {fontSize:15, anchorX:'middle'});\n\nvar tRot = board.create('transform', \n [function () {return AB.getAngle()}, \n function () {return (A.X() + B.X())/2}, \n function () {return (A.Y() + B.Y())/2}],\n {type:'rotate'});\ntRot.bindTo(textAB);\n \nboard.update();\n\nreturn div;", "parameters": [["x1", "number"], ["x2", "number"], ["y1", "number"], ["y2", "number"]], "type": "html"}}, "tags": [], "metadata": {"description": "Draws a triangle based on 3 input points. Calcualtes length, area, perimeter, heights and internal angles
", "licence": "Creative Commons Attribution 4.0 International"}, "ungrouped_variables": ["x1", "x2", "y1", "y2", "unitList", "units"], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "Referring to the line below.
", "extensions": ["jsxgraph"], "parts": [{"showCorrectAnswer": true, "type": "gapfill", "prompt": "{plotgraph(x1,x2,y1,y2)}
\nAll units are in mmcmmkm
", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "scripts": {}, "marks": 0, "variableReplacements": []}], "variable_groups": [], "name": "Line", "rulesets": {}, "preamble": {"js": "", "css": ""}, "type": "question", "contributors": [{"name": "David Wishart", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1461/"}]}]}], "contributors": [{"name": "David Wishart", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1461/"}]}