// Numbas version: exam_results_page_options {"metadata": {"licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International", "description": "

Looking at gradients and values for x and y for straight-line graphs

"}, "feedback": {"advicethreshold": 0, "showanswerstate": true, "intro": "", "showtotalmark": true, "feedbackmessages": [], "showactualmark": true, "allowrevealanswer": true}, "timing": {"timedwarning": {"action": "none", "message": ""}, "timeout": {"action": "none", "message": ""}, "allowPause": true}, "duration": 0, "name": "Linear graphs", "question_groups": [{"pickQuestions": 1, "name": "Group", "pickingStrategy": "all-ordered", "questions": [{"name": "Simon's copy of Gradient", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Rachel Staddon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/901/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}], "rulesets": {}, "tags": [], "statement": "

You are given the following straight-line graph equation:

\n

$y = \\simplify{{a}x + {b}}$

", "parts": [{"showCellAnswerState": true, "displayType": "radiogroup", "unitTests": [], "matrix": ["1", 0, 0, 0], "showFeedbackIcon": true, "distractors": ["", "", "", ""], "marks": 0, "scripts": {}, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "maxMarks": 0, "prompt": "

", "customMarkingAlgorithm": "", "customName": "", "minMarks": 0, "variableReplacements": [], "displayColumns": "1", "type": "1_n_2", "shuffleChoices": true, "choices": ["

$\\var{a}$

", "

$\\var{b}$

", "

$x$

", "

$y$

"], "extendBaseMarkingAlgorithm": true}, {"showCellAnswerState": true, "displayType": "radiogroup", "unitTests": [], "matrix": ["0", "1", 0, 0], "showFeedbackIcon": true, "distractors": ["", "", "", ""], "marks": 0, "scripts": {}, "useCustomName": false, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "maxMarks": 0, "prompt": "

What is the y-intercept?

", "customMarkingAlgorithm": "", "customName": "", "minMarks": 0, "variableReplacements": [], "displayColumns": "1", "type": "1_n_2", "shuffleChoices": true, "choices": ["

$\\var{a}$

", "

$\\var{b}$

", "

$x$

", "

$y$

In a straight-line graph the general equation is $y = mx + c$ where $c$ is the $y$-intercept and $m$ is the gradient.

\n

\n

In our example we have $y = \\simplify{{a}x + {b}}$. Therefore:

\n
\n
• the gradient is $\\var{a}$ since this is the coefficient of $x$ (the number in front of $x$)
• \n
• the $y$-intercept is $\\var{b}$
• \n
", "functions": {}, "variables": {"b": {"description": "", "templateType": "anything", "group": "Ungrouped variables", "definition": "random(-10..10 except a)", "name": "b"}, "a": {"description": "", "templateType": "anything", "group": "Ungrouped variables", "definition": "random(-10..10)", "name": "a"}}, "preamble": {"js": "", "css": ""}, "ungrouped_variables": ["a", "b"], "variablesTest": {"maxRuns": 100, "condition": ""}, "variable_groups": [], "metadata": {"description": "

