// Numbas version: exam_results_page_options {"name": "Single Absolute Value", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "

You are given the inequality \\[|\\simplify{{a}x+{b}}| \\var{latex(sym)} \\var{c}.\\]

\n

", "variablesTest": {"maxRuns": 100, "condition": ""}, "name": "Single Absolute Value", "tags": [], "rulesets": {}, "preamble": {"css": "", "js": ""}, "variable_groups": [], "variables": {"b": {"definition": "random(-12..12 except 0)", "description": "", "group": "Ungrouped variables", "name": "b", "templateType": "anything"}, "backsym": {"definition": "['>','\\\\ge','<','\\\\le'][backChoice-1]", "description": "", "group": "Ungrouped variables", "name": "backsym", "templateType": "anything"}, "nonhole": {"definition": "(a-b*c)/(c*d-1)", "description": "", "group": "Ungrouped variables", "name": "nonhole", "templateType": "anything"}, "dr": {"definition": "r2-r1", "description": "", "group": "Ungrouped variables", "name": "dr", "templateType": "anything"}, "backprod": {"definition": "leadCoeff*backchoice", "description": "", "group": "Ungrouped variables", "name": "backprod", "templateType": "anything"}, "d": {"definition": "random(-12..12 except -1..1)", "description": "

d

", "group": "Ungrouped variables", "name": "d", "templateType": "anything"}, "hole": {"definition": "-b/d", "description": "", "group": "Ungrouped variables", "name": "hole", "templateType": "anything"}, "r1": {"definition": "rootList[0]", "description": "

r1

", "group": "Ungrouped variables", "name": "r1", "templateType": "anything"}, "extremeY": {"definition": "(r2-r1)^2/4\n\n//abs((c*b-a)*b-(b*(d*d-1)+d*(c*b-a))^2/(4*d*(c*d-1)))", "description": "

approx of the furthest we need to plot in the y direction

", "group": "Ungrouped variables", "name": "extremeY", "templateType": "anything"}, "one": {"definition": "if(choice=3 or choice=4,true,false)", "description": "", "group": "Ungrouped variables", "name": "one", "templateType": "anything"}, "c": {"definition": "random(1..12)", "description": "", "group": "Ungrouped variables", "name": "c", "templateType": "anything"}, "leadCoeff": {"definition": "sign(a)", "description": "", "group": "Ungrouped variables", "name": "leadCoeff", "templateType": "anything"}, "choice": {"definition": "random(1..4)", "description": "", "group": "Ungrouped variables", "name": "choice", "templateType": "anything"}, "sym": {"definition": "['>','\\\\ge','<','\\\\le'][choice-1]", "description": "", "group": "Ungrouped variables", "name": "sym", "templateType": "anything"}, "a": {"definition": "random(-12..12 except 0)", "description": "", "group": "Ungrouped variables", "name": "a", "templateType": "anything"}, "backChoice": {"definition": "mod(choice+1,4)+1", "description": "", "group": "Ungrouped variables", "name": "backChoice", "templateType": "anything"}, "r2": {"definition": "rootList[1]", "description": "

r2

", "group": "Ungrouped variables", "name": "r2", "templateType": "anything"}, "prod": {"definition": "leadCoeff*choice", "description": "", "group": "Ungrouped variables", "name": "prod", "templateType": "anything"}, "rootList": {"definition": "sort([(-b-c)/a,(-b+c)/a])", "description": "", "group": "Ungrouped variables", "name": "rootList", "templateType": "anything"}, "strict": {"definition": "if(choice=1 or choice=3,true,false)", "description": "", "group": "Ungrouped variables", "name": "strict", "templateType": "anything"}}, "ungrouped_variables": ["choice", "sym", "a", "c", "d", "b", "leadCoeff", "prod", "one", "rootList", "r1", "r2", "strict", "backChoice", "backsym", "extremeY", "backprod", "dr", "hole", "nonhole"], "metadata": {"description": "

Inequality involving a single absolute value, question solution uses the piecewise nature of the absolute value function.

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

Short-cut Method

\n

\n

For questions of this type (where the absolute value is 'less than' or 'less than and equal to' something positive) we can set out our working in a shorter way:

\n

\\begin{alignat}{2} &&|\\simplify{{a}x+{b}}| &\\var{latex(sym)} \\var{c}\\\\ \\var{-c} &\\var{latex(sym)}&\\simplify{{a}x+{b}}&\\var{latex(sym)}\\var{c}\\\\ \\var{-c-b} &\\var{latex(sym)} &\\simplify{{a}x}\\quad&\\var{latex(sym)}\\var{c-b}\\\\ \\var[fractionNumbers]{r1}&\\var{latex(sym)}&x\\quad&\\var{latex(sym)}\\var[fractionNumbers]{r2}.\\end{alignat}

