// Numbas version: exam_results_page_options {"name": "Distance between two points", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": [], "advice": "

The distance between the points $(x_1,y_1)$ and $(x_2,y_2)$ is $\\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$ units. This is the simply the length of the hypotenuse of the right angled triangle given by Pythagoras' Theorem $c^2=a^2+b^2$.

\n

{diagram()}

\n

a) For the points $(\\var{x1},\\var{y1})$ and $(\\var{x2},\\var{y2})$ this is a distance of

\n

\\begin{align}\\sqrt{\\simplify[basic]{({x2}-{x1})^2+({y2}-{y1})^2}}&=\\sqrt{\\simplify[basic]{({x2-x1})^2+({y2-y1})^2}}\\\\&=\\sqrt{\\simplify[basic]{{(x2-x1)^2}+{(y2-y1)^2}}}\\\\&=\\sqrt{\\simplify[basic]{{(x2-x1)^2+(y2-y1)^2}}}\\\\&=\\var{triple[2]} \\quad \\text{units.}\\end{align}

\n

\n

b) For the points $(\\var{xa1},\\var{ya1})$ and $(\\var{xa2},\\var{ya2})$ this is a distance of

\n

\\begin{align}\\sqrt{\\simplify[basic]{({xa2}-{xa1})^2+({ya2}-{ya1})^2}}&=\\sqrt{\\simplify[basic]{({xa2-xa1})^2+({ya2-ya1})^2}}\\\\&=\\sqrt{\\simplify[basic]{{(xa2-xa1)^2}+{(ya2-ya1)^2}}}\\\\&=\\sqrt{\\simplify[basic]{{(xa2-xa1)^2+(ya2-ya1)^2}}} \\quad \\text{units.}\\end{align}

\n

", "functions": {"diagram": {"type": "html", "definition": "var div = Numbas.extensions.jsxgraph.makeBoard('600px','600px',{boundingBox:[-13,13,13,-13],grid:true,axis:false});\nvar board = div.board;\n\n// create the x-axis.\nvar xaxis = board.create('line',[[0,0],[1,0]], { strokeColor: 'black', fixed: true});\nvar xticks = board.create('ticks',[xaxis,2],{\n drawLabels: true,\n label: {offset: [-4, -10]},\n minorTicks: 0\n});\n\n// create the y-axis\nvar yaxis = board.create('line',[[0,0],[0,1]], { strokeColor: 'black', fixed: true });\nvar yticks = board.create('ticks',[yaxis,2],{\ndrawLabels: true,\nlabel: {offset: [-20, 0]},\nminorTicks: 0\n});\n\n\nx0 = Numbas.jme.unwrapValue(scope.variables.xa1);\ny0 = Numbas.jme.unwrapValue(scope.variables.ya1);\nx1 = Numbas.jme.unwrapValue(scope.variables.xa2);\ny1 = Numbas.jme.unwrapValue(scope.variables.ya2);\n\nboard.create('point',[x0,y0],{fixed:true,withLabel:false});\nboard.create('point',[x1,y1],{fixed:true,withLabel:false});\n\nvar vline = board.create('line',[[x0,y0],[x0,y1]], {straightFirst:false, straightLast:false, strokeWidth:2, fixed:true});\nvar hline = board.create('line',[[x0,y1],[x1,y1]], {straightFirst:false, straightLast:false, strokeWidth:2, fixed:true});\nvar dia = board.create('line',[[x0,y0],[x1,y1]], {straightFirst:false, straightLast:false, strokeWidth:2, fixed:true});\n\nvar rise = board.create('text',[x0+0.25,(y0+y1)/2,'b']);\nvar run = board.create('text',[(x0+x1)/2,y1-0.5,'a']);\nvar hyp = board.create('text',[(x0+x1)/2,(y0+y1)/2+0.5,'c']);\n\nreturn div;\n", "language": "javascript", "parameters": []}}, "ungrouped_variables": ["l", "xa1", "xa2", "ya1", "ya2", "dx", "dy", "x1", "y1", "x2", "y2", "triple"], "variablesTest": {"condition": "", "maxRuns": 100}, "variable_groups": [], "extensions": ["jsxgraph"], "name": "Distance between two points", "parts": [{"marks": 0, "scripts": {}, "prompt": "