Identifying the gradient from a straight-line graph equation y=mx+c

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "type": "question"}, {"name": "Simon's copy of Simon's copy of Calculating gradient", "extensions": [], "custom_part_types": [], "resources": [["question-resources/dydx.png", "/srv/numbas/media/question-resources/dydx.png"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Rachel Staddon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/901/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}], "rulesets": {}, "tags": [], "statement": "

A student is trying to find the gradient on the graph below.

\n

{image('resources/question-resources/dydx.png')}

\n

", "parts": [{"correctAnswerStyle": "plain", "unitTests": [], "strictPrecision": false, "showPrecisionHint": true, "showFeedbackIcon": true, "allowFractions": false, "mustBeReduced": false, "scripts": {}, "precision": "3", "useCustomName": false, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "maxValue": "grad", "prompt": "

If the difference of $y = \\var{dy}$, and the difference in $x = \\var{dx}$, calculate the gradient.

", "customMarkingAlgorithm": "", "customName": "", "precisionPartialCredit": 0, "mustBeReducedPC": 0, "variableReplacements": [], "precisionMessage": "You have not given your answer to the correct precision.", "type": "numberentry", "precisionType": "dp", "marks": 1, "extendBaseMarkingAlgorithm": true, "notationStyles": ["plain", "en", "si-en"], "minValue": "grad"}], "advice": "

\n

$\\frac{\\text{difference in }y}{\\text{difference in }x}$

\n

\n

Therefore in our example, gradient = $\\frac{\\text{difference in }y}{\\text{difference in }x}=\\frac{\\var{dy}}{\\var{dx}}=\\var{dy/dx}$

", "functions": {}, "variables": {"grad": {"description": "", "templateType": "anything", "group": "Ungrouped variables", "definition": "dy/dx", "name": "grad"}, "dx": {"description": "", "templateType": "anything", "group": "Ungrouped variables", "definition": "random(-2..25 except 0)", "name": "dx"}, "dy": {"description": "", "templateType": "anything", "group": "Ungrouped variables", "definition": "random(-5..20 except 0)", "name": "dy"}}, "preamble": {"js": "", "css": ""}, "ungrouped_variables": ["dy", "dx", "grad"], "variablesTest": {"maxRuns": 100, "condition": ""}, "variable_groups": [], "metadata": {"description": "

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "type": "question"}, {"name": "Simon's copy of Straight-line graph values", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Rachel Staddon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/901/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}], "variables": {"x4": {"group": "Ungrouped variables", "definition": "random(-5..5 except [x1,x2,x3])", "templateType": "anything", "description": "", "name": "x4"}, "c": {"group": "Ungrouped variables", "definition": "random(-10..10)", "templateType": "anything", "description": "", "name": "c"}, "x2": {"group": "Ungrouped variables", "definition": "random(-5..5 except x1)", "templateType": "anything", "description": "", "name": "x2"}, "y1": {"group": "Ungrouped variables", "definition": "(m*x1)+c", "templateType": "anything", "description": "", "name": "y1"}, "y3": {"group": "Ungrouped variables", "definition": "(m*x3)+c", "templateType": "anything", "description": "", "name": "y3"}, "x1": {"group": "Ungrouped variables", "definition": "random(-5..5)", "templateType": "anything", "description": "", "name": "x1"}, "y4": {"group": "Ungrouped variables", "definition": "(m*x4)+c", "templateType": "anything", "description": "", "name": "y4"}, "x3": {"group": "Ungrouped variables", "definition": "random(-5..5 except [x1,x2])", "templateType": "anything", "description": "", "name": "x3"}, "m": {"group": "Ungrouped variables", "definition": "random(-10..10)", "templateType": "anything", "description": "", "name": "m"}, "y2": {"group": "Ungrouped variables", "definition": "(m*x2)+c", "templateType": "anything", "description": "", "name": "y2"}}, "advice": "

(a)

\n

Substitute $x=\\var{x1}$ into the equation $y = \\simplify{{m}x + {c}}$

\n

Hence $y = \\var{m} \\times \\var{x1} + \\var{c}=\\var{m*x1+c}$

\n

\n

(b)

\n

Substitute $x=\\var{x2}$ into the equation $y = \\simplify{{m}x + {c}}$

\n

Hence $y = \\var{m} \\times \\var{x2} + \\var{c}=\\var{m*x2+c}$

\n

\n

(c)

\n

First make $x$ the subject of $y = \\simplify{{m}x + {c}}$

\n

Hence $x = \\frac{y-\\var{c}}{\\var{m}}$

\n

\n

Substituting your value of $y=\\var{y3}$ into the above equation gives:

\n

$x= \\frac{\\var{y3}-\\var{c}}{\\var{m}}=\\var{(y3-c)/m}$

\n

\n

(d)

\n

First make $x$ the subject of $y = \\simplify{{m}x + {c}}$

\n

Hence $x = \\frac{y-\\var{c}}{\\var{m}}$

\n

\n

