// Numbas version: exam_results_page_options {"name": "Laura's copy of factorise a quadratic", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"preamble": {"js": "", "css": ""}, "variables": {"c": {"name": "c", "group": "Ungrouped variables", "definition": "random(-5..-1)", "description": "", "templateType": "anything"}, "a": {"name": "a", "group": "Ungrouped variables", "definition": "random(2..3)", "description": "

a

", "templateType": "anything"}, "b": {"name": "b", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "", "templateType": "anything"}}, "extensions": [], "rulesets": {}, "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})}$.

", "variablesTest": {"maxRuns": 100, "condition": ""}, "functions": {}, "parts": [{"marks": 0, "customMarkingAlgorithm": "", "unitTests": [], "showFeedbackIcon": true, "showCorrectAnswer": true, "type": "gapfill", "extendBaseMarkingAlgorithm": true, "sortAnswers": false, "variableReplacementStrategy": "originalfirst", "gaps": [{"marks": 1, "customMarkingAlgorithm": "", "expectedVariableNames": [], "unitTests": [], "notallowed": {"message": "", "showStrings": true, "strings": ["/"], "partialCredit": 0}, "checkingAccuracy": 0.001, "showFeedbackIcon": true, "showCorrectAnswer": true, "failureRate": 1, "vsetRangePoints": 5, "checkingType": "absdiff", "extendBaseMarkingAlgorithm": true, "answer": "({a}*x + {b})", "type": "jme", "checkVariableNames": false, "showPreview": true, "vsetRange": [0, 1], "variableReplacementStrategy": "originalfirst", "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}"}}, "variableReplacements": []}, {"marks": 1, "customMarkingAlgorithm": "", "expectedVariableNames": [], "unitTests": [], "notallowed": {"message": "", "showStrings": false, "strings": ["/"], "partialCredit": 0}, "checkingAccuracy": 0.001, "showFeedbackIcon": true, "showCorrectAnswer": true, "failureRate": 1, "vsetRangePoints": 5, "checkingType": "absdiff", "extendBaseMarkingAlgorithm": true, "answer": "(x + {c})", "type": "jme", "checkVariableNames": false, "showPreview": true, "vsetRange": [0, 1], "variableReplacementStrategy": "originalfirst", "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}"}}, "variableReplacements": []}], "prompt": "

What are the the two linear factors of this quadratic?

\n

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

", "scripts": {}, "variableReplacements": []}], "statement": "

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

", "ungrouped_variables": ["a", "b", "c"], "tags": [], "name": "Laura's copy of factorise a quadratic", "metadata": {"description": "

Quadratic factorisation that does not rely upon pattern matching.

", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "type": "question", "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Laura Horton", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3124/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Laura Horton", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3124/"}]}