// Numbas version: exam_results_page_options {"name": "Using student input in a JSXGraph diagram", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {"eqnline": {"definition": "var div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',\n{boundingBox: [-13,16,13,-16],\n axis: false,\n showNavigation: false,\n grid: true\n});\n var board = div.board; // div.board is the object created by JSXGraph, which you use to manipulate elements\nvar xaxis = board.create('line',[[0,0],[1,0]], { strokeColor: 'black', fixed: true}); // create the x-axis.\nvar xticks = board.create('ticks',[xaxis,2],{ drawLabels: true, label: {offset: [-4, -10]}, minorTicks: 0});\nvar yaxis = board.create('line',[[0,0],[0,1]], { strokeColor: 'black', fixed: true }); // create the y-axis\nvar yticks = board.create('ticks',[yaxis,2],{drawLabels: true,label: {offset: [-20, 0]},minorTicks: 0});\n// create the static line based on the coefficients a and b\nvar line1 = board.create('line',[[0,b],[1,a+b]],{fixed:true, strokeWidth: 1});\nreturn div;", "type": "html", "language": "javascript", "parameters": [["a", "number"], ["b", "number"], ["x2", "number"], ["y2", "number"]]}}, "ungrouped_variables": ["a", "x2", "b", "y2"], "name": "Using student input in a JSXGraph diagram", "tags": [], "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\n", "rulesets": {}, "parts": [{"prompt": "

Write the equation of the line in the diagram. The line described by your equation will also be drawn on the diagram.

\n

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

", "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"}], "extensions": ["jsxgraph"], "statement": "

{eqnline(a,b,x2,y2)}

\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, $(0,\\var{b})$ and $(\\var{x2},\\var{y2})$, as indicated on the diagram.

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"a": {"definition": "random(-4..4 except 0)", "templateType": "anything", "group": "Ungrouped variables", "name": "a", "description": ""}, "x2": {"definition": "random(-3..3 except -1..1)", "templateType": "anything", "group": "Ungrouped variables", "name": "x2", "description": ""}, "b": {"definition": "random(-6..6 except [0,a])", "templateType": "anything", "group": "Ungrouped variables", "name": "b", "description": ""}, "y2": {"definition": "x2*a+b", "templateType": "anything", "group": "Ungrouped variables", "name": "y2", "description": ""}}, "metadata": {"description": "

There are copious comments in the definition of the function eqnline about the voodoo needed to have a JSXGraph diagram interact with the input box for a part.

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Marlon Arcila", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/321/"}]}]}], "contributors": [{"name": "Marlon Arcila", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/321/"}]}