// Numbas version: exam_results_page_options {"name": "Find equation of line (negative and fractions points)", "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": [{"variables": {"a": {"definition": "random(-5..5 except[ 0,-2,2])", "group": "Ungrouped variables", "templateType": "anything", "name": "a", "description": ""}, "b": {"definition": "random(-6..6 except [0,a])", "group": "Ungrouped variables", "templateType": "anything", "name": "b", "description": ""}}, "ungrouped_variables": ["a", "b"], "name": "Find equation of line (negative and fractions points)", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "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.

First Method.

\n

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

\n

Hence:

\n

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

\n

Second Method.

\n

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

\n

\n

For more help on line graphs click on this link.

", "variablesTest": {"condition": "", "maxRuns": 100}, "functions": {"eqnline": {"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',[-0.5,b-0.5*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 ", "language": "javascript", "parameters": [], "type": "html"}}, "variable_groups": [], "tags": [], "statement": "

{eqnline()}

\n

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

\n

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

\n

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

\n

Your task is to input the equation of the line.

", "preamble": {"css": "", "js": ""}, "parts": [{"showCorrectAnswer": true, "marks": 0, "gaps": [{"showFeedbackIcon": true, "marks": 1, "maxValue": "{a}", "scripts": {}, "allowFractions": false, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"], "extendBaseMarkingAlgorithm": true, "type": "numberentry", "useCustomName": false, "variableReplacementStrategy": "originalfirst", "correctAnswerStyle": "plain", "showCorrectAnswer": true, "mustBeReducedPC": 0, "adaptiveMarkingPenalty": 0, "minValue": "{a}", "correctAnswerFraction": false, "variableReplacements": [], "mustBeReduced": false, "unitTests": [], "customMarkingAlgorithm": "", "customName": ""}], "sortAnswers": false, "adaptiveMarkingPenalty": 0, "steps": [{"showCorrectAnswer": true, "marks": 0, "adaptiveMarkingPenalty": 0, "scripts": {}, "variableReplacements": [], "showFeedbackIcon": true, "unitTests": [], "prompt": "

To find the slope:

\n

\n

Slope = Rise/Run

\n

Given two points on the line $(x_1,y_1)$ and $(x_2,y_2)$ the slope is given by the formula below:

\n

Slope = $\\frac{y_2-y_1}{x_2-x_1}$

\n
\n
• Form a triangle using the line as shown in the image above
• \n
• The rise is how many units from the base of the triangle (perpendicular corner) up to the line along the y-axis
• \n
• The run is how many units from the base of the triangle (perpendicular corner) to the line along the x-axis.
• \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.

", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "customName": "", "type": "information", "useCustomName": false, "variableReplacementStrategy": "originalfirst"}], "scripts": {}, "stepsPenalty": 0, "variableReplacements": [], "showFeedbackIcon": true, "unitTests": [], "prompt": "

Input the slope of the line:

\n

slope $=$[[0]]

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

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

\n
\n
• The slope, $m$, as calculated above
• \n
• The y-intercept, $b$, where the line crosses the $y$-axis
• \n
\n

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

", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "customName": "", "type": "information", "useCustomName": false, "variableReplacementStrategy": "originalfirst"}], "scripts": {}, "stepsPenalty": 0, "variableReplacements": [], "showFeedbackIcon": true, "unitTests": [], "prompt": "

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

\n

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

\n

\n

", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "customName": "", "type": "gapfill", "useCustomName": false, "variableReplacementStrategy": "originalfirst"}], "rulesets": {}, "extensions": ["jsxgraph"], "contributors": [{"name": "Julie Crowley", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/113/"}, {"name": "Catherine Palmer", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/423/"}]}]}], "contributors": [{"name": "Julie Crowley", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/113/"}, {"name": "Catherine Palmer", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/423/"}]}