\n

\\begin{alignat}{2} &&|\\simplify{{a}x+{b}}| &\\var{latex(sym)} \\var{c}\\\\ \\var{-c} &\\var{latex(sym)}&\\simplify{{a}x+{b}}&\\var{latex(sym)}\\var{c}\\\\ \\var{-c-b} &\\var{latex(sym)} &\\simplify{{a}x}\\quad&\\var{latex(sym)}\\var{c-b}.\\end{alignat}

\n

\\begin{alignat}{2} &&|\\simplify{{a}x+{b}}| &\\var{latex(sym)} \\var{c}\\\\ \\var{-c} &\\var{latex(sym)}&\\simplify{{a}x+{b}}&\\var{latex(sym)}\\var{c}\\\\ \\var{-c-b} &\\var{latex(sym)} &\\simplify{{a}x}\\quad&\\var{latex(sym)}\\var{c-b}\\\\ \\var[fractionNumbers]{r2}&\\var{latex(backsym)}&x\\quad&\\var{latex(backsym)}\\var[fractionNumbers]{r1}\\\\\\var[fractionNumbers]{r1}&\\var{latex(sym)}&x\\quad&\\var{latex(sym)}\\var[fractionNumbers]{r2}.\\end{alignat}

\n

\n

Cases Method

\n

 

\n

Recall that the absolute value is defined as the piecewise function \\[|x|=\\begin{cases}x, &\\text{ for } x\\ge 0\\\\ -x, &\\text{ for } x<0. \\end{cases}\\]

\n

This means that $|\\simplify{{a}x+{b}}|$ is actually $\\simplify{{a}x+{b}}$ when $\\simplify{{a}x+{b}}\\ge 0$ but it is $-(\\simplify{{a}x+{b}})$ when $\\simplify{{a}x+{b}}<0$. We have two cases:

\n

\n

Case 1: $\\simplify{{a}x+{b}}\\ge 0$

\n

Rearranging $\\simplify{{a}x+{b}}\\ge 0$ for $x$ gives $x \\ge \\simplify[fractionNumbers]{{-b/a}}$ $x \\le \\simplify[fractionNumbers]{{-b/a}}$ and so case 1 is only relevant for $x \\ge \\simplify[fractionNumbers]{{-b/a}}$ $x \\le \\simplify[fractionNumbers]{{-b/a}}$.

\n

In case 1, our inequality is simply $\\simplify{{a}x+{b}} \\var{latex(sym)} \\var{c}$, and so rearranging it for $x$ gives $x \\var{latex(sym)} \\simplify[fractionNumbers,simplifyFractions,!unitDenominator]{{(c-b)/a}}$ $x \\var{latex(backsym)} \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(c-b)/a}}$

\n

So in conclusion for case 1, we require that $x \\ge \\simplify[fractionNumbers]{{-b/a}}$ $x \\le \\simplify[fractionNumbers]{{-b/a}}$   and  $x \\var{latex(sym)} \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(c-b)/a}}$ $x \\var{latex(backsym)} \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(c-b)/a}}$ which is the same as $\\simplify[fractionNumbers]{-{b/a}}\\le x\\var{latex(sym)} \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(c-b)/a}}$ $\\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(c-b)/a}}\\var{latex(sym)} x\\le \\simplify[fractionNumbers]{{-b/a}}$ $x\\var{latex(sym)}\\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(c-b)/a}}$ $x\\var{latex(backsym)}\\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(c-b)/a}}$.

\n

\n

Case 2: $\\simplify{{a}x+{b}}< 0$

\n

Rearranging $\\simplify{{a}x+{b}}< 0$ for $x$ gives $x < \\simplify[fractionNumbers]{{-b/a}}$ $x > \\simplify[fractionNumbers]{{-b/a}}$ and so case 2 is only relevant for $x < \\simplify[fractionNumbers]{{-b/a}}$ $x > \\simplify[fractionNumbers]{{-b/a}}$.

\n

In case 2, our inequality is actually $-(\\simplify{{a}x+{b}}) \\var{latex(sym)} \\var{c}$, and so rearranging it for $x$ gives $x \\var{latex(backsym)} \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(-c-b)/a}}$ $x \\var{latex(sym)} \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(-c-b)/a}}$

\n

