// Numbas version: exam_results_page_options {"name": "Gizem's copy of factorise a quadratic (order of answers etc)", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "

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

", "tags": [], "parts": [{"prompt": "

What are the the two linear factors of this quadratic?

\n

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

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

Quadratic factorisation that does not rely upon pattern matching.

", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "preamble": {"js": "", "css": ""}, "extensions": [], "variablesTest": {"condition": "", "maxRuns": 100}, "functions": {}, "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})}$.

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

a

", "name": "a", "definition": "random(2..3)", "templateType": "anything"}}, "ungrouped_variables": ["a", "b", "c"], "name": "Gizem's copy of factorise a quadratic (order of answers etc)", "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Gizem Intepe", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2097/"}]}]}], "contributors": [{"name": "Daniel Mansfield", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/743/"}, {"name": "Gizem Intepe", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2097/"}]}