Substituting your value of $y=\\var{y4}$ into the above equation gives:

\n

$x= \\frac{\\var{y4}-\\var{c}}{\\var{m}}=\\var{(y4-c)/m}$

Finding x and y values for straight line graphs

"}, "ungrouped_variables": ["m", "c", "x1", "y1", "x2", "y2", "x3", "y3", "x4", "y4"], "variablesTest": {"condition": "", "maxRuns": 100}, "parts": [{"maxValue": "y1", "showCorrectAnswer": true, "mustBeReduced": false, "allowFractions": false, "showFeedbackIcon": true, "minValue": "y1", "customName": "", "type": "numberentry", "mustBeReducedPC": 0, "extendBaseMarkingAlgorithm": true, "unitTests": [], "scripts": {}, "correctAnswerFraction": false, "showFractionHint": true, "variableReplacements": [], "marks": 1, "variableReplacementStrategy": "originalfirst", "notationStyles": ["plain", "en", "si-en"], "prompt": "

What is $y$ if $x = \\var{x1}$?

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

What is $y$ if $x = \\var{x2}$?

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

What is $x$ if $y = \\var{y3}$?

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

What is $x$ if $y = \\var{y4}$?

", "customMarkingAlgorithm": "", "useCustomName": false, "correctAnswerStyle": "plain"}], "statement": "

For the line $y = \\simplify{{m}x + {c}}$:

", "tags": [], "functions": {}, "rulesets": {}, "variable_groups": [], "preamble": {"css": "", "js": ""}, "type": "question"}, {"name": "Simon's copy of Terry's copy of Straight lines: one point gradient", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}, {"name": "Terry Young", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3130/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}], "metadata": {"licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International", "description": "

Given one point and the gradient determine the equation of the line.

"}, "variables": {"scale": {"group": "Ungrouped variables", "definition": "random(-1,1,2,-2)", "templateType": "anything", "name": "scale", "description": ""}, "rise": {"group": "Ungrouped variables", "definition": "if(run=2,random(1,3,5,7),if(run=3,random(1,2,4,5,7),if(run=5,random(1,2,3,4,6,7),if(run=7,random(1,2,3,4,5,6)))))", "templateType": "anything", "name": "rise", "description": ""}, "brun": {"group": "Ungrouped variables", "definition": "random(2,3,5,7)", "templateType": "anything", "name": "brun", "description": ""}, "b": {"group": "Ungrouped variables", "definition": "random(-12..5 except 0)", "templateType": "anything", "name": "b", "description": ""}, "bpoint_y": {"group": "Ungrouped variables", "definition": "bb+brise*bscale", "templateType": "anything", "name": "bpoint_y", "description": ""}, "bpoint_x": {"group": "Ungrouped variables", "definition": "brun*bscale", "templateType": "anything", "name": "bpoint_x", "description": ""}, "brise": {"group": "Ungrouped variables", "definition": "-if(brun=2,random(1,3,5,7),if(brun=3,random(1,2,4,5,7),if(brun=5,random(1,2,3,4,6,7),if(brun=7,random(1,2,3,4,5,6)))))", "templateType": "anything", "name": "brise", "description": ""}, "point_y": {"group": "Ungrouped variables", "definition": "b+rise*scale", "templateType": "anything", "name": "point_y", "description": ""}, "point_x": {"group": "Ungrouped variables", "definition": "run*scale", "templateType": "anything", "name": "point_x", "description": ""}, "bscale": {"group": "Ungrouped variables", "definition": "random(-2..2 except [0,scale])", "templateType": "anything", "name": "bscale", "description": ""}, "bb": {"group": "Ungrouped variables", "definition": "random(-5..12 except 0)", "templateType": "anything", "name": "bb", "description": ""}, "run": {"group": "Ungrouped variables", "definition": "random(2,3,5,7)", "templateType": "anything", "name": "run", "description": ""}}, "tags": [], "functions": {}, "preamble": {"css": "", "js": ""}, "advice": "

