// Numbas version: finer_feedback_settings {"name": "Graphing: two transformations", "metadata": {"description": "", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "duration": 0, "percentPass": 0, "showQuestionGroupNames": false, "shuffleQuestionGroups": false, "showstudentname": true, "question_groups": [{"name": "Group", "pickingStrategy": "all-ordered", "pickQuestions": 1, "questionNames": ["", "", "", ""], "variable_overrides": [[], [], [], []], "questions": [{"name": "Graphs: Two random transformations", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}], "tags": ["functions", "graphing", "graphs", "JSXgraph", "Jsxgraph", "jsxgraph", "transformations"], "metadata": {"description": "

Horizontal and vertical shifts and scales of a random cubic spline

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

The graph of a function $y=f(x)$ is shown below. Move the red points so the red curve represents $y=\\simplify[fractionNumbers,all]{{vsc}f({hsc}x+{hsh})+{vsh}}$.

", "advice": "", "rulesets": {"std": ["all", "fractionNumbers"]}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"recip": {"name": "recip", "group": "Ungrouped variables", "definition": "1/hsc", "description": "", "templateType": "anything", "can_override": false}, "hsc": {"name": "hsc", "group": "Ungrouped variables", "definition": "if(selector[3]=1,random(-2,-1,-0.5,0.5,2),1)", "description": "", "templateType": "anything", "can_override": false}, "maxx": {"name": "maxx", "group": "Ungrouped variables", "definition": "max(map(abs(a),a,xn)+5)+1", "description": "", "templateType": "anything", "can_override": false}, "maxy": {"name": "maxy", "group": "Ungrouped variables", "definition": "max(map(abs(a),a,yn)+5)+1", "description": "", "templateType": "anything", "can_override": false}, "xn": {"name": "xn", "group": "Ungrouped variables", "definition": "map((x-hsh)/hsc,x,xo)", "description": "

new transformed x values

", "templateType": "anything", "can_override": false}, "xo": {"name": "xo", "group": "Ungrouped variables", "definition": "list(-2..2)", "description": "

original x values

", "templateType": "anything", "can_override": false}, "yo": {"name": "yo", "group": "Ungrouped variables", "definition": "repeat(random(-5..5),5)", "description": "

the (random) original y values which relate to the x values

", "templateType": "anything", "can_override": false}, "yn": {"name": "yn", "group": "Ungrouped variables", "definition": "map(vsc*y+vsh,y,yo)", "description": "

new y values after the transformation

", "templateType": "anything", "can_override": false}, "hsh": {"name": "hsh", "group": "Ungrouped variables", "definition": "if(selector[1]=1,random(-3..3 except 0),0)", "description": "

horizontal shift

", "templateType": "anything", "can_override": false}, "selector": {"name": "selector", "group": "Ungrouped variables", "definition": "shuffle([0,0,1,1])", "description": "

order is ['vsh','hsh','vsc','hsc'] 1 is on 0 is off

