// Numbas version: exam_results_page_options {"name": "Graph - Line equation", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [["question-resources/gradient_pic.gif", "/srv/numbas/media/question-resources/gradient_pic.gif"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "

{eqnline()}

\n

The above graph shows a line which has an equation of the form $y=ax+b$ where $a$ and $b$ are integers.

\n

You are given two points on the line as indicated on the diagram.

\n

$(0,\\var{b}),\\;\\;(-1,\\var{b-a})$.

\n

Your task is to input the equation of the line.

", "metadata": {"description": "

Given a graph of a line of the form $y=ax+b$ where $a$ and $b$ are integers, find the equation of the line. The y-intercept is given.

", "licence": "Creative Commons Attribution 4.0 International"}, "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"group": "Ungrouped variables", "description": "", "definition": "random(-3..3 except 0)", "name": "a", "templateType": "anything"}, "b": {"group": "Ungrouped variables", "description": "", "definition": "random(-6..6 except [0,a])", "name": "b", "templateType": "anything"}}, "functions": {"eqnline": {"type": "html", "parameters": [], "language": "javascript", "definition": "\n var a = Numbas.jme.unwrapValue(scope.variables.a);\n var b = Numbas.jme.unwrapValue(scope.variables.b);\n var div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',\n {boundingBox:[-13,13,13,-13],\n axis:false,\n showNavigation:false,\n grid:true});\n var brd = div.board; \n var xas = brd.create('line',[[0,0],[1,0]], { strokeColor: 'black',fixed:true});\n var xticks = brd.create('ticks',[xas,2],{\n drawLabels: true,\n label: {offset: [-4, -10]},\n minorTicks: 0\n });\n var yas = brd.create('line',[[0,0],[0,1]], { strokeColor: 'black',fixed:true});\n var yticks = brd.create('ticks',[yas,2],{\n drawLabels: true,\n label: {offset: [-20, 0]},\n minorTicks: 0\n });\n var li1=brd.create('line',[[0,b],[1,a+b]],{fixed:true});\n var p1=brd.create('point',[0,b],{fixed:true,size:1,name:''});\n //brd.create('text', [0.25, b, function(){ return '(' + p1.X()+','+p1.Y()+')'; }],{fontsize:15,isLabel:true});\n var p2=brd.create('point',[-1,b-a],{fixed:true,size:1,name:''});\n // brd.create('text', [-0.75, b-a, function(){ return '(' + p2.X()+','+p2.Y()+')'; }],{fontsize:15,isLabel:true});\n var tree;\n //x is the variable in the equation to be input\n var nscope = new Numbas.jme.Scope([scope,{variables:{x:new Numbas.jme.types.TNum(0)}}]);\n //create a functiongraph from the student input\n var curve = brd.create('functiongraph', [function(t){\n if(tree) {\n try {\n nscope.variables.x.value = t;\n //the user input is evaluated at x=t\n var val = Numbas.jme.evaluate(tree,nscope).value;\n return val;\n }\n catch(e) {\n return 0;\n }\n }\n else\n return 0;\n },-10,10],{strokeColor:'black'});\n //pick up the student answer and is parsed\n question.signals.on('HTMLAttached',function(e) {\n ko.computed(function(){\n var expr = question.parts[0].gaps[0].display.studentAnswer();\n try {\n tree = Numbas.jme.compile(expr,scope);\n }\n catch(e) {\n tree = null;\n }\n curve.updateCurve();\n brd.update();\n });\n }); \n return div;\n \n \n "}}, "tags": [], "extensions": ["jsxgraph"], "parts": [{"steps": [{"type": "information", "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": 0, "unitTests": [], "showFeedbackIcon": true, "variableReplacements": [], "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "prompt": "

To find the gradient:

\n

\n\n

It is important to count from the perpendicular corner of the triangle as this affects whether the value is positive or negative depending on which direction the line is in. This in turn gives either a positive or negative gradient.

", "showCorrectAnswer": true}], "type": "gapfill", "stepsPenalty": 0, "scripts": {}, "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "gaps": [{"type": "numberentry", "scripts": {}, "extendBaseMarkingAlgorithm": true, "maxValue": "{a}", "showFeedbackIcon": true, "correctAnswerFraction": false, "correctAnswerStyle": "plain", "customMarkingAlgorithm": "", "mustBeReduced": false, "variableReplacementStrategy": "originalfirst", "minValue": "{a}", "allowFractions": false, "marks": 1, "mustBeReducedPC": 0, "variableReplacements": [], "notationStyles": ["plain", "en", "si-en"], "unitTests": [], "showCorrectAnswer": true}], "customMarkingAlgorithm": "", "prompt": "

Input the gradient of the line:

\n

Gradient $=$[[0]]

", "variableReplacementStrategy": "originalfirst", "sortAnswers": false, "marks": 0, "variableReplacements": [], "unitTests": [], "showCorrectAnswer": true}, {"steps": [{"type": "information", "scripts": {}, "extendBaseMarkingAlgorithm": true, "marks": 0, "unitTests": [], "showFeedbackIcon": true, "variableReplacements": [], "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "prompt": "

To find the line equation in the form $y=ax+b$, you need to know:

\n\n

Substitute these values into the above equation to give the line equation of the graph.

", "showCorrectAnswer": true}], "type": "gapfill", "stepsPenalty": 0, "scripts": {}, "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "gaps": [{"type": "jme", "scripts": {}, "vsetRange": [0, 1], "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "showPreview": true, "answer": "{a}x+{b}", "customMarkingAlgorithm": "", "vsetRangePoints": 5, "variableReplacementStrategy": "originalfirst", "checkVariableNames": false, "checkingAccuracy": 0.001, "checkingType": "absdiff", "marks": 1, "expectedVariableNames": [], "variableReplacements": [], "failureRate": 1, "answerSimplification": "all", "unitTests": [], "showCorrectAnswer": true}], "customMarkingAlgorithm": "", "prompt": "

Hence, input the equation for the line in the diagram:

\n

$y=\\;$[[0]]

\n

\n

", "variableReplacementStrategy": "originalfirst", "sortAnswers": false, "marks": 0, "variableReplacements": [], "unitTests": [], "showCorrectAnswer": true}], "advice": "

First Method.

\n

We are given that the line goes through $(0,\\var{b})$ and $(-1,\\var{b-a})$ and the equation of the line is of the form $y=ax+b$

\n

Hence:

\n

1) At $x=0$ we have $y=\\var{b}$, and this gives $\\var{b}=a \\times 0 +b =b$   on putting $x=0$ into $y=ax+b$.
So $b=\\var{b}$.
2) At $x=-1$ we have $y=\\var{b-a}$, and this gives $\\var{b-a}=a \\times (-1) +b =\\simplify[all,!collectNumbers]{-a+{b}}$  on putting $x=-1$ into $y=ax+b$.
After rearranging we obtain $a=\\simplify[all,!collectNumbers]{{b}-{b-a}}=\\var{a}$. 
So $a=\\var{a}$.
So the equation of the line is $\\simplify{y={a}*x+{b}}$.

\n


Second Method.

\n

The equation $y=ax+b$ tells us that the graph crosses the $y$-axis (when $x=0$) at $y=b$.
So looking at the graph we immediately see that $b=\\var{b}$.
$a$ is the gradient of the line and is given by the change from $(-1,\\var{b-a})$ to $(0,\\var{b})$:
\\[a=\\frac{\\text{Change in y}}{\\text{Change in x}}=\\frac{\\simplify[all,!collectNumbers]{({b-a}-{b})}}{-1-0}=\\var{a}\\]

\n

\n

For more help on line graphs click on this link.

", "name": "Graph - Line equation", "rulesets": {}, "variable_groups": [], "preamble": {"css": "", "js": ""}, "ungrouped_variables": ["a", "b"], "type": "question", "contributors": [{"name": "Sarah Turner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/881/"}, {"name": "heike hoffmann", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2960/"}]}]}], "contributors": [{"name": "Sarah Turner", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/881/"}, {"name": "heike hoffmann", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2960/"}]}