// Numbas version: exam_results_page_options {"name": "J. Richard's copy of Extract common factors of polynomials", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "

Factorise polynomials by identifying common factors. The first expression has a constant common factor; the rest have common factors involving variables.

"}, "variables": {"x7": {"definition": "random(1..5)", "description": "", "name": "x7", "group": "Ungrouped variables", "templateType": "anything"}, "x2": {"definition": "random(1..5)", "description": "", "name": "x2", "group": "Ungrouped variables", "templateType": "anything"}, "x1": {"definition": "random(1..5)", "description": "", "name": "x1", "group": "Ungrouped variables", "templateType": "anything"}, "x6": {"definition": "random(1..5)", "description": "", "name": "x6", "group": "Ungrouped variables", "templateType": "anything"}, "a": {"definition": "repeat(random([3, 11, 17, 29, 37, 43] except b),50)", "description": "

Vector of every other random prime number

", "name": "a", "group": "Ungrouped variables", "templateType": "anything"}, "x4": {"definition": "random(-5..-1)\n\n", "description": "", "name": "x4", "group": "Ungrouped variables", "templateType": "anything"}, "c": {"definition": "repeat(random([ 5, 19, 47] ),50)", "description": "

extra primes for when you need a third constant

", "name": "c", "group": "Ungrouped variables", "templateType": "anything"}, "x5": {"definition": "random(1..5)", "description": "", "name": "x5", "group": "Ungrouped variables", "templateType": "anything"}, "x3": {"definition": "random(1..5 except [x2])", "description": "", "name": "x3", "group": "Ungrouped variables", "templateType": "anything"}, "b": {"definition": "repeat(random(2, 7, 13, 23, 31, 41, 53),50)", "description": "

Vector of the other every other random prime number