", "templateType": "anything", "can_override": false}, "vsc": {"name": "vsc", "group": "Ungrouped variables", "definition": "if(selector[2]=1,random(-2,-1,-0.5,0.5,2),1)", "description": "", "templateType": "anything", "can_override": false}, "vsh": {"name": "vsh", "group": "Ungrouped variables", "definition": "if(selector[0]=1,random(-3..3#0.5 except 0),0)\n", "description": "

vertical shift

", "templateType": "anything", "can_override": false}, "yo4": {"name": "yo4", "group": "Ungrouped variables", "definition": "yo[4]", "description": "", "templateType": "anything", "can_override": false}, "yo3": {"name": "yo3", "group": "Ungrouped variables", "definition": "yo[3]", "description": "", "templateType": "anything", "can_override": false}, "yo2": {"name": "yo2", "group": "Ungrouped variables", "definition": "yo[2]", "description": "", "templateType": "anything", "can_override": false}, "yo1": {"name": "yo1", "group": "Ungrouped variables", "definition": "yo[1]", "description": "", "templateType": "anything", "can_override": false}, "yo0": {"name": "yo0", "group": "Ungrouped variables", "definition": "yo[0]", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["selector", "vsh", "hsh", "vsc", "hsc", "yo", "yn", "xo", "xn", "yo0", "yo1", "yo2", "yo3", "yo4", "maxx", "maxy", "recip"], "variable_groups": [], "functions": {}, "preamble": {"js": "function dragpoint_board() {\n var scope = question.scope;\n \n // var a = scope.variables.a.value;\n// var c = scope.variables.c.value;\n\n var yo0 = scope.variables.yo0.value;\n var yo1 = scope.variables.yo1.value;\n var yo2 = scope.variables.yo2.value;\n var yo3 = scope.variables.yo3.value; \n var yo4 = scope.variables.yo4.value;\n \n var maxx = scope.variables.maxx.value;\n var maxy = scope.variables.maxy.value;\n \n var div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-maxx,maxy,maxx,-maxy],grid:true});\nquestion.display.html.querySelector('#dragpoint').append(div);\n \n var board = div.board;\n \n \n //create stationary points\n \n var op0 = board.create('point',[-2,yo0],{name:'',fixed:true,size:2,color:'black'});\n var op1 = board.create('point',[-1,yo1],{name:'',fixed:true,size:2,color:'black'});\n var op2 = board.create('point',[0,yo2],{name:'',fixed:true,size:2,color:'black'});\n var op3 = board.create('point',[1,yo3],{name:'',fixed:true,size:2,color:'black'});\n var op4 = board.create('point',[2,yo4],{name:'',fixed:true,size:2,color:'black'});\n \n \n //create draggable points\n //why are there are a cloine under each one?\n var np0 = board.create('point',[-2,yo0],{name:'A',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np1 = board.create('point',[-1,yo1],{name:'B',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np2 = board.create('point',[0,yo2],{name:'C',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np3 = board.create('point',[1,yo3],{name:'D',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np4 = board.create('point',[2,yo4],{name:'E',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n \n \n \n \n //shorthand to evaluate a mathematical expression to a number\n function evaluate(expression) {\n try {\n var val = Numbas.jme.evaluate(expression,question.scope);\n return Numbas.jme.unwrapValue(val);\n }\n catch(e) {\n // if there's an error, return no number\n return NaN;\n }\n }\n \n // set up points array\n var num_points = 5;\n var points = [np0, np1, np2, np3, np4];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n // calculate initial coordinates\n // var x = i-(num_points-1)/2;\n \n // create an invisible vertical line for the point to slide along\n // var line = board.create('line',[[x,0],[x,1]],{visible: false});\n \n // create the point\n // var point = points[i] = board.create(\n // 'point',\n // [i-(num_points-1)/2,0],\n // {\n // name:'',\n // size:2,\n // snapSizeY: 0.25, // the point will snap to y-coordinates which are multiples of 0.1\n // snapSizeX: 0.25,\n // snapToGrid: true\n // }\n // );\n \n var point = points[i];\n \n var x=point[0];\n var y=point[1];\n \n // the contents of the input box for this point\n var xstudentAnswer = question.parts[0].gaps[2*i].display.studentAnswer;\n var ystudentAnswer = question.parts[0].gaps[2*i+1].display.studentAnswer;\n \n // watch the student's input and reposition the point when it changes. \n ko.computed(function() {\n x = evaluate(xstudentAnswer());\n y = evaluate(ystudentAnswer());\n if(!(isNaN(x)) && !(isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n point.moveTo([x,y],100);\n }\n });\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var x = Numbas.math.niceNumber(point.X());\n var y = Numbas.math.niceNumber(point.Y());\n xstudentAnswer(x);\n ystudentAnswer(y);\n });\n \n }\n \n // create each point\n for(var i=0;i\n

The point $A$ was $(-2,\\var{yo0})$ but it is now $\\big($[[0]],[[1]]$\\big)$.
The point $B$ was $(-1,\\var{yo1})$ but it is now $\\big($[[2]],[[3]]$\\big)$.
The point $C$ was $(0,\\var{yo2})$ but it is now $\\big($[[4]],[[5]]$\\big)$.
The point $D$ was $(1,\\var{yo3})$ but it is now $\\big($[[6]],[[7]]$\\big)$.
The point $E$ was $(2,\\var{yo4})$ but it is now $\\big($[[8]],[[9]]$\\big)$.

\n", "stepsPenalty": "10", "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Suppose $x$ is substituted into the function $y=\\simplify[fractionNumbers,all]{{vsc}f({hsc}x+{hsh})+{vsh}}$. The order of operations tells us what happens to $x$, in our case the order is, $\\var{hsc}$ multiplies it , $\\var{hsh}$ is added to it, $f$ is taken of it, $\\var{vsc}$ multiplies it , $\\var{vsh}$ is added to it. In this case there are two transformations to the original graph.

\n

The $\\simplify[fractionNumbers,all]{f({hsc}x)}$ part of the equation means that to get the same $y$ value as the original graph the new $x$ value will have to be $2$ times $-2$ times the negative of half of the negative half of what it was before (so that when you multiply the new $x$ value by $\\var{hsc}$ you get the old one).

\n

Since the $x$ value is displayed in the horizontal direction, this means we stretch or scale horizontally by a factor of $\\simplify[fractionNumbers,all]{{recip}}$, or in other words, compress horizontally by a factor of $\\simplify[fractionNumbers,all]{{hsc}}$.

\n

The $\\simplify[fractionNumbers,all]{f(x+{hsh})}$ means that to get the same $y$ value as the original graph the new $x$ value will have to be $\\var{abs(hsh)}$ units less greater than the original $x$ value (so that when you add $\\var{hsh}$ to subtract $\\var{abs(hsh)}$ from the new $x$ value you get the old one).

\n

Since the $x$ value is displayed in the horizontal direction, this means we shift horizontally $\\var{abs(hsh)}$ units to the left right.

\n

Notice that $x$ is modified twice before the function $f$ gets to it. If we want the same $y$ value as the original graph we need to feed $f$ with the same input. Let $x_o$ be the old $x$ value and $x_n$ be the new $x$ value. To get the same $y$ values we want $f(x_o)=\\simplify[fractionNumbers, unitFactor, basic]{f({hsc}x_n+{hsh})}$, that is, we require $x_o=\\simplify[fractionNumbers, unitFactor, basic]{{hsc}x_n+{hsh}}$. Rearranging we see $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$. 

\n

Method one (shift then scale)

\n

The equation $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$ tells us to take the old $x$ subtract $\\var{abs(hsh)}$ from it, add $\\var{abs(hsh)}$ to it, then multiply this result by $\\simplify[fractionNumbers, unitFactor, basic]{{recip}}$.

\n

Method two (scale then shift)

\n

We could rewrite $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$ as $x_n=\\simplify[fractionNumbers, unitFactor, basic, simplifyFractions]{{recip}*x_o-{hsh/hsc}}$. This equation tells us to take the old $x$ value, multiply it by $\\simplify[fractionNumbers, unitFactor, basic]{{recip}}$, then subtract $\\simplify[fractionNumbers, unitFactor, basic]{{abs(hsh/hsc)}}$ from this result. add $\\simplify[fractionNumbers, unitFactor, basic]{{abs(hsh/hsc)}}$ to this result.

\n

\n

The $\\simplify[fractionNumbers,all]{{vsc}f(x)}$ part of the equation means that the $y$ value of each point on the graph will be $\\var{vsc}$ times what they were before.  half of what they were before. a negative half of what they were before. the negative of what it was before. Since the $y$ value is displayed in the vertical direction, this means we stretch or scale vertically by a factor of $\\var{vsc}$. 

\n

The $\\simplify[fractionNumbers,all]{f(x)+{vsh}}$ part of the equation means that the $y$ value of each point on the graph will be $\\var{abs(vsh)}$ units greater less than they were before. Since the $y$ value is displayed in the vertical direction, this means we shift vertically by $\\var{vsh}$ units.

"}], "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[0]", "maxValue": "xn[0]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[0]", "maxValue": "yn[0]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[1]", "maxValue": "xn[1]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[1]", "maxValue": "yn[1]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[2]", "maxValue": "xn[2]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[2]", "maxValue": "yn[2]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[3]", "maxValue": "xn[3]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[3]", "maxValue": "yn[3]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[4]", "maxValue": "xn[4]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[4]", "maxValue": "yn[4]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Graphs: Two random transformations", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}], "tags": ["functions", "graphing", "graphs", "JSXgraph", "Jsxgraph", "jsxgraph", "transformations"], "metadata": {"description": "

Horizontal and vertical shifts and scales of a random cubic spline

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

The graph of a function $y=f(x)$ is shown below. Move the red points so the red curve represents $y=\\simplify[fractionNumbers,all]{{vsc}f({hsc}x+{hsh})+{vsh}}$.

", "advice": "", "rulesets": {"std": ["all", "fractionNumbers"]}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"recip": {"name": "recip", "group": "Ungrouped variables", "definition": "1/hsc", "description": "", "templateType": "anything", "can_override": false}, "hsc": {"name": "hsc", "group": "Ungrouped variables", "definition": "if(selector[3]=1,random(-2,-1,-0.5,0.5,2),1)", "description": "", "templateType": "anything", "can_override": false}, "maxx": {"name": "maxx", "group": "Ungrouped variables", "definition": "max(map(abs(a),a,xn)+5)+1", "description": "", "templateType": "anything", "can_override": false}, "maxy": {"name": "maxy", "group": "Ungrouped variables", "definition": "max(map(abs(a),a,yn)+5)+1", "description": "", "templateType": "anything", "can_override": false}, "xn": {"name": "xn", "group": "Ungrouped variables", "definition": "map((x-hsh)/hsc,x,xo)", "description": "

new transformed x values

", "templateType": "anything", "can_override": false}, "xo": {"name": "xo", "group": "Ungrouped variables", "definition": "list(-2..2)", "description": "

original x values

", "templateType": "anything", "can_override": false}, "yo": {"name": "yo", "group": "Ungrouped variables", "definition": "repeat(random(-5..5),5)", "description": "

the (random) original y values which relate to the x values

", "templateType": "anything", "can_override": false}, "yn": {"name": "yn", "group": "Ungrouped variables", "definition": "map(vsc*y+vsh,y,yo)", "description": "

new y values after the transformation

", "templateType": "anything", "can_override": false}, "hsh": {"name": "hsh", "group": "Ungrouped variables", "definition": "if(selector[1]=1,random(-3..3 except 0),0)", "description": "

horizontal shift

", "templateType": "anything", "can_override": false}, "selector": {"name": "selector", "group": "Ungrouped variables", "definition": "shuffle([0,0,1,1])", "description": "

order is ['vsh','hsh','vsc','hsc'] 1 is on 0 is off

", "templateType": "anything", "can_override": false}, "vsc": {"name": "vsc", "group": "Ungrouped variables", "definition": "if(selector[2]=1,random(-2,-1,-0.5,0.5,2),1)", "description": "", "templateType": "anything", "can_override": false}, "vsh": {"name": "vsh", "group": "Ungrouped variables", "definition": "if(selector[0]=1,random(-3..3#0.5 except 0),0)\n", "description": "

vertical shift

", "templateType": "anything", "can_override": false}, "yo4": {"name": "yo4", "group": "Ungrouped variables", "definition": "yo[4]", "description": "", "templateType": "anything", "can_override": false}, "yo3": {"name": "yo3", "group": "Ungrouped variables", "definition": "yo[3]", "description": "", "templateType": "anything", "can_override": false}, "yo2": {"name": "yo2", "group": "Ungrouped variables", "definition": "yo[2]", "description": "", "templateType": "anything", "can_override": false}, "yo1": {"name": "yo1", "group": "Ungrouped variables", "definition": "yo[1]", "description": "", "templateType": "anything", "can_override": false}, "yo0": {"name": "yo0", "group": "Ungrouped variables", "definition": "yo[0]", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["selector", "vsh", "hsh", "vsc", "hsc", "yo", "yn", "xo", "xn", "yo0", "yo1", "yo2", "yo3", "yo4", "maxx", "maxy", "recip"], "variable_groups": [], "functions": {}, "preamble": {"js": "function dragpoint_board() {\n var scope = question.scope;\n \n // var a = scope.variables.a.value;\n// var c = scope.variables.c.value;\n\n var yo0 = scope.variables.yo0.value;\n var yo1 = scope.variables.yo1.value;\n var yo2 = scope.variables.yo2.value;\n var yo3 = scope.variables.yo3.value; \n var yo4 = scope.variables.yo4.value;\n \n var maxx = scope.variables.maxx.value;\n var maxy = scope.variables.maxy.value;\n \n var div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-maxx,maxy,maxx,-maxy],grid:true});\nquestion.display.html.querySelector('#dragpoint').append(div);\n \n var board = div.board;\n \n \n //create stationary points\n \n var op0 = board.create('point',[-2,yo0],{name:'',fixed:true,size:2,color:'black'});\n var op1 = board.create('point',[-1,yo1],{name:'',fixed:true,size:2,color:'black'});\n var op2 = board.create('point',[0,yo2],{name:'',fixed:true,size:2,color:'black'});\n var op3 = board.create('point',[1,yo3],{name:'',fixed:true,size:2,color:'black'});\n var op4 = board.create('point',[2,yo4],{name:'',fixed:true,size:2,color:'black'});\n \n \n //create draggable points\n //why are there are a cloine under each one?\n var np0 = board.create('point',[-2,yo0],{name:'A',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np1 = board.create('point',[-1,yo1],{name:'B',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np2 = board.create('point',[0,yo2],{name:'C',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np3 = board.create('point',[1,yo3],{name:'D',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np4 = board.create('point',[2,yo4],{name:'E',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n \n \n \n \n //shorthand to evaluate a mathematical expression to a number\n function evaluate(expression) {\n try {\n var val = Numbas.jme.evaluate(expression,question.scope);\n return Numbas.jme.unwrapValue(val);\n }\n catch(e) {\n // if there's an error, return no number\n return NaN;\n }\n }\n \n // set up points array\n var num_points = 5;\n var points = [np0, np1, np2, np3, np4];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n // calculate initial coordinates\n // var x = i-(num_points-1)/2;\n \n // create an invisible vertical line for the point to slide along\n // var line = board.create('line',[[x,0],[x,1]],{visible: false});\n \n // create the point\n // var point = points[i] = board.create(\n // 'point',\n // [i-(num_points-1)/2,0],\n // {\n // name:'',\n // size:2,\n // snapSizeY: 0.25, // the point will snap to y-coordinates which are multiples of 0.1\n // snapSizeX: 0.25,\n // snapToGrid: true\n // }\n // );\n \n var point = points[i];\n \n var x=point[0];\n var y=point[1];\n \n // the contents of the input box for this point\n var xstudentAnswer = question.parts[0].gaps[2*i].display.studentAnswer;\n var ystudentAnswer = question.parts[0].gaps[2*i+1].display.studentAnswer;\n \n // watch the student's input and reposition the point when it changes. \n ko.computed(function() {\n x = evaluate(xstudentAnswer());\n y = evaluate(ystudentAnswer());\n if(!(isNaN(x)) && !(isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n point.moveTo([x,y],100);\n }\n });\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var x = Numbas.math.niceNumber(point.X());\n var y = Numbas.math.niceNumber(point.Y());\n xstudentAnswer(x);\n ystudentAnswer(y);\n });\n \n }\n \n // create each point\n for(var i=0;i\n

The point $A$ was $(-2,\\var{yo0})$ but it is now $\\big($[[0]],[[1]]$\\big)$.
The point $B$ was $(-1,\\var{yo1})$ but it is now $\\big($[[2]],[[3]]$\\big)$.
The point $C$ was $(0,\\var{yo2})$ but it is now $\\big($[[4]],[[5]]$\\big)$.
The point $D$ was $(1,\\var{yo3})$ but it is now $\\big($[[6]],[[7]]$\\big)$.
The point $E$ was $(2,\\var{yo4})$ but it is now $\\big($[[8]],[[9]]$\\big)$.

\n", "stepsPenalty": "10", "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Suppose $x$ is substituted into the function $y=\\simplify[fractionNumbers,all]{{vsc}f({hsc}x+{hsh})+{vsh}}$. The order of operations tells us what happens to $x$, in our case the order is, $\\var{hsc}$ multiplies it , $\\var{hsh}$ is added to it, $f$ is taken of it, $\\var{vsc}$ multiplies it , $\\var{vsh}$ is added to it. In this case there are two transformations to the original graph.

\n

The $\\simplify[fractionNumbers,all]{f({hsc}x)}$ part of the equation means that to get the same $y$ value as the original graph the new $x$ value will have to be $2$ times $-2$ times the negative of half of the negative half of what it was before (so that when you multiply the new $x$ value by $\\var{hsc}$ you get the old one).

\n

Since the $x$ value is displayed in the horizontal direction, this means we stretch or scale horizontally by a factor of $\\simplify[fractionNumbers,all]{{recip}}$, or in other words, compress horizontally by a factor of $\\simplify[fractionNumbers,all]{{hsc}}$.

\n

The $\\simplify[fractionNumbers,all]{f(x+{hsh})}$ means that to get the same $y$ value as the original graph the new $x$ value will have to be $\\var{abs(hsh)}$ units less greater than the original $x$ value (so that when you add $\\var{hsh}$ to subtract $\\var{abs(hsh)}$ from the new $x$ value you get the old one).

\n

Since the $x$ value is displayed in the horizontal direction, this means we shift horizontally $\\var{abs(hsh)}$ units to the left right.

\n

Notice that $x$ is modified twice before the function $f$ gets to it. If we want the same $y$ value as the original graph we need to feed $f$ with the same input. Let $x_o$ be the old $x$ value and $x_n$ be the new $x$ value. To get the same $y$ values we want $f(x_o)=\\simplify[fractionNumbers, unitFactor, basic]{f({hsc}x_n+{hsh})}$, that is, we require $x_o=\\simplify[fractionNumbers, unitFactor, basic]{{hsc}x_n+{hsh}}$. Rearranging we see $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$. 

\n

Method one (shift then scale)

\n

The equation $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$ tells us to take the old $x$ subtract $\\var{abs(hsh)}$ from it, add $\\var{abs(hsh)}$ to it, then multiply this result by $\\simplify[fractionNumbers, unitFactor, basic]{{recip}}$.

\n

Method two (scale then shift)

\n

We could rewrite $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$ as $x_n=\\simplify[fractionNumbers, unitFactor, basic, simplifyFractions]{{recip}*x_o-{hsh/hsc}}$. This equation tells us to take the old $x$ value, multiply it by $\\simplify[fractionNumbers, unitFactor, basic]{{recip}}$, then subtract $\\simplify[fractionNumbers, unitFactor, basic]{{abs(hsh/hsc)}}$ from this result. add $\\simplify[fractionNumbers, unitFactor, basic]{{abs(hsh/hsc)}}$ to this result.

\n

\n

The $\\simplify[fractionNumbers,all]{{vsc}f(x)}$ part of the equation means that the $y$ value of each point on the graph will be $\\var{vsc}$ times what they were before.  half of what they were before. a negative half of what they were before. the negative of what it was before. Since the $y$ value is displayed in the vertical direction, this means we stretch or scale vertically by a factor of $\\var{vsc}$. 

\n

The $\\simplify[fractionNumbers,all]{f(x)+{vsh}}$ part of the equation means that the $y$ value of each point on the graph will be $\\var{abs(vsh)}$ units greater less than they were before. Since the $y$ value is displayed in the vertical direction, this means we shift vertically by $\\var{vsh}$ units.

"}], "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[0]", "maxValue": "xn[0]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[0]", "maxValue": "yn[0]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[1]", "maxValue": "xn[1]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[1]", "maxValue": "yn[1]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[2]", "maxValue": "xn[2]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[2]", "maxValue": "yn[2]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[3]", "maxValue": "xn[3]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[3]", "maxValue": "yn[3]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[4]", "maxValue": "xn[4]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[4]", "maxValue": "yn[4]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Graphs: Two random transformations", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}], "tags": ["functions", "graphing", "graphs", "JSXgraph", "Jsxgraph", "jsxgraph", "transformations"], "metadata": {"description": "

Horizontal and vertical shifts and scales of a random cubic spline

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

The graph of a function $y=f(x)$ is shown below. Move the red points so the red curve represents $y=\\simplify[fractionNumbers,all]{{vsc}f({hsc}x+{hsh})+{vsh}}$.

", "advice": "", "rulesets": {"std": ["all", "fractionNumbers"]}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"recip": {"name": "recip", "group": "Ungrouped variables", "definition": "1/hsc", "description": "", "templateType": "anything", "can_override": false}, "hsc": {"name": "hsc", "group": "Ungrouped variables", "definition": "if(selector[3]=1,random(-2,-1,-0.5,0.5,2),1)", "description": "", "templateType": "anything", "can_override": false}, "maxx": {"name": "maxx", "group": "Ungrouped variables", "definition": "max(map(abs(a),a,xn)+5)+1", "description": "", "templateType": "anything", "can_override": false}, "maxy": {"name": "maxy", "group": "Ungrouped variables", "definition": "max(map(abs(a),a,yn)+5)+1", "description": "", "templateType": "anything", "can_override": false}, "xn": {"name": "xn", "group": "Ungrouped variables", "definition": "map((x-hsh)/hsc,x,xo)", "description": "

new transformed x values

", "templateType": "anything", "can_override": false}, "xo": {"name": "xo", "group": "Ungrouped variables", "definition": "list(-2..2)", "description": "

original x values

", "templateType": "anything", "can_override": false}, "yo": {"name": "yo", "group": "Ungrouped variables", "definition": "repeat(random(-5..5),5)", "description": "

the (random) original y values which relate to the x values

", "templateType": "anything", "can_override": false}, "yn": {"name": "yn", "group": "Ungrouped variables", "definition": "map(vsc*y+vsh,y,yo)", "description": "

new y values after the transformation

", "templateType": "anything", "can_override": false}, "hsh": {"name": "hsh", "group": "Ungrouped variables", "definition": "if(selector[1]=1,random(-3..3 except 0),0)", "description": "

horizontal shift

", "templateType": "anything", "can_override": false}, "selector": {"name": "selector", "group": "Ungrouped variables", "definition": "shuffle([0,0,1,1])", "description": "

order is ['vsh','hsh','vsc','hsc'] 1 is on 0 is off

", "templateType": "anything", "can_override": false}, "vsc": {"name": "vsc", "group": "Ungrouped variables", "definition": "if(selector[2]=1,random(-2,-1,-0.5,0.5,2),1)", "description": "", "templateType": "anything", "can_override": false}, "vsh": {"name": "vsh", "group": "Ungrouped variables", "definition": "if(selector[0]=1,random(-3..3#0.5 except 0),0)\n", "description": "

vertical shift

", "templateType": "anything", "can_override": false}, "yo4": {"name": "yo4", "group": "Ungrouped variables", "definition": "yo[4]", "description": "", "templateType": "anything", "can_override": false}, "yo3": {"name": "yo3", "group": "Ungrouped variables", "definition": "yo[3]", "description": "", "templateType": "anything", "can_override": false}, "yo2": {"name": "yo2", "group": "Ungrouped variables", "definition": "yo[2]", "description": "", "templateType": "anything", "can_override": false}, "yo1": {"name": "yo1", "group": "Ungrouped variables", "definition": "yo[1]", "description": "", "templateType": "anything", "can_override": false}, "yo0": {"name": "yo0", "group": "Ungrouped variables", "definition": "yo[0]", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["selector", "vsh", "hsh", "vsc", "hsc", "yo", "yn", "xo", "xn", "yo0", "yo1", "yo2", "yo3", "yo4", "maxx", "maxy", "recip"], "variable_groups": [], "functions": {}, "preamble": {"js": "function dragpoint_board() {\n var scope = question.scope;\n \n // var a = scope.variables.a.value;\n// var c = scope.variables.c.value;\n\n var yo0 = scope.variables.yo0.value;\n var yo1 = scope.variables.yo1.value;\n var yo2 = scope.variables.yo2.value;\n var yo3 = scope.variables.yo3.value; \n var yo4 = scope.variables.yo4.value;\n \n var maxx = scope.variables.maxx.value;\n var maxy = scope.variables.maxy.value;\n \n var div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-maxx,maxy,maxx,-maxy],grid:true});\nquestion.display.html.querySelector('#dragpoint').append(div);\n \n var board = div.board;\n \n \n //create stationary points\n \n var op0 = board.create('point',[-2,yo0],{name:'',fixed:true,size:2,color:'black'});\n var op1 = board.create('point',[-1,yo1],{name:'',fixed:true,size:2,color:'black'});\n var op2 = board.create('point',[0,yo2],{name:'',fixed:true,size:2,color:'black'});\n var op3 = board.create('point',[1,yo3],{name:'',fixed:true,size:2,color:'black'});\n var op4 = board.create('point',[2,yo4],{name:'',fixed:true,size:2,color:'black'});\n \n \n //create draggable points\n //why are there are a cloine under each one?\n var np0 = board.create('point',[-2,yo0],{name:'A',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np1 = board.create('point',[-1,yo1],{name:'B',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np2 = board.create('point',[0,yo2],{name:'C',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np3 = board.create('point',[1,yo3],{name:'D',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np4 = board.create('point',[2,yo4],{name:'E',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n \n \n \n \n //shorthand to evaluate a mathematical expression to a number\n function evaluate(expression) {\n try {\n var val = Numbas.jme.evaluate(expression,question.scope);\n return Numbas.jme.unwrapValue(val);\n }\n catch(e) {\n // if there's an error, return no number\n return NaN;\n }\n }\n \n // set up points array\n var num_points = 5;\n var points = [np0, np1, np2, np3, np4];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n // calculate initial coordinates\n // var x = i-(num_points-1)/2;\n \n // create an invisible vertical line for the point to slide along\n // var line = board.create('line',[[x,0],[x,1]],{visible: false});\n \n // create the point\n // var point = points[i] = board.create(\n // 'point',\n // [i-(num_points-1)/2,0],\n // {\n // name:'',\n // size:2,\n // snapSizeY: 0.25, // the point will snap to y-coordinates which are multiples of 0.1\n // snapSizeX: 0.25,\n // snapToGrid: true\n // }\n // );\n \n var point = points[i];\n \n var x=point[0];\n var y=point[1];\n \n // the contents of the input box for this point\n var xstudentAnswer = question.parts[0].gaps[2*i].display.studentAnswer;\n var ystudentAnswer = question.parts[0].gaps[2*i+1].display.studentAnswer;\n \n // watch the student's input and reposition the point when it changes. \n ko.computed(function() {\n x = evaluate(xstudentAnswer());\n y = evaluate(ystudentAnswer());\n if(!(isNaN(x)) && !(isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n point.moveTo([x,y],100);\n }\n });\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var x = Numbas.math.niceNumber(point.X());\n var y = Numbas.math.niceNumber(point.Y());\n xstudentAnswer(x);\n ystudentAnswer(y);\n });\n \n }\n \n // create each point\n for(var i=0;i\n

The point $A$ was $(-2,\\var{yo0})$ but it is now $\\big($[[0]],[[1]]$\\big)$.
The point $B$ was $(-1,\\var{yo1})$ but it is now $\\big($[[2]],[[3]]$\\big)$.
The point $C$ was $(0,\\var{yo2})$ but it is now $\\big($[[4]],[[5]]$\\big)$.
The point $D$ was $(1,\\var{yo3})$ but it is now $\\big($[[6]],[[7]]$\\big)$.
The point $E$ was $(2,\\var{yo4})$ but it is now $\\big($[[8]],[[9]]$\\big)$.

\n", "stepsPenalty": "10", "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Suppose $x$ is substituted into the function $y=\\simplify[fractionNumbers,all]{{vsc}f({hsc}x+{hsh})+{vsh}}$. The order of operations tells us what happens to $x$, in our case the order is, $\\var{hsc}$ multiplies it , $\\var{hsh}$ is added to it, $f$ is taken of it, $\\var{vsc}$ multiplies it , $\\var{vsh}$ is added to it. In this case there are two transformations to the original graph.

\n

The $\\simplify[fractionNumbers,all]{f({hsc}x)}$ part of the equation means that to get the same $y$ value as the original graph the new $x$ value will have to be $2$ times $-2$ times the negative of half of the negative half of what it was before (so that when you multiply the new $x$ value by $\\var{hsc}$ you get the old one).

\n

Since the $x$ value is displayed in the horizontal direction, this means we stretch or scale horizontally by a factor of $\\simplify[fractionNumbers,all]{{recip}}$, or in other words, compress horizontally by a factor of $\\simplify[fractionNumbers,all]{{hsc}}$.

\n

The $\\simplify[fractionNumbers,all]{f(x+{hsh})}$ means that to get the same $y$ value as the original graph the new $x$ value will have to be $\\var{abs(hsh)}$ units less greater than the original $x$ value (so that when you add $\\var{hsh}$ to subtract $\\var{abs(hsh)}$ from the new $x$ value you get the old one).

\n

Since the $x$ value is displayed in the horizontal direction, this means we shift horizontally $\\var{abs(hsh)}$ units to the left right.

\n

Notice that $x$ is modified twice before the function $f$ gets to it. If we want the same $y$ value as the original graph we need to feed $f$ with the same input. Let $x_o$ be the old $x$ value and $x_n$ be the new $x$ value. To get the same $y$ values we want $f(x_o)=\\simplify[fractionNumbers, unitFactor, basic]{f({hsc}x_n+{hsh})}$, that is, we require $x_o=\\simplify[fractionNumbers, unitFactor, basic]{{hsc}x_n+{hsh}}$. Rearranging we see $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$. 

\n

Method one (shift then scale)

\n

The equation $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$ tells us to take the old $x$ subtract $\\var{abs(hsh)}$ from it, add $\\var{abs(hsh)}$ to it, then multiply this result by $\\simplify[fractionNumbers, unitFactor, basic]{{recip}}$.

\n

Method two (scale then shift)

\n

We could rewrite $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$ as $x_n=\\simplify[fractionNumbers, unitFactor, basic, simplifyFractions]{{recip}*x_o-{hsh/hsc}}$. This equation tells us to take the old $x$ value, multiply it by $\\simplify[fractionNumbers, unitFactor, basic]{{recip}}$, then subtract $\\simplify[fractionNumbers, unitFactor, basic]{{abs(hsh/hsc)}}$ from this result. add $\\simplify[fractionNumbers, unitFactor, basic]{{abs(hsh/hsc)}}$ to this result.

\n

\n

The $\\simplify[fractionNumbers,all]{{vsc}f(x)}$ part of the equation means that the $y$ value of each point on the graph will be $\\var{vsc}$ times what they were before.  half of what they were before. a negative half of what they were before. the negative of what it was before. Since the $y$ value is displayed in the vertical direction, this means we stretch or scale vertically by a factor of $\\var{vsc}$. 

\n

The $\\simplify[fractionNumbers,all]{f(x)+{vsh}}$ part of the equation means that the $y$ value of each point on the graph will be $\\var{abs(vsh)}$ units greater less than they were before. Since the $y$ value is displayed in the vertical direction, this means we shift vertically by $\\var{vsh}$ units.

"}], "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[0]", "maxValue": "xn[0]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[0]", "maxValue": "yn[0]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[1]", "maxValue": "xn[1]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[1]", "maxValue": "yn[1]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[2]", "maxValue": "xn[2]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[2]", "maxValue": "yn[2]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[3]", "maxValue": "xn[3]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[3]", "maxValue": "yn[3]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[4]", "maxValue": "xn[4]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[4]", "maxValue": "yn[4]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}, {"name": "Graphs: Two random transformations", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}], "tags": ["functions", "graphing", "graphs", "JSXgraph", "Jsxgraph", "jsxgraph", "transformations"], "metadata": {"description": "

Horizontal and vertical shifts and scales of a random cubic spline

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

The graph of a function $y=f(x)$ is shown below. Move the red points so the red curve represents $y=\\simplify[fractionNumbers,all]{{vsc}f({hsc}x+{hsh})+{vsh}}$.

", "advice": "", "rulesets": {"std": ["all", "fractionNumbers"]}, "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true, "j": false}, "constants": [], "variables": {"recip": {"name": "recip", "group": "Ungrouped variables", "definition": "1/hsc", "description": "", "templateType": "anything", "can_override": false}, "hsc": {"name": "hsc", "group": "Ungrouped variables", "definition": "if(selector[3]=1,random(-2,-1,-0.5,0.5,2),1)", "description": "", "templateType": "anything", "can_override": false}, "maxx": {"name": "maxx", "group": "Ungrouped variables", "definition": "max(map(abs(a),a,xn)+5)+1", "description": "", "templateType": "anything", "can_override": false}, "maxy": {"name": "maxy", "group": "Ungrouped variables", "definition": "max(map(abs(a),a,yn)+5)+1", "description": "", "templateType": "anything", "can_override": false}, "xn": {"name": "xn", "group": "Ungrouped variables", "definition": "map((x-hsh)/hsc,x,xo)", "description": "

new transformed x values

", "templateType": "anything", "can_override": false}, "xo": {"name": "xo", "group": "Ungrouped variables", "definition": "list(-2..2)", "description": "

original x values

", "templateType": "anything", "can_override": false}, "yo": {"name": "yo", "group": "Ungrouped variables", "definition": "repeat(random(-5..5),5)", "description": "

the (random) original y values which relate to the x values

", "templateType": "anything", "can_override": false}, "yn": {"name": "yn", "group": "Ungrouped variables", "definition": "map(vsc*y+vsh,y,yo)", "description": "

new y values after the transformation

", "templateType": "anything", "can_override": false}, "hsh": {"name": "hsh", "group": "Ungrouped variables", "definition": "if(selector[1]=1,random(-3..3 except 0),0)", "description": "

horizontal shift

", "templateType": "anything", "can_override": false}, "selector": {"name": "selector", "group": "Ungrouped variables", "definition": "shuffle([0,0,1,1])", "description": "

order is ['vsh','hsh','vsc','hsc'] 1 is on 0 is off

", "templateType": "anything", "can_override": false}, "vsc": {"name": "vsc", "group": "Ungrouped variables", "definition": "if(selector[2]=1,random(-2,-1,-0.5,0.5,2),1)", "description": "", "templateType": "anything", "can_override": false}, "vsh": {"name": "vsh", "group": "Ungrouped variables", "definition": "if(selector[0]=1,random(-3..3#0.5 except 0),0)\n", "description": "

vertical shift

", "templateType": "anything", "can_override": false}, "yo4": {"name": "yo4", "group": "Ungrouped variables", "definition": "yo[4]", "description": "", "templateType": "anything", "can_override": false}, "yo3": {"name": "yo3", "group": "Ungrouped variables", "definition": "yo[3]", "description": "", "templateType": "anything", "can_override": false}, "yo2": {"name": "yo2", "group": "Ungrouped variables", "definition": "yo[2]", "description": "", "templateType": "anything", "can_override": false}, "yo1": {"name": "yo1", "group": "Ungrouped variables", "definition": "yo[1]", "description": "", "templateType": "anything", "can_override": false}, "yo0": {"name": "yo0", "group": "Ungrouped variables", "definition": "yo[0]", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["selector", "vsh", "hsh", "vsc", "hsc", "yo", "yn", "xo", "xn", "yo0", "yo1", "yo2", "yo3", "yo4", "maxx", "maxy", "recip"], "variable_groups": [], "functions": {}, "preamble": {"js": "function dragpoint_board() {\n var scope = question.scope;\n \n // var a = scope.variables.a.value;\n// var c = scope.variables.c.value;\n\n var yo0 = scope.variables.yo0.value;\n var yo1 = scope.variables.yo1.value;\n var yo2 = scope.variables.yo2.value;\n var yo3 = scope.variables.yo3.value; \n var yo4 = scope.variables.yo4.value;\n \n var maxx = scope.variables.maxx.value;\n var maxy = scope.variables.maxy.value;\n \n var div = Numbas.extensions.jsxgraph.makeBoard('500px','500px',{boundingBox:[-maxx,maxy,maxx,-maxy],grid:true});\nquestion.display.html.querySelector('#dragpoint').append(div);\n \n var board = div.board;\n \n \n //create stationary points\n \n var op0 = board.create('point',[-2,yo0],{name:'',fixed:true,size:2,color:'black'});\n var op1 = board.create('point',[-1,yo1],{name:'',fixed:true,size:2,color:'black'});\n var op2 = board.create('point',[0,yo2],{name:'',fixed:true,size:2,color:'black'});\n var op3 = board.create('point',[1,yo3],{name:'',fixed:true,size:2,color:'black'});\n var op4 = board.create('point',[2,yo4],{name:'',fixed:true,size:2,color:'black'});\n \n \n //create draggable points\n //why are there are a cloine under each one?\n var np0 = board.create('point',[-2,yo0],{name:'A',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np1 = board.create('point',[-1,yo1],{name:'B',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np2 = board.create('point',[0,yo2],{name:'C',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np3 = board.create('point',[1,yo3],{name:'D',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n var np4 = board.create('point',[2,yo4],{name:'E',size:2,snapSizeX: 0.25,snapSizeY: 0.25,snapToGrid: true});\n \n \n \n \n //shorthand to evaluate a mathematical expression to a number\n function evaluate(expression) {\n try {\n var val = Numbas.jme.evaluate(expression,question.scope);\n return Numbas.jme.unwrapValue(val);\n }\n catch(e) {\n // if there's an error, return no number\n return NaN;\n }\n }\n \n // set up points array\n var num_points = 5;\n var points = [np0, np1, np2, np3, np4];\n \n \n // this function sets up the i^th point\n function make_point(i) {\n \n // calculate initial coordinates\n // var x = i-(num_points-1)/2;\n \n // create an invisible vertical line for the point to slide along\n // var line = board.create('line',[[x,0],[x,1]],{visible: false});\n \n // create the point\n // var point = points[i] = board.create(\n // 'point',\n // [i-(num_points-1)/2,0],\n // {\n // name:'',\n // size:2,\n // snapSizeY: 0.25, // the point will snap to y-coordinates which are multiples of 0.1\n // snapSizeX: 0.25,\n // snapToGrid: true\n // }\n // );\n \n var point = points[i];\n \n var x=point[0];\n var y=point[1];\n \n // the contents of the input box for this point\n var xstudentAnswer = question.parts[0].gaps[2*i].display.studentAnswer;\n var ystudentAnswer = question.parts[0].gaps[2*i+1].display.studentAnswer;\n \n // watch the student's input and reposition the point when it changes. \n ko.computed(function() {\n x = evaluate(xstudentAnswer());\n y = evaluate(ystudentAnswer());\n if(!(isNaN(x)) && !(isNaN(y)) && board.mode!=board.BOARD_MODE_DRAG) {\n point.moveTo([x,y],100);\n }\n });\n \n // when the student drags the point, update the gapfill input\n point.on('drag',function(){\n var x = Numbas.math.niceNumber(point.X());\n var y = Numbas.math.niceNumber(point.Y());\n xstudentAnswer(x);\n ystudentAnswer(y);\n });\n \n }\n \n // create each point\n for(var i=0;i\n

The point $A$ was $(-2,\\var{yo0})$ but it is now $\\big($[[0]],[[1]]$\\big)$.
The point $B$ was $(-1,\\var{yo1})$ but it is now $\\big($[[2]],[[3]]$\\big)$.
The point $C$ was $(0,\\var{yo2})$ but it is now $\\big($[[4]],[[5]]$\\big)$.
The point $D$ was $(1,\\var{yo3})$ but it is now $\\big($[[6]],[[7]]$\\big)$.
The point $E$ was $(2,\\var{yo4})$ but it is now $\\big($[[8]],[[9]]$\\big)$.

\n", "stepsPenalty": "10", "steps": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Suppose $x$ is substituted into the function $y=\\simplify[fractionNumbers,all]{{vsc}f({hsc}x+{hsh})+{vsh}}$. The order of operations tells us what happens to $x$, in our case the order is, $\\var{hsc}$ multiplies it , $\\var{hsh}$ is added to it, $f$ is taken of it, $\\var{vsc}$ multiplies it , $\\var{vsh}$ is added to it. In this case there are two transformations to the original graph.

\n

The $\\simplify[fractionNumbers,all]{f({hsc}x)}$ part of the equation means that to get the same $y$ value as the original graph the new $x$ value will have to be $2$ times $-2$ times the negative of half of the negative half of what it was before (so that when you multiply the new $x$ value by $\\var{hsc}$ you get the old one).

\n

Since the $x$ value is displayed in the horizontal direction, this means we stretch or scale horizontally by a factor of $\\simplify[fractionNumbers,all]{{recip}}$, or in other words, compress horizontally by a factor of $\\simplify[fractionNumbers,all]{{hsc}}$.

\n

The $\\simplify[fractionNumbers,all]{f(x+{hsh})}$ means that to get the same $y$ value as the original graph the new $x$ value will have to be $\\var{abs(hsh)}$ units less greater than the original $x$ value (so that when you add $\\var{hsh}$ to subtract $\\var{abs(hsh)}$ from the new $x$ value you get the old one).

\n

Since the $x$ value is displayed in the horizontal direction, this means we shift horizontally $\\var{abs(hsh)}$ units to the left right.

\n

Notice that $x$ is modified twice before the function $f$ gets to it. If we want the same $y$ value as the original graph we need to feed $f$ with the same input. Let $x_o$ be the old $x$ value and $x_n$ be the new $x$ value. To get the same $y$ values we want $f(x_o)=\\simplify[fractionNumbers, unitFactor, basic]{f({hsc}x_n+{hsh})}$, that is, we require $x_o=\\simplify[fractionNumbers, unitFactor, basic]{{hsc}x_n+{hsh}}$. Rearranging we see $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$. 

\n

Method one (shift then scale)

\n

The equation $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$ tells us to take the old $x$ subtract $\\var{abs(hsh)}$ from it, add $\\var{abs(hsh)}$ to it, then multiply this result by $\\simplify[fractionNumbers, unitFactor, basic]{{recip}}$.

\n

Method two (scale then shift)

\n

We could rewrite $x_n=\\simplify[fractionNumbers, unitFactor, basic]{{recip}*(x_o-{hsh})}$ as $x_n=\\simplify[fractionNumbers, unitFactor, basic, simplifyFractions]{{recip}*x_o-{hsh/hsc}}$. This equation tells us to take the old $x$ value, multiply it by $\\simplify[fractionNumbers, unitFactor, basic]{{recip}}$, then subtract $\\simplify[fractionNumbers, unitFactor, basic]{{abs(hsh/hsc)}}$ from this result. add $\\simplify[fractionNumbers, unitFactor, basic]{{abs(hsh/hsc)}}$ to this result.

\n

\n

The $\\simplify[fractionNumbers,all]{{vsc}f(x)}$ part of the equation means that the $y$ value of each point on the graph will be $\\var{vsc}$ times what they were before.  half of what they were before. a negative half of what they were before. the negative of what it was before. Since the $y$ value is displayed in the vertical direction, this means we stretch or scale vertically by a factor of $\\var{vsc}$. 

\n

The $\\simplify[fractionNumbers,all]{f(x)+{vsh}}$ part of the equation means that the $y$ value of each point on the graph will be $\\var{abs(vsh)}$ units greater less than they were before. Since the $y$ value is displayed in the vertical direction, this means we shift vertically by $\\var{vsh}$ units.

"}], "gaps": [{"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[0]", "maxValue": "xn[0]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[0]", "maxValue": "yn[0]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[1]", "maxValue": "xn[1]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[1]", "maxValue": "yn[1]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[2]", "maxValue": "xn[2]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[2]", "maxValue": "yn[2]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[3]", "maxValue": "xn[3]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[3]", "maxValue": "yn[3]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "xn[4]", "maxValue": "xn[4]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}, {"type": "numberentry", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "minValue": "yn[4]", "maxValue": "yn[4]", "correctAnswerFraction": false, "allowFractions": true, "mustBeReduced": false, "mustBeReducedPC": 0, "displayAnswer": "", "showFractionHint": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain"}], "sortAnswers": false}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always"}]}], "allowPrinting": true, "navigation": {"allowregen": true, "reverse": true, "browse": true, "allowsteps": true, "showfrontpage": true, "navigatemode": "sequence", "onleave": {"action": "none", "message": ""}, "preventleave": true, "typeendtoleave": false, "startpassword": "", "autoSubmit": true, "allowAttemptDownload": false, "downloadEncryptionKey": "", "showresultspage": "oncompletion"}, "timing": {"allowPause": true, "timeout": {"action": "none", "message": ""}, "timedwarning": {"action": "none", "message": ""}}, "feedback": {"enterreviewmodeimmediately": true, "showactualmarkwhen": "always", "showtotalmarkwhen": "always", "showanswerstatewhen": "always", "showpartfeedbackmessageswhen": "always", "showexpectedanswerswhen": "inreview", "showadvicewhen": "inreview", "allowrevealanswer": true, "intro": "", "end_message": "", "results_options": {"printquestions": true, "printadvice": true}, "feedbackmessages": [], "reviewshowexpectedanswer": true, "showanswerstate": true, "reviewshowfeedback": true, "showactualmark": true, "showtotalmark": true, "reviewshowscore": true, "reviewshowadvice": true}, "diagnostic": {"knowledge_graph": {"topics": [], "learning_objectives": []}, "script": "diagnosys", "customScript": ""}, "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}], "extensions": ["jsxgraph"], "custom_part_types": [], "resources": []}