Substitute the $x$ and $y$ values of the point and the value for $m$ into the equation of a line $y=mx+c$, then solve to determine $c$. Now you have $m$ and $c$ so you can write the equation of the line in the form $y=mx+c$.

\n

\n

(a)

\n

To find the equation of the line through $(\\var{point_x},\\var{point_y})$ with a gradient of $\\frac{\\var{rise}}{\\var{run}}$:

\n

Take the point $(\\var{point_x},\\var{point_y})$ as $(x,y)$ and substitute this and the gradient into the equation $y=mx+c$.

\n

This gives $\\var{point_y}=\\frac{\\var{rise}}{\\var{run}}(\\var{point_x})+c$.

\n

Rearranging gives $c=\\var{point_y}-\\frac{\\var{rise}}{\\var{run}}(\\var{point_x})=\\var{point_y-(point_x*rise)/run}$

\n

Therefore the equation of the line is $y=\\simplify{{rise}/{run}x+{b}}$.

\n

\n

(b)

\n

To find the equation of the line through $(\\var{bpoint_x},\\var{bpoint_y})$ with a gradient of $\\frac{\\var{brise}}{\\var{brun}}$:

\n

Take the point $(\\var{bpoint_x},\\var{bpoint_y})$ as $(x,y)$ and substitute this and the gradient into the equation $y=mx+c$.

\n

This gives $\\var{bpoint_y}=\\frac{\\var{brise}}{\\var{brun}}(\\var{bpoint_x})+c$.

\n

Rearranging gives $c=\\var{bpoint_y}-\\frac{\\var{brise}}{\\var{brun}}(\\var{bpoint_x})=\\var{bpoint_y-(bpoint_x*brise)/brun}$

\n

Therefore the equation of the line is $y=\\simplify{{brise}/{brun}x+{bb}}$.

", "statement": "

In each part, find the equation of the straight-line graph in the form $y=mx+c$

", "parts": [{"showCorrectAnswer": true, "steps": [{"showCorrectAnswer": true, "marks": 0, "customMarkingAlgorithm": "", "variableReplacementStrategy": "originalfirst", "unitTests": [], "prompt": "

Substitute the $x$ and $y$ values of the point and the value for $m$ into the equation of a line $y=mx+c$, then solve to determine $c$. Now you have $m$ and $c$ so you can write the equation of the line in the form $y=mx+c$.

\n

\n

For example, suppose we had to find the equation of the line through $(2,3)$ with a gradient of $\\frac{1}{4}$:

\n

Take the point $(2,3)$ as $(x,y)$ and substitute this and the gradient into the equation $y=mx+c$. This gives $3=\\frac{1}{4}(2)+c$. Solving for $c$ gives $c=\\frac{5}{2}$. Therefore the equation of the line is $y=\\frac{1}{4}x+\\frac{5}{2}$.

\n

\n

\n

", "customName": "", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "showFeedbackIcon": true, "useCustomName": false, "type": "information", "scripts": {}}], "marks": 0, "stepsPenalty": "1", "customMarkingAlgorithm": "", "sortAnswers": false, "variableReplacementStrategy": "originalfirst", "unitTests": [], "gaps": [{"valuegenerators": [{"value": "", "name": "x"}], "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "unitTests": [], "checkVariableNames": true, "extendBaseMarkingAlgorithm": true, "checkingAccuracy": 0.001, "showPreview": true, "type": "jme", "scripts": {}, "showCorrectAnswer": true, "vsetRange": [0, 1], "marks": "2", "customMarkingAlgorithm": "", "answer": "{rise}/{run}*x+{b}", "failureRate": 1, "answerSimplification": "all", "customName": "", "variableReplacements": [], "showFeedbackIcon": true, "useCustomName": false, "vsetRangePoints": 5, "notallowed": {"strings": ["="], "showStrings": false, "message": "", "partialCredit": 0}}], "prompt": "

The line that passes through the point ({point_x},{point_y}) with a gradient of $\\simplify{{rise}/{run}}$

\n

$y=$ [[0]]