", "name": "b", "group": "Ungrouped variables", "templateType": "anything"}}, "parts": [{"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "gaps": [{"type": "jme", "vsetRangePoints": 5, "showCorrectAnswer": true, "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "marks": 1, "checkVariableNames": false, "variableReplacements": [], "scripts": {"mark": {"script": "question.mark_factorised(this);", "order": "after"}}, "showPreview": true, "vsetRange": [0, 1], "checkingAccuracy": 0.001, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "answer": "2({a[0]}x+{b[0]})", "showFeedbackIcon": true, "failureRate": 1, "unitTests": [], "expectedVariableNames": []}], "scripts": {}, "sortAnswers": false, "prompt": "

$\\simplify{{2*a[0]}x+{2*b[0]}}=$ [[0]]

", "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "unitTests": [], "type": "gapfill"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "gaps": [{"type": "jme", "vsetRangePoints": 5, "showCorrectAnswer": true, "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "marks": 1, "checkVariableNames": false, "variableReplacements": [], "scripts": {"mark": {"script": "question.mark_factorised(this);", "order": "after"}}, "showPreview": true, "vsetRange": [0, 1], "checkingAccuracy": 0.001, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "answer": "6*y*({a[1]}+{b[1]}*y)", "showFeedbackIcon": true, "failureRate": 1, "unitTests": [], "expectedVariableNames": []}], "scripts": {}, "sortAnswers": false, "prompt": "

$\\simplify{6{a[1]}y+6{b[1]}y^2}=$ [[0]]

", "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "unitTests": [], "type": "gapfill"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "gaps": [{"type": "jme", "vsetRangePoints": 5, "showCorrectAnswer": true, "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "marks": 1, "checkVariableNames": false, "variableReplacements": [], "scripts": {"mark": {"script": "question.mark_factorised(this);", "order": "after"}}, "showPreview": true, "vsetRange": [0, 1], "checkingAccuracy": 0.001, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "answer": "x*y*z*({a[2]}+{b[2]}x*y*z)", "showFeedbackIcon": true, "failureRate": 1, "unitTests": [], "expectedVariableNames": []}], "scripts": {}, "sortAnswers": false, "prompt": "

$\\simplify{{a[2]}x*y*z+{b[2]}x^2y^2z^2}=$ [[0]]

", "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "unitTests": [], "type": "gapfill"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "gaps": [{"type": "jme", "vsetRangePoints": 5, "showCorrectAnswer": true, "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "marks": 1, "checkVariableNames": false, "variableReplacements": [], "scripts": {"mark": {"script": "question.mark_factorised(this);", "order": "after"}}, "showPreview": true, "vsetRange": [0, 1], "checkingAccuracy": 0.001, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "answer": "5({a[3]}d+{b[3]}r+m)", "showFeedbackIcon": true, "failureRate": 1, "unitTests": [], "expectedVariableNames": []}], "scripts": {}, "sortAnswers": false, "prompt": "

$\\simplify{5{a[3]}d+5{b[3]}r+5m}=$ [[0]]

", "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "unitTests": [], "type": "gapfill"}, {"variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 0, "gaps": [{"type": "jme", "vsetRangePoints": 5, "showCorrectAnswer": true, "checkingType": "absdiff", "variableReplacementStrategy": "originalfirst", "marks": 1, "checkVariableNames": false, "variableReplacements": [], "scripts": {"mark": {"script": "question.mark_factorised(this);", "order": "after"}}, "showPreview": true, "vsetRange": [0, 1], "checkingAccuracy": 0.001, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "answer": "6c*d*({a[4]}d+{b[4]}c+{c[1]}c*d)", "showFeedbackIcon": true, "failureRate": 1, "unitTests": [], "expectedVariableNames": []}], "scripts": {}, "sortAnswers": false, "prompt": "

$\\simplify{6{a[4]}c*d^2+6{b[4]}c^2d+6{c[1]}c^2d^2}=$ [[0]]

", "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "unitTests": [], "type": "gapfill"}], "variable_groups": [], "rulesets": {}, "variablesTest": {"maxRuns": "1000", "condition": ""}, "statement": "

An expression can be factorised by finding common factors of each term in the expression.

\n

Completely factorise the following expressions by finding their common factors.

\n

Make sure that you include a multiplication symbol * between each algebraic variable, and before brackets, e.g. a*b*(x+1) instead of ab(x+1). Otherwise, the system might not accept your answer.

", "tags": ["common factors", "common factors of linear algebraic equations", "common factors of quadratic equations", "finding common factors", "Linear equations", "linear equations", "quadratic equations", "Quadratic Equations", "Quadratic equations", "taxonomy"], "extensions": [], "advice": "

In order to factorise the expressions, the factors that make up each term in the expression need to be identified and, where these factors are the same for all terms in the expression, those factors can be taken outside the brackets. Stop when the remaining terms have no more common factors.

\n

#### a)

\n

Both terms have a common factor of $2$.

\n

\\begin{align}
\\simplify{2{a[0]}x+2{b[0]}}&=
(\\simplify[]{2{a[0]}})x+2\\times\\var{b[0]}\\\\
&=\\simplify[]{2({a[0]}x+{b[0]})}
\\end{align}

\n

#### b)

\n

Both terms have common factors of $6$ and $y$.

\n

\\begin{align}
\\simplify{6{a[1]}y+6{b[1]}y^2}&= 6 \\times \\var{a[1]} y + 6 \\times \\var{b[1]} y^2 \\\\
&= 6 \\times (\\simplify{{a[1]}y + {b[1]}y^2}) \\\\
&=6y(\\simplify[]{{a[1]}+{b[1]}y})
\\end{align}

\n

#### c)

\n

Both terms have common factors of $x$, $y$ and $z$.

\n

\\begin{align}
\\simplify{{a[2]}x*y*z+{b[2]}x^2y^2z^2}&=\\var{a[2]} \\times xyz + \\var{b[2]} \\times xyz \\times xyz\\\\
&=xyz(\\var{a[2]} + \\var{b[2]} xyz)
\\end{align}

\n

#### d)

\n

All three terms have a common factor of $5$.

\n

\\begin{align}
\\simplify{5{a[3]}d+5{b[3]}r+5m}&= 5 \\times \\var{a[3]} d+5 \\times \\var{b[3]} r + 5 m \\\\
&=\\simplify[]{5({a[3]}d+{b[3]}r+m)}
\\end{align}

\n

#### e)

\n

All the terms have common factors of $6$, $c$ and $d$.

\n

\\begin{align}
\\simplify{6{a[4]}cd^2+6{b[4]}c^2d+6{c[1]}c^2d^2} &= 6 \\times \\var{a[4]} c d^2 \\;+\\; 6 \\times \\var{b[4]} c^2 d \\;+\\; 6 \\times \\var{c[1]} c^2 d^2 \\\\
&= 6(\\var{a[4]} c d^2 + \\var{b[4]} c^2 d + \\var{c[1]} c^2 d^2) \\\\
&=6cd(\\var{a[4]}d+\\var{b[4]}c+\\var{c[1]}cd)
\\end{align}

\n", "name": "J. Richard's copy of Extract common factors of polynomials", "functions": {}, "ungrouped_variables": ["a", "b", "c", "x1", "x2", "x3", "x4", "x5", "x6", "x7"], "preamble": {"js": "question.mark_factorised = function(part) {\n var match = Numbas.jme.display.matchExpression;\n var unwrap = Numbas.jme.unwrapValue;\n var getCommutingTerms = Numbas.jme.display.getCommutingTerms;\n var matchTree = Numbas.jme.display.matchTree;\n\n var expr = part.studentAnswer;\n\n // is the student's answer in the form factors*(terms)?\n var m = match('m_all(m_any(m_number,m_type(name),m_type(name)^m_number))*(m_all(??)+m_nothing);rest', expr, true);\n if(!m) {\n part.multCredit(0,\"You don't seem to have extracted a common factor.\");\n return;\n }\n \n var terms = getCommutingTerms(m.rest,'+').terms;\n \n var gcd; // greatest common divisor of the coefficients of each term\n var min_degrees = {}; // minimum degree of each variable across the terms - if greater than 0, that variable is a common factor\n \n // for each term, collect the scalar part and the degree of each of the variables\n terms.map(function(t,i) { \n var factors = getCommutingTerms(t,'*').terms;\n var degrees = {};\n var n = 1;\n factors.forEach(function(f) {\n var tok = f.tok;\n var scalar = 1;\n var name = null;\n var degree = 0;\n var m = Numbas.jme.display.matchTree(Numbas.jme.compile('m_any(m_number;n, m_type(name);name, m_number;n*m_type(name);name, m_type(name);name^(m_number;degree), m_number;n*m_type(name);name^m_number;degree )'),f,true)\n\n console.log(Numbas.jme.display.treeToJME(f));\n\n if(!m) {\n console.log(' no match');\n return;\n }\n console.log(' match',m.n,m.name,m.degree);\n if(m.n) {\n n *= unwrap(m.n.tok);\n }\n if(m.name) {\n name = m.name.tok.name;\n if(m.degree) {\n degree = unwrap(m.degree.tok);\n } else {\n degree = 1;\n }\n degrees[name] = (degrees[name] || 0) + degree;\n }\n });\n console.log(Numbas.jme.display.treeToJME(t), degrees, n);\n \n if(i==0) {\n gcd = n;\n } else {\n gcd = Numbas.math.gcd(gcd,n);\n }\n \n Object.keys(degrees).forEach(function(k) {\n if(i==0) {\n min_degrees[k] = degrees[k];\n } else {\n min_degrees[k] = Math.min(min_degrees[k] || 0, degrees[k]);\n }\n });\n Object.keys(min_degrees).forEach(function(k) {\n if(degrees[k]===undefined) {\n min_degrees[k] = 0;\n }\n });\n \n });\n \n var common_factors = [];\n if(gcd>1) {\n common_factors.push(gcd);\n }\n Object.keys(min_degrees).filter(function(k){return min_degrees[k]>0}).forEach(function(k) {\n common_factors.push(k+'^'+min_degrees[k])\n });\n \n if(common_factors.length==0) {\n return true;\n } else {\n part.multCredit(0,\"Your terms still have a common factor of $\"+Numbas.jme.display.exprToLaTeX(common_factors.join('*'),'all',Numbas.jme.builtinScope)+\"$.\");\n }\n};", "css": ""}, "type": "question", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Bradley Bush", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1521/"}, {"name": "J. Richard Snape", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1700/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Bradley Bush", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1521/"}, {"name": "J. Richard Snape", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1700/"}]}