// Numbas version: exam_results_page_options {"name": "factorize a quadratic", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "preventleave": false, "showfrontpage": false}, "question_groups": [{"questions": [{"variables": {"c": {"group": "Ungrouped variables", "definition": "random(-5..-1)", "templateType": "anything", "description": "", "name": "c"}, "b": {"group": "Ungrouped variables", "definition": "random(1..5)", "templateType": "anything", "description": "", "name": "b"}, "a": {"group": "Ungrouped variables", "definition": "random(2..3)", "templateType": "anything", "description": "

a

", "name": "a"}}, "name": "factorize a quadratic", "functions": {}, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/", "name": "Daniel Mansfield"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/", "name": "Xiaodan Leng"}], "tags": [], "metadata": {"description": "

Quadratic factorisation that does not rely upon pattern matching.

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

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

", "extensions": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "ungrouped_variables": ["a", "b", "c"], "preamble": {"js": "", "css": ""}, "variable_groups": [], "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})}$.

", "rulesets": {}, "parts": [{"customName": "", "variableReplacementStrategy": "originalfirst", "extendBaseMarkingAlgorithm": true, "unitTests": [], "useCustomName": false, "showFeedbackIcon": true, "showCorrectAnswer": true, "gaps": [{"customName": "", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "useCustomName": false, "variableReplacements": [], "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"}}, "showPreview": true, "answer": "({a}*x + {b})", "vsetRange": [0, 1], "vsetRangePoints": 5, "showFeedbackIcon": true, "checkingType": "absdiff", "notallowed": {"message": "", "strings": ["/"], "showStrings": true, "partialCredit": 0}, "showCorrectAnswer": true, "checkVariableNames": false, "marks": 1, "checkingAccuracy": 0.001, "valuegenerators": [{"value": "", "name": "x"}], "type": "jme", "failureRate": 1}, {"customName": "", "variableReplacementStrategy": "originalfirst", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "useCustomName": false, "variableReplacements": [], "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 gap2 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 = 10; //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 if (Numbas.jme.compare(studentanswer, correctanswer, compare_settings, this.question.scope)) {\n // the two gaps multiply to give the correct answer\n this.setCredit(1,\"The product of your factors is $\\\\simplify{\" + correctanswer + \"}$.\");\n } else {\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 }\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"}}, "showPreview": true, "answer": "(x + {c})", "vsetRange": [0, 1], "vsetRangePoints": 5, "showFeedbackIcon": true, "checkingType": "absdiff", "notallowed": {"message": "", "strings": ["/"], "showStrings": false, "partialCredit": 0}, "showCorrectAnswer": true, "checkVariableNames": false, "marks": 1, "checkingAccuracy": 0.001, "valuegenerators": [{"value": "", "name": "x"}], "type": "jme", "failureRate": 1}], "marks": 0, "sortAnswers": false, "prompt": "

What are the the two linear factors of this quadratic?

\n

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

", "scripts": {}, "variableReplacements": [], "type": "gapfill", "customMarkingAlgorithm": ""}]}], "pickingStrategy": "all-ordered"}], "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/", "name": "Daniel Mansfield"}, {"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/", "name": "Xiaodan Leng"}]}