", "customName": "", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "showFeedbackIcon": true, "useCustomName": false, "type": "gapfill", "scripts": {}}, {"showCorrectAnswer": true, "marks": 0, "customMarkingAlgorithm": "", "sortAnswers": false, "variableReplacementStrategy": "originalfirst", "unitTests": [], "gaps": [{"valuegenerators": [{"value": "", "name": "x"}], "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "unitTests": [], "checkVariableNames": true, "extendBaseMarkingAlgorithm": true, "checkingAccuracy": 0.001, "showPreview": true, "type": "jme", "scripts": {}, "showCorrectAnswer": true, "vsetRange": [0, 1], "marks": "2", "customMarkingAlgorithm": "", "answer": "{brise}/{brun}*x+{bb}", "failureRate": 1, "answerSimplification": "all", "customName": "", "variableReplacements": [], "showFeedbackIcon": true, "useCustomName": false, "vsetRangePoints": 5, "notallowed": {"strings": ["="], "showStrings": false, "message": "", "partialCredit": 0}}], "prompt": "

The line that passes through the point ({bpoint_x},{bpoint_y}) with a gradient of $\\simplify{{brise}/{brun}}$

\n

$y=$ [[0]]

", "customName": "", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "showFeedbackIcon": true, "useCustomName": false, "type": "gapfill", "scripts": {}}], "ungrouped_variables": ["b", "run", "rise", "point_y", "point_x", "scale", "bb", "brun", "brise", "bscale", "bpoint_y", "bpoint_x"], "rulesets": {}, "variable_groups": [], "variablesTest": {"condition": "", "maxRuns": 100}, "type": "question"}, {"name": "Simon's copy of Equation of a line through two points - positive gradient", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Angharad Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/315/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Bradley Bush", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1521/"}, {"name": "Aiden McCall", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1592/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}], "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Use two points on a line graph to calculate the gradient and $y$-intercept and hence the equation of the straight line running through both points.

\n

The answer box for the third part plots the function which allows the student to check their answer against the graph before submitting.

\n

This particular example has a positive gradient.

