// Numbas version: exam_results_page_options {"name": "Marlon's copy of Extract common factors of polynomials", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"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": ""}, "rulesets": {}, "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", "taxonomy"], "variable_groups": [], "extensions": [], "ungrouped_variables": ["a", "b", "c", "x1", "x2", "x3", "x4", "x5", "x6", "x7"], "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

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

Vector of every other random prime number

", "templateType": "anything"}, "x6": {"name": "x6", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "", "templateType": "anything"}, "b": {"name": "b", "group": "Ungrouped variables", "definition": "repeat(random(2, 7, 13, 23, 31, 41, 53),50)", "description": "

Vector of the other every other random prime number

", "templateType": "anything"}, "x3": {"name": "x3", "group": "Ungrouped variables", "definition": "random(1..5 except [x2])", "description": "", "templateType": "anything"}, "x5": {"name": "x5", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "", "templateType": "anything"}, "c": {"name": "c", "group": "Ungrouped variables", "definition": "repeat(random([ 5, 19, 47] ),50)", "description": "

extra primes for when you need a third constant

", "templateType": "anything"}, "x1": {"name": "x1", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "", "templateType": "anything"}, "x7": {"name": "x7", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "", "templateType": "anything"}}, "metadata": {"description": "

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

", "licence": "Creative Commons Attribution 4.0 International"}, "name": "Marlon's copy of Extract common factors of polynomials", "parts": [{"variableReplacements": [], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "prompt": "

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

", "gaps": [{"variableReplacementStrategy": "originalfirst", "answer": "2({a[0]}x+{b[0]})", "checkvariablenames": false, "showFeedbackIcon": true, "marks": 1, "scripts": {"mark": {"order": "after", "script": "question.mark_factorised(this);"}}, "variableReplacements": [], "showCorrectAnswer": true, "vsetrangepoints": 5, "checkingaccuracy": 0.001, "checkingtype": "absdiff", "showpreview": true, "vsetrange": [0, 1], "type": "jme", "expectedvariablenames": []}], "showFeedbackIcon": true, "type": "gapfill", "marks": 0, "scripts": {}}, {"variableReplacements": [], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "prompt": "

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

", "gaps": [{"variableReplacementStrategy": "originalfirst", "answer": "6*y*({a[1]}+{b[1]}*y)", "checkvariablenames": false, "showFeedbackIcon": true, "marks": 1, "scripts": {"mark": {"order": "after", "script": "question.mark_factorised(this);"}}, "variableReplacements": [], "showCorrectAnswer": true, "vsetrangepoints": 5, "checkingaccuracy": 0.001, "checkingtype": "absdiff", "showpreview": true, "vsetrange": [0, 1], "type": "jme", "expectedvariablenames": []}], "showFeedbackIcon": true, "type": "gapfill", "marks": 0, "scripts": {}}, {"variableReplacements": [], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "prompt": "

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

", "gaps": [{"variableReplacementStrategy": "originalfirst", "answer": "x*y*z*({a[2]}+{b[2]}x*y*z)", "checkvariablenames": false, "showFeedbackIcon": true, "marks": 1, "scripts": {"mark": {"order": "after", "script": "question.mark_factorised(this);"}}, "variableReplacements": [], "showCorrectAnswer": true, "vsetrangepoints": 5, "checkingaccuracy": 0.001, "checkingtype": "absdiff", "showpreview": true, "vsetrange": [0, 1], "type": "jme", "expectedvariablenames": []}], "showFeedbackIcon": true, "type": "gapfill", "marks": 0, "scripts": {}}, {"variableReplacements": [], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "prompt": "

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

", "gaps": [{"variableReplacementStrategy": "originalfirst", "answer": "5({a[3]}d+{b[3]}r+m)", "checkvariablenames": false, "showFeedbackIcon": true, "marks": 1, "scripts": {"mark": {"order": "after", "script": "question.mark_factorised(this);"}}, "variableReplacements": [], "showCorrectAnswer": true, "vsetrangepoints": 5, "checkingaccuracy": 0.001, "checkingtype": "absdiff", "showpreview": true, "vsetrange": [0, 1], "type": "jme", "expectedvariablenames": []}], "showFeedbackIcon": true, "type": "gapfill", "marks": 0, "scripts": {}}, {"variableReplacements": [], "showCorrectAnswer": true, "variableReplacementStrategy": "originalfirst", "prompt": "

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

", "gaps": [{"variableReplacementStrategy": "originalfirst", "answer": "6c*d*({a[4]}d+{b[4]}c+{c[1]}c*d)", "checkvariablenames": false, "showFeedbackIcon": true, "marks": 1, "scripts": {"mark": {"order": "after", "script": "question.mark_factorised(this);"}}, "variableReplacements": [], "showCorrectAnswer": true, "vsetrangepoints": 5, "checkingaccuracy": 0.001, "checkingtype": "absdiff", "showpreview": true, "vsetrange": [0, 1], "type": "jme", "expectedvariablenames": []}], "showFeedbackIcon": true, "type": "gapfill", "marks": 0, "scripts": {}}], "variablesTest": {"condition": "", "maxRuns": "1000"}, "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.

", "type": "question", "contributors": [{"name": "Marlon Arcila", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/321/"}]}]}], "contributors": [{"name": "Marlon Arcila", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/321/"}]}