// Numbas version: exam_results_page_options {"name": "factorise a quadratic", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "rulesets": {}, "preamble": {"js": "", "css": ""}, "statement": "

Consider the quadratic $ \\simplify[all,expandBrackets]{({a}*x + {b})*(x+{c})}$.

", "parts": [{"type": "gapfill", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "useCustomName": false, "showFeedbackIcon": true, "unitTests": [], "marks": 0, "gaps": [{"variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "valuegenerators": [{"name": "x", "value": ""}], "customName": "", "unitTests": [], "vsetRange": [0, 1], "notallowed": {"strings": ["/"], "showStrings": true, "partialCredit": 0, "message": ""}, "vsetRangePoints": 5, "showPreview": true, "showCorrectAnswer": true, "scripts": {"mark": {"script": "\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\n\nvar a = unwrap(variables.a);\nvar b = unwrap(variables.b);\nvar c = unwrap(variables.c);\n\ntry {\n // get the student's answers to the two gaps\n var gap0 = this.parentPart.gaps[0].studentAnswer;\n \n if (!gap0) {\n return; \n }\n \n // there are two roots: -b/a and -c. Make sure there is exactly one root in gap0\n \n var root0 = -1*b/a;\n var root1 = -1*c;\n var correctanswer = a + \"*x*x + (\" +(b+c*a) + \")*x\" + b*c;\n var gap0root0 = (\"0\" == unwrap(this.question.scope.evaluate(gap0,{\"x\": root0})));\n var gap0root1 = (\"0\" == unwrap(this.question.scope.evaluate(gap0,{\"x\": root1})));\n \n // check that gap0 is linear by verifying that it increases by\n // the same constant amount from 10 to 11 and 11 to 12.\n var e10 = unwrap(this.question.scope.evaluate(gap0,{\"x\": 10}));\n var e11 = unwrap(this.question.scope.evaluate(gap0,{\"x\": 11}));\n var e12 = unwrap(this.question.scope.evaluate(gap0,{\"x\": 12}));\n if ((e11 == e12) || (e11 - e10 !== e12 - e11)) {\n this.setCredit(0, \"$\" + gap0 + \"$ is not linear. A linear factor is of the form $Ax + B$ for constants $A \\\\neq 0$ and $B$.\");\n } else if ((gap0root0 && !gap0root1) || (!gap0root0 && gap0root1)) {\n // if root0 xor root1 is a root of gap0\n this.setCredit(1, \"$\" + gap0 + \"$ is a linear factor of $\\\\simplify{\" + correctanswer + \"}$.\");\n } else {\n this.setCredit(0, \"$\" + gap0 + \"$ is not a linear factor of $\\\\simplify{\" + correctanswer + \"}$.\" );\n }\n \n \n} catch(e) {\n this.setCredit(0); // if the student's answer isn't a valid expression, give 0 credit\n this.markingComment(e);\n alert(e);\n}", "order": "instead"}}, "useCustomName": false, "failureRate": 1, "type": "jme", "checkVariableNames": false, "checkingType": "absdiff", "showFeedbackIcon": true, "marks": 1, "variableReplacements": [], "adaptiveMarkingPenalty": 0, "checkingAccuracy": 0.001, "answer": "({a}*x + {b})", "extendBaseMarkingAlgorithm": true}, {"variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "valuegenerators": [{"name": "x", "value": ""}], "customName": "", "unitTests": [], "vsetRange": [0, 1], "notallowed": {"strings": ["/"], "showStrings": false, "partialCredit": 0, "message": ""}, "vsetRangePoints": 5, "showPreview": true, "showCorrectAnswer": true, "scripts": {"mark": {"script": "\nvar variables = this.question.scope.variables;\nvar unwrap = Numbas.jme.unwrapValue;\n\nvar a = unwrap(variables.a);\nvar b = unwrap(variables.b);\nvar c = unwrap(variables.c);\n\ntry {\n // get the student's answers to the two gaps\n var gap0 = this.parentPart.gaps[0].studentAnswer;\n var gap1 = this.parentPart.gaps[1].studentAnswer;\n \n if (!gap0 || !gap1) {\n return; \n }\n // check that gap1 is linear\n var e10 = unwrap(this.question.scope.evaluate(gap1,{\"x\": 10}));\n var e11 = unwrap(this.question.scope.evaluate(gap1,{\"x\": 11}));\n var e12 = unwrap(this.question.scope.evaluate(gap1,{\"x\": 12}));\n if ((e11 == e12) || (e11 - e10 !== e12 - e11)) {\n this.setCredit(0, \"$\" + gap1 + \"$ is not linear. A linear factor is of the form $Ax + B$ for constants $A \\\\neq 0$ and $B$.\");\n return;\n } \n \n var compare_settings = {};\n compare_settings.checkingType = \"absdiff\";\n compare_settings.vsetRangeStart = -5; //The lower bound of the range to pick variable values from.\n compare_settings.vsetRangeEnd = 5; //The upper bound of the range to pick variable values from.\n compare_settings.vsetRangePoints = 5; //The number of values to pick for each variable.\n compare_settings.checkingAccuracy = 0.1; // A parameter for the checking function to determine if two results are equal. See {@link Numbas.jme.checkingFunctions}.\n compare_settings.failureRate = 1;\n \n var studentanswer = \"(\" + gap0 + \")*(\" + gap1 + \")\";\n var correctanswer = a + \"*x*x + (\" +(b+c*a) + \")*x\" + b*c;\n \n for (var n = 0; n < 10; n++)\n {\n var x = Math.floor(10*Math.random());\n var test1 = unwrap(this.question.scope.evaluate(studentanswer,{\"x\": x}));\n var test2 = unwrap(this.question.scope.evaluate(correctanswer,{\"x\": x}));\n if (test1 != test2) {\n // student answer does not evaluate to the same thing as the correct answer\n this.setCredit(0,\"The product of the factors should be $\\\\simplify{\" + correctanswer + \"}$, but the product of your factors is $\\\\simplify[expandBrackets,all]{\" + studentanswer + \"}$.\");\n return;\n }\n }\n // student answer passed random testing. It is highly likely to be correct.\n this.setCredit(1,\"The product of your factors is $\\\\simplify{\" + correctanswer + \"}$.\");\n \n} catch(e) {\n this.setCredit(0); // if the student's answer isn't a valid expression, give 0 credit\n this.markingComment(e);\n alert(e);\n}", "order": "instead"}}, "useCustomName": false, "failureRate": 1, "type": "jme", "checkVariableNames": false, "checkingType": "absdiff", "showFeedbackIcon": true, "marks": 1, "variableReplacements": [], "adaptiveMarkingPenalty": 0, "checkingAccuracy": 0.001, "answer": "(x + {c})", "extendBaseMarkingAlgorithm": true}], "variableReplacements": [], "showCorrectAnswer": true, "adaptiveMarkingPenalty": 0, "scripts": {}, "customName": "", "prompt": "

What are the the two linear factors of this quadratic?

\n

[[0]] and [[1]].

", "extendBaseMarkingAlgorithm": true, "sortAnswers": false}], "ungrouped_variables": ["a", "b", "c"], "advice": "

You can use the quadratic formula to deduce that $\\simplify[all,expandBrackets]{({a}*x + {b})*(x+{c})}$ has roots:

\n

$ x = \\frac{\\simplify{-({a}*{c}+{b})}\\pm\\sqrt{ (\\var{a*c+b})^2 - 4\\times(\\var{a})\\times(\\var{b*c}) }}{2\\times \\var{a}} = \\var{-1*c} \\text{ or } \\displaystyle \\simplify{-1*{b}/{a}}.$

\n

The roots determine the factors, but only upto a constant. In general, a quadratic with roots $ \\var{-1*c}$ and $\\simplify{-1*{b}/{a}}$ has the form:

\n

$C \\times (x + \\simplify{{b}/{a}}) \\times (x - \\var{-1*c})$

\n

for some constant term $C$. The only thing left to do is determine the value of the constant which makes:

\n

$C \\times (x + \\simplify{{b}/{a}}) \\times (x - \\var{-1*c}) = \\simplify[all,expandBrackets]{({a}*x + {b})*(x+{c})}$.

\n

Equating the coefficients of the $x^2$ terms in the left and right hand sides shows that $C=\\var{a}$. So

\n

$ (\\var{a}x + \\var{b}) \\times (x-\\var{-1*c}) = \\simplify[all,expandBrackets]{({a}*x + {b})*(x+{c})}$.

", "variables": {"c": {"name": "c", "group": "Ungrouped variables", "definition": "random(-5..-1)", "description": "", "templateType": "anything"}, "b": {"name": "b", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "", "templateType": "anything"}, "a": {"name": "a", "group": "Ungrouped variables", "definition": "random(2..3)", "description": "

a

", "templateType": "anything"}}, "metadata": {"description": "

Quadratic factorisation that does not rely upon pattern matching.

", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "tags": [], "name": "factorise a quadratic", "extensions": [], "variablesTest": {"condition": "", "maxRuns": 100}, "functions": {}, "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Laure Helme-Guizon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2531/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Laure Helme-Guizon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2531/"}]}