"}, "variables": {"yb": {"group": "Ungrouped variables", "definition": "ya+random([2,4])", "templateType": "anything", "name": "yb", "description": ""}, "ya": {"group": "Ungrouped variables", "definition": "random(-4..2)", "templateType": "anything", "name": "ya", "description": ""}, "xa": {"group": "Ungrouped variables", "definition": "random(-4..-1)", "templateType": "anything", "name": "xa", "description": ""}, "m": {"group": "Ungrouped variables", "definition": "(ya-yb)/(xa-xb)", "templateType": "anything", "name": "m", "description": ""}, "c": {"group": "Ungrouped variables", "definition": "ya-m*xa", "templateType": "anything", "name": "c", "description": ""}, "xb": {"group": "Ungrouped variables", "definition": "xa+random([2,4] except -xa)", "templateType": "anything", "name": "xb", "description": ""}}, "tags": [], "functions": {"plotPoints": {"language": "javascript", "type": "html", "definition": "//point coordinate variables\nvar xa = Numbas.jme.unwrapValue(scope.variables.xa);\nvar xb = Numbas.jme.unwrapValue(scope.variables.xb);\nvar ya = Numbas.jme.unwrapValue(scope.variables.ya);\nvar yb = Numbas.jme.unwrapValue(scope.variables.yb);\nvar m = Numbas.jme.unwrapValue(scope.variables.m);\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\n\n//make board\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[Math.min(-1,xa-2),Math.max(2,yb+2,c+1),Math.max(2,xb+2),Math.min(-1,ya-2,c-1)],grid: true});\nvar board = div.board;\nquestion.board = board;\n\n//points (with nice colors)\nvar a = board.create('point',[xa,ya],{name: 'A', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow', fixed: true, showInfobox: true});\nvar b = board.create('point',[xb,yb],{name: 'B', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow',fixed: true, showInfobox: true});\n\n\n//ans(was tree) is defined at the end and nscope looks important\n//but they're both variables\n var ans;\n var nscope = new Numbas.jme.Scope([scope,{variables:{x:new Numbas.jme.types.TNum(0)}}]);\n//this is the beating heart of whatever plots the function,\n//I've changed this from being curve to functiongraph\n var line = board.create('functiongraph',[function(x){\nif(ans) {\n try {\nnscope.variables.x.value = x;\n var val = Numbas.jme.evaluate(ans,nscope).value;\n return val;\n }\n catch(e) {\nreturn 13;\n }\n}\nelse\n return 13;\n },-12,12]\n , {strokeColor:\"blue\",strokeWidth: 4} );\n \nvar correct_line = board.create('functiongraph',[function(x){ return m*x+c},-22,22], {strokeColor:\"green\",setLabelText:'mx+c',visible: false, strokeWidth: 4, highlightStrokeColor: 'green'} )\n\nquestion.lines = {\n l:line, c:correct_line\n}\n\n question.signals.on('HTMLAttached',function(e) {\nko.computed(function(){\nvar expr = question.parts[2].gaps[0].display.studentAnswer();\n\n//define ans as this \ntry {\n ans = Numbas.jme.compile(expr,scope);\n}\ncatch(e) {\n ans = null;\n}\nline.updateCurve();\ncorrect_line.updateCurve();\nboard.update();\n});\n });\n\n\nreturn div;", "parameters": []}, "correctPoints": {"language": "javascript", "type": "html", "definition": "//point coordinate variables\nvar xa = Numbas.jme.unwrapValue(scope.variables.xa);\nvar xb = Numbas.jme.unwrapValue(scope.variables.xb);\nvar ya = Numbas.jme.unwrapValue(scope.variables.ya);\nvar yb = Numbas.jme.unwrapValue(scope.variables.yb);\nvar m = Numbas.jme.unwrapValue(scope.variables.m);\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\n\n//make board\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[Math.min(-1,xa-2),Math.max(2,yb+2,c+1),Math.max(2,xb+2),Math.min(-1,ya-2,c-1)],grid: true});\nvar board = div.board;\nquestion.board = board;\n\n\n//points (with nice colors)\nvar a = board.create('point',[xa,ya],{name: 'A', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow', fixed: true, showInfobox: true});\nvar b = board.create('point',[xb,yb],{name: 'B', size: 7, fillColor: 'blue' , strokeColor: 'lightblue' , highlightFillColor: 'lightblue', highlightStrokeColor: 'yellow',fixed: true, showInfobox: true});\n\n\n//ans(was tree) is defined at the end and nscope looks important\n//but they're both variables\n\nvar correct_line = board.create('functiongraph',[function(x){ return m*x+c},-22,22], {strokeColor:\"green\",setLabelText:'mx+c',visible: true, strokeWidth: 4, highlightStrokeColor: 'green'} )\n\n\n\nquestion.signals.on('HTMLAttached',function(e) {\nko.computed(function(){\n//define ans as this \ncorrect_line.updateCurve();\nboard.update();\n});\n });\n\n\nreturn div;", "parameters": []}}, "preamble": {"css": "", "js": ""}, "advice": "

We find the equation of a straight line passing through two points by finding the gradient and the $y$-intercept of the line.

\n

#### (a)

\n

We can find the gradient ($m$) using the points $A = (x_1,y_1)=(\\var{xa},\\var{ya})$ and $B = (x_2,y_2)=(\\var{xb},\\var{yb})$.

\n

As the definition of gradient is the ratio of vertical change ($y_2-y_1$) to horizontal change ($x_2-x_1$).

\n

\\begin{align}
m &= \\frac{y_2-y_1}{x_2-x_1} \\\0.5em] &= \\frac{\\var{yb}-\\var{ya}}{\\var{xb}-\\var{xa}} \\\\[0.5em] &= \\frac{\\var{yb-ya}}{\\var{xb-xa}} \\\\[0.5em] &= \\var{m} \\end{align} \n \n #### (b) \n Rearranging the equation y=mx+c and substituting either of the points gives \n \\[c = y_1-mx_1 \\quad \\mathrm{or} \\quad c = y_2-mx_2 \\,\\text{.} \