The distance between the points $(\\var{x1},\\var{y1})$ and $(\\var{x2},\\var{y2})$ is  [[0]] units.

\n

\n

", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "type": "gapfill", "gaps": [{"marks": 1, "maxValue": "triple[2]", "notationStyles": ["plain", "en", "si-en"], "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": true, "minValue": "triple[2]", "scripts": {}, "showCorrectAnswer": true, "mustBeReduced": false, "showFeedbackIcon": true, "type": "numberentry", "allowFractions": true, "variableReplacements": [], "mustBeReducedPC": 0, "correctAnswerStyle": "plain"}], "variableReplacements": [], "showCorrectAnswer": true}, {"marks": 0, "scripts": {}, "prompt": "

The distance between the points $(\\var{xa1},\\var{ya1})$ and $(\\var{xa2},\\var{ya2})$ is  [[0]] units.

\n

\n

Note: For this question you can enter exact answers by using expressions such as sqrt(200) to indicate $\\sqrt{200}$.

", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "type": "gapfill", "gaps": [{"marks": 1, "checkingtype": "absdiff", "vsetrange": [0, 1], "variableReplacementStrategy": "originalfirst", "vsetrangepoints": 5, "checkvariablenames": false, "showpreview": true, "variableReplacements": [], "scripts": {}, "showCorrectAnswer": true, "showFeedbackIcon": true, "type": "jme", "expectedvariablenames": [], "answer": "sqrt({dx^2+dy^2})", "checkingaccuracy": 0.001}], "variableReplacements": [], "showCorrectAnswer": true}], "metadata": {"description": "

Calculate the midpoint of two points.

", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "rulesets": {}, "statement": "

Fill in the blanks.

", "variables": {"y1": {"definition": "l[6]", "description": "", "name": "y1", "group": "Ungrouped variables", "templateType": "anything"}, "dy": {"definition": "ya2-ya1", "description": "", "name": "dy", "group": "Ungrouped variables", "templateType": "anything"}, "y2": {"definition": "y1+random([-1,1])*triple[1]", "description": "", "name": "y2", "group": "Ungrouped variables", "templateType": "anything"}, "triple": {"definition": "random([[3, 4, 5], [5, 12, 13], [7, 24, 25], [8, 15, 17], [9, 40, 41], [11, 60, 61], [12, 35, 37], [16, 63, 65], [20, 21, 29], [20, 99, 101]])", "description": "", "name": "triple", "group": "Ungrouped variables", "templateType": "anything"}, "x2": {"definition": "x1+random([-1,1])*triple[0]", "description": "", "name": "x2", "group": "Ungrouped variables", "templateType": "anything"}, "ya2": {"definition": "l[3]", "description": "", "name": "ya2", "group": "Ungrouped variables", "templateType": "anything"}, "dx": {"definition": "xa2-xa1", "description": "", "name": "dx", "group": "Ungrouped variables", "templateType": "anything"}, "l": {"definition": "shuffle(-12..12)[0..8]", "description": "

l

", "name": "l", "group": "Ungrouped variables", "templateType": "anything"}, "ya1": {"definition": "l[2]", "description": "", "name": "ya1", "group": "Ungrouped variables", "templateType": "anything"}, "xa1": {"definition": "l[0]", "description": "", "name": "xa1", "group": "Ungrouped variables", "templateType": "anything"}, "xa2": {"definition": "l[1]", "description": "

xa

", "name": "xa2", "group": "Ungrouped variables", "templateType": "anything"}, "x1": {"definition": "l[4]", "description": "", "name": "x1", "group": "Ungrouped variables", "templateType": "anything"}}, "preamble": {"js": "", "css": ""}, "type": "question", "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}]}]}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}]}