// Numbas version: exam_results_page_options {"name": "Gareth's copy of pasar variables Graphs I: Linear - 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": [{"functions": {"eqnline": {"definition": "//pasa la variable directamente\n var a = Numbas.jme.unwrapValue(scope.variables.a);\n var b = Numbas.jme.unwrapValue(scope.variables.b);\n var c = Numbas.jme.unwrapValue(scope.variables.c);\n\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,c],[1,0]], {fixed:true,name:'Line1',withLabel:true});\n var xticks = brd.create('ticks',[xas,2],{\n drawLabels: true,\n label: {offset: [-4, -10]},\n minorTicks: 0\n });\n var p = brd.create('point',[-3,1]); //punto movible\n//las tres stgtes crean puntos y recta\nvar p1 = brd.create('point',[-1,1], {name:'A',size:4});\nvar p2 = brd.create('point',[2,-1], {name:'B',size:4});\nvar li = brd.create('line',[\"A\",\"B\"], {strokeColor:'#00ff00',strokeWidth:2});\n// segmento por punto anteriores\nvar li2 = brd.create('line',[\"A\",\"B\"], \n {straightFirst:false, straightLast:false, strokeWidth:2, dash:2});\n//sin declarar puntos separadamente\nvar li3 = brd.create('line',[[-3,-2],[2,2]], {straightFirst:false, straightLast:false, strokeWidth:2});\n\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 ", "type": "html", "language": "javascript", "parameters": []}}, "ungrouped_variables": ["a", "b", "c"], "name": "Gareth's copy of pasar variables Graphs I: Linear - Line equation", "tags": [], "preamble": {"css": "", "js": ""}, "advice": "
First Method.
\nWe 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$
\nHence:
\n1) 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}}$.
Second Method.
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}\\]
For more help on line graphs click on this link.
", "rulesets": {}, "parts": [{"stepsPenalty": 0, "prompt": "Input the gradient of the line
\nGradient $=$[[0]]
", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "{a}", "minValue": "{a}", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}], "steps": [{"prompt": "To find the gradient:
\nIt 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.
", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "information"}], "scripts": {}, "marks": 0, "showCorrectAnswer": true, "type": "gapfill"}, {"stepsPenalty": 0, "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"}], "steps": [{"prompt": "To find the line equation in the form $y=ax+b$, you need to know:
\nSubstitute these values into the above equation to give the line equation of the graph.
", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "information"}], "scripts": {}, "marks": 0, "showCorrectAnswer": true, "type": "gapfill"}], "extensions": ["jsxgraph"], "statement": "{eqnline()}
\nThe above graph shows a line which has an equation of the form $y=ax+b$ where $a$ and $b$ are integers.
\nYou are given two points on the line as indicated on the diagram.
\n$(0,\\var{b}),\\;\\;(-1,\\var{b-a})$.
\nYour task is to input the equation of the line.
", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(-3..3 except 0)", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "c": {"definition": "0", "templateType": "anything", "group": "Ungrouped variables", "name": "c", "description": ""}, "b": {"definition": "random(-6..6 except [0,a])", "templateType": "anything", "group": "Ungrouped variables", "name": "b", "description": ""}}, "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"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Gareth Woods", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/978/"}]}]}], "contributors": [{"name": "Gareth Woods", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/978/"}]}