\n

\n

For example, using point $A$:

\n

\\\begin{align} c &= y_1-mx_1 \\\\ &= \\var{ya}-\\var[fractionnumbers]{m}\\times\\var{xa} \\\\ & = \\simplify[fractionnumbers]{{ya-m*xa}}\\text{.} \\end{align} \

\n

\n

Similarly, we could have obtained the same value using point $B$:

\n

\\\begin{align} c &= y_2-mx_2 \\\\ &= \\var{yb}-\\var[fractionnumbers]{m}\\times\\var{xb} \\\\ & = \\simplify[fractionnumbers]{{yb-m*xb}}\\text{.} \\end{align} \

\n

\n

#### c)

\n

We can now substitute these values for $m$ and $c$ into $y=mx+c$  to get:

\n

\$y=\\simplify[!noLeadingMinus,fractionNumbers,unitFactor]{{m} x+ {c}}\\text{.}\$

\n

The green line drawn on the graph represents the above line equation.

\n

{correctPoints()}

", "statement": "

In this question we will identify the equation of the straight line passing through points  $A=(\\var{xa},\\var{ya})$ and  $B=(\\var{xb},\\var{yb})$ in the form $y = mx + c$.

\n

{plotPoints()}

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

Calculate the gradient, $m$, of the straight line between these two points.

\n

$m=$ [[0]]

\n

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

Use this gradient and the coordinates of the points to calculate the $y$-intercept, $c$.

\n

$c=$ [[0]]

", "customName": "", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "showFeedbackIcon": true, "useCustomName": false, "type": "gapfill", "scripts": {}}, {"showCorrectAnswer": true, "marks": 0, "customMarkingAlgorithm": "", "sortAnswers": false, "variableReplacementStrategy": "originalfirst", "unitTests": [], "gaps": [{"valuegenerators": [{"value": "", "name": "x"}], "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "unitTests": [], "checkVariableNames": true, "extendBaseMarkingAlgorithm": true, "checkingAccuracy": 0.001, "showPreview": true, "type": "jme", "scripts": {}, "showCorrectAnswer": true, "vsetRange": [0, 1], "marks": 1, "customMarkingAlgorithm": "", "answer": "{m}*x+{c}", "failureRate": 1, "answerSimplification": "fractionNumbers", "customName": "", "variableReplacements": [], "showFeedbackIcon": false, "useCustomName": false, "vsetRangePoints": 5, "notallowed": {"strings": ["c", "m"], "showStrings": false, "message": "

You must input your answer in the form y = mx +c where m and c are numbers.

", "partialCredit": 0}}], "prompt": "

Give the equation of the straight line through these points in the form $y=mx+c$.

\n

$\\displaystyle y=$ [[0]]

", "customName": "", "extendBaseMarkingAlgorithm": true, "variableReplacements": [], "showFeedbackIcon": true, "useCustomName": false, "type": "gapfill", "scripts": {"mark": {"order": "after", "script": "this.question.lines.l.setAttribute({strokeColor: this.credit==1 ? 'green' : 'red'});\nthis.question.lines.c.setAttribute({visible: this.credit==1});\n"}}}], "ungrouped_variables": ["xa", "xb", "ya", "yb", "m", "c"], "rulesets": {}, "variable_groups": [], "variablesTest": {"condition": "\n", "maxRuns": 100}, "type": "question"}]}], "percentPass": 0, "navigation": {"browse": true, "onleave": {"action": "none", "message": ""}, "showresultspage": "oncompletion", "showfrontpage": true, "reverse": true, "preventleave": true, "startpassword": "", "allowregen": true}, "showstudentname": true, "showQuestionGroupNames": false, "type": "exam", "contributors": [{"name": "Mark Hodds", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/510/"}, {"name": "Simon Thomas", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3148/"}], "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [["question-resources/dydx.png", "/srv/numbas/media/question-resources/dydx.png"]]}