So in conclusion for case 2, we require that $x < \\simplify[fractionNumbers]{-{b/a}}$ $x > \\simplify[fractionNumbers]{-{b/a}}$  and  $x \\var{latex(backsym)} \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(-c-b)/a}}$ $x \\var{latex(sym)} \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(-c-b)/a}}$ which is the same as $\\simplify[fractionNumbers]{{-(b+c)/a}}\\var{latex(sym)} x< \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{-b}/{a}}$ $\\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{-b/a}}< x \\var{latex(sym)} \\simplify[fractionNumbers,simplifyFractions,unitDenominator]{-{(b+c)/a}}$ $x\\var{latex(backsym)}\\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(-c-b)/a}}$ $x\\var{latex(sym)}\\simplify[fractionNumbers,simplifyFractions,unitDenominator]{{(-c-b)/a}}$.

\n

\n

Therefore the solution to our original inequality $|\\simplify{{a}x+{b}}| \\var{latex(sym)} \\var{c}$ is 

\n

\\[\\var[fractionNumbers]{r1}<x<\\var[fractionNumbers]{r2}.\\]

\n

\\[\\var[fractionNumbers]{r1}\\le x \\le\\var[fractionNumbers]{r2}.\\]

\n

\\[x< \\var[fractionNumbers]{r1}, \\, x> \\var[fractionNumbers]{r2}.  \\]

\n

\\[x\\le \\var[fractionNumbers]{r1}, \\, x\\ge\\var[fractionNumbers]{r2}.  \\]

\n

\n

\n

