// Numbas version: exam_results_page_options {"name": "factorize a quadratic", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": [], "statement": "

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

", "variable_groups": [], "ungrouped_variables": ["a", "b", "c"], "variables": {"a": {"group": "Ungrouped variables", "description": "

a

", "definition": "random(2..3)", "name": "a", "templateType": "anything"}, "b": {"group": "Ungrouped variables", "description": "", "definition": "random(1..5)", "name": "b", "templateType": "anything"}, "c": {"group": "Ungrouped variables", "description": "", "definition": "random(-5..-1)", "name": "c", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "preamble": {"css": "", "js": ""}, "metadata": {"licence": "Creative Commons Attribution-ShareAlike 4.0 International", "description": "

Quadratic factorisation that does not rely upon pattern matching.

"}, "parts": [{"variableReplacementStrategy": "originalfirst", "unitTests": [], "marks": 0, "customMarkingAlgorithm": "", "customName": "", "prompt": "

What are the the two linear factors of this quadratic?

\n

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

", "showCorrectAnswer": true, "sortAnswers": false, "gaps": [{"variableReplacementStrategy": "originalfirst", "vsetRange": [0, 1], "notallowed": {"partialCredit": 0, "showStrings": true, "message": "", "strings": ["/"]}, "checkingType": "absdiff", "type": "jme", "showFeedbackIcon": true, "useCustomName": false, "customMarkingAlgorithm": "", "valuegenerators": [{"value": "", "name": "x"}], "variableReplacements": [], "scripts": {"mark": {"order": "instead", "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}"}}, "checkVariableNames": false, "failureRate": 1, "marks": 1, "unitTests": [], "customName": "", "answer": "({a}*x + {b})", "showCorrectAnswer": true, "vsetRangePoints": 5, "checkingAccuracy": 0.001, "extendBaseMarkingAlgorithm": true, "showPreview": true}, {"variableReplacementStrategy": "originalfirst", "vsetRange": [0, 1], "notallowed": {"partialCredit": 0, "showStrings": false, "message": "", "strings": ["/"]}, "checkingType": "absdiff", "type": "jme", "showFeedbackIcon": true, "useCustomName": false, "customMarkingAlgorithm": "", "valuegenerators": [{"value": "", "name": "x"}], "variableReplacements": [], "scripts": {"mark": {"order": "instead", "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}"}}, "checkVariableNames": false, "failureRate": 1, "marks": 1, "unitTests": [], "customName": "", "answer": "(x + {c})", "showCorrectAnswer": true, "vsetRangePoints": 5, "checkingAccuracy": 0.001, "extendBaseMarkingAlgorithm": true, "showPreview": true}], "extendBaseMarkingAlgorithm": true, "type": "gapfill", "useCustomName": false, "showFeedbackIcon": true, "variableReplacements": [], "scripts": {}}], "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})}$.

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