// Numbas version: exam_results_page_options {"name": "joshua's copy of Jinhua's copy of Equation of a line 2", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"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',[-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,question,qd) {\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 ", "type": "html", "language": "javascript", "parameters": []}}, "ungrouped_variables": ["a", "b"], "name": "joshua's copy of Jinhua's copy of Equation of a line 2", "tags": ["equation of a line", "graphs", "jsxgraph", "Jsxgraph", "lines"], "preamble": {"css": "", "js": ""}, "advice": "\n

First Method.

\n

You 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$.

\n

So $b=\\var{b}$.

\n

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$.

\n

On rearranging we obtain $a=\\simplify[all,!collectNumbers]{{b}-{b-a}}=\\var{a}$.

\n

So $a=\\var{a}$.

\n

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$.

\n

So looking at the graph we immediately see that $b=\\var{b}$.

\n

$a$ is the gradient of the line and is given by the change from $(-1,\\var{b-a})$ to $(0,\\var{b})$:

\n

\$a=\\frac{\\text{Change in y}}{\\text{Change in x}}=\\frac{\\simplify[all,!collectNumbers]{({b-a}-{b})}}{-1-0}=\\var{a}\$

\n ", "rulesets": {}, "parts": [{"prompt": "

Input the gradient of the line

\n

Gradient $=$[[0]]

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"vsetrangepoints": 5, "expectedvariablenames": [], "checkingaccuracy": 0.001, "vsetrange": [0, 1], "showpreview": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "scripts": {}, "answer": "{a}", "marks": 1, "checkvariablenames": false, "checkingtype": "absdiff", "type": "jme"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}, {"prompt": "

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

\n

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

\n

\n

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"vsetrangepoints": 5, "expectedvariablenames": [], "checkingaccuracy": 0.001, "vsetrange": [0, 1], "showpreview": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "answersimplification": "all", "scripts": {}, "answer": "{a}x+{b}", "marks": 1, "checkvariablenames": false, "checkingtype": "absdiff", "type": "jme"}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "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

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(-3..3 except 0)", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "b": {"definition": "random(-6..6 except [0,a])", "templateType": "anything", "group": "Ungrouped variables", "name": "b", "description": ""}}, "metadata": {"notes": "\n \t\t

15/11/2013:

\n \t\t

Created.

\n \t\t", "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"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "joshua boddy", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/557/"}]}]}], "contributors": [{"name": "joshua boddy", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/557/"}]}