", "extensions": ["jsxgraph"], "functions": {"graph": {"language": "javascript", "parameters": [], "type": "html", "definition": "a = Numbas.jme.unwrapValue(scope.variables.leadcoeff);\nr1 = Numbas.jme.unwrapValue(scope.variables.r1);\nr2 = Numbas.jme.unwrapValue(scope.variables.r2);\nprod = Numbas.jme.unwrapValue(scope.variables.backprod);\ndr=Numbas.jme.unwrapValue(scope.variables.dr);\nexy=Numbas.jme.unwrapValue(scope.variables.extremey);\nhole = Numbas.jme.unwrapValue(scope.variables.hole);\nnonhole = Numbas.jme.unwrapValue(scope.variables.nonhole);\n\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[r1-dr,1.2*exy,r2+dr,-1.2*exy],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,10],{\ndrawLabels: true,\nlabel: {offset: [-20, 0]},\nminorTicks: 0,\n});\n\n\n\nif(prod==2 || prod==4 || prod==-2 || prod==-4){ptColour = 'green';} else {ptColour = 'red';};\n\nboard.create('point',[hole,0],{fixed:true,withLabel:false,strokeColour:'red', fillColor:'red'});\nboard.create('point',[nonhole,0],{fixed:true,withLabel:false,strokeColor:ptColour,fillColor:ptColour});\n\nif(prod==2 || prod==-4 || prod== 1 || prod==-3){ outColour = 'green';} else {outColour = 'red';};\nif(prod==-2 || prod==4 || prod== -1 || prod==3){inColour = 'green';} else {inColour = 'red';};\n\nboard.create('functiongraph',[function(x){return a*(x**2-(r1+r2)*x+r1*r2);},r1,r2],{strokeColor:inColour,strokeWidth:2});\nboard.create('functiongraph',[function(x){return a*(x**2-(r1+r2)*x+r1*r2);},r1-dr,r1],{strokeColor:outColour,strokeWidth:2});\nboard.create('functiongraph',[function(x){return a*(x**2-(r1+r2)*x+r1*r2);},r2,r2+dr],{strokeColor:outColour,strokeWidth:2});\n\nreturn div;"}}, "parts": [{"gaps": [{"matrix": ["if(one=true,1,0)", "if(one=false,1,0)"], "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "shuffleChoices": false, "scripts": {"mark": {"script": "// apply the normal marking algorithm for this part\nthis.__proto__.mark.apply(this);\n// store whether the student said \"one interval\" in an attribute that's easier to access\nthis.one = this.ticks[0][0];", "order": "instead"}}, "minMarks": 0, "displayColumns": 0, "displayType": "dropdownlist", "choices": ["

one interval.

", "

two intervals.

"], "showCorrectAnswer": true, "type": "1_n_2", "maxMarks": 0, "distractors": ["", ""]}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 1, "showFeedbackIcon": true, "mustBeReduced": false, "allowFractions": true, "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "maxValue": "r1", "minValue": "r1", "scripts": {}, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": true}, {"matrix": ["if(one=true and strict=true,1,0)", "if(one=true and strict=false,1,0)"], "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "shuffleChoices": false, "scripts": {}, "minMarks": 0, "displayColumns": 0, "displayType": "dropdownlist", "choices": ["

<

", "

"], "showCorrectAnswer": true, "type": "1_n_2", "maxMarks": 0, "distractors": ["", ""]}, {"matrix": ["if(one=true and strict=true,1,0)", "if(one=true and strict=false,1,0)"], "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "shuffleChoices": false, "scripts": {}, "minMarks": 0, "displayColumns": 0, "displayType": "dropdownlist", "choices": ["

<

", "

"], "showCorrectAnswer": true, "type": "1_n_2", "maxMarks": 0, "distractors": ["", ""]}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 1, "showFeedbackIcon": true, "mustBeReduced": false, "allowFractions": true, "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "maxValue": "r2", "minValue": "r2", "scripts": {}, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": true}, {"matrix": ["if(one=false and strict=true,1,0)", "if(one=false and strict=false,1,0)"], "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "shuffleChoices": false, "scripts": {}, "minMarks": 0, "displayColumns": 0, "displayType": "dropdownlist", "choices": ["

<

", "

"], "showCorrectAnswer": true, "type": "1_n_2", "maxMarks": 0, "distractors": ["", ""]}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 1, "showFeedbackIcon": true, "mustBeReduced": false, "allowFractions": true, "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "maxValue": "r1", "minValue": "r1", "scripts": {}, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": true}, {"matrix": ["if(one=false and strict=true,1,0)", "if(one=false and strict=false,1,0)"], "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "showFeedbackIcon": true, "shuffleChoices": false, "scripts": {}, "minMarks": 0, "displayColumns": 0, "displayType": "dropdownlist", "choices": ["

>

", "

"], "showCorrectAnswer": true, "type": "1_n_2", "maxMarks": 0, "distractors": ["", ""]}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 1, "showFeedbackIcon": true, "mustBeReduced": false, "allowFractions": true, "correctAnswerStyle": "plain", "mustBeReducedPC": 0, "maxValue": "r2", "minValue": "r2", "scripts": {}, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "showCorrectAnswer": true, "correctAnswerFraction": true}], "type": "gapfill", "marks": 0, "showFeedbackIcon": true, "variableReplacements": [], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "scripts": {"constructor": {"script": "// override the default 'submit' method for the part\n// we only want to submit gaps 1,2,3,4 if the answer to gap 0 is \"one\" and we only want to submit gaps 5,6,7,8 if the answer to gap 0 is \"two\"\nthis.submit = Numbas.util.extend(function() {\n this.gaps[0].submit();\n if(this.gaps[0].one) {\n this.gaps[1].submit();\n this.gaps[2].submit();\n this.gaps[3].submit();\n this.gaps[4].submit();\n this.gaps[5].answered = true;\n this.gaps[6].answered = true;\n this.gaps[7].answered = true;\n this.gaps[8].answered = true;\n } else {\n this.gaps[1].answered = true;\n this.gaps[2].answered = true;\n this.gaps[3].answered = true;\n this.gaps[4].answered = true;\n this.gaps[5].submit();\n this.gaps[6].submit();\n this.gaps[7].submit();\n this.gaps[8].submit(); \n }\n},Part.prototype.submit);\n", "order": "after"}, "mark": {"script": "var gaps = this.gaps;\n// if the student said \"one\" to gap 0, then mark gaps 0 to 4\nif(gaps[0].one) {\n this.setCredit((gaps[0].credit*gaps[0].marks+gaps[1].credit*gaps[1].marks+gaps[2].credit*gaps[2].marks+gaps[3].credit*gaps[3].marks+gaps[4].credit*gaps[4].marks)/(gaps[0].marks+gaps[1].marks+gaps[2].marks+gaps[3].marks+gaps[4].marks));\n// otherwise, work out the credit based on the gaps 0, 5 to 8\n} else {\n this.setCredit((gaps[0].credit*gaps[0].marks+gaps[5].credit*gaps[5].marks+gaps[6].credit*gaps[6].marks+gaps[7].credit*gaps[7].marks+gaps[8].credit*gaps[8].marks)/(gaps[0].marks+gaps[5].marks+gaps[6].marks+gaps[7].marks+gaps[8].marks));\n}\n\n", "order": "instead"}}, "prompt": "

The solution to the above inequality

\n

is made up of  [[0]]

\n
\n

Given by the condition [[1]] [[2]] $x$ [[3]] [[4]].

\n
\n
\n

Given by the condition, $x$ [[5]] [[6]] or $x$ [[7]] [[8]].

\n
"}], "type": "question", "contributors": [{"name": "Caitr\u00edona N\u00ed Sh\u00e9", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1572/"}, {"name": "Johnny Yi", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2810/"}]}]}], "contributors": [{"name": "Caitr\u00edona N\u00ed Sh\u00e9", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1572/"}, {"name": "Johnny Yi", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2810/"}]}