// Numbas version: finer_feedback_settings {"name": "1.3.4.2 Factorise an expression", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "1.3.4.2 Factorise an expression", "tags": [], "metadata": {"description": "
Factorise a 2-term expression where the gcd can be alphanumeric. Part of HELM Book 1.3
", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "Practise these questions repeatedly until you can quickly, confidently and correctly factorise the expressions.
", "advice": "$\\var{simplify(expression(q2terms[q2termidx]),\"all\")}$ and $\\var{simplify(expression(q2terms[mod(q2termidx+1,2)]),\"all\")}$ have a common factor of $\\var{fullgcd}$
\nso $\\var{q2expr}=\\var{q2ans}$
", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"alphabet": {"name": "alphabet", "group": "Ungrouped variables", "definition": "shuffle(['a','b','c','d','f','g','h','k','m','n','p','q','r','s','t','u','v','w','x','y','z'])", "description": "", "templateType": "anything", "can_override": false}, "q2expr": {"name": "q2expr", "group": "question 2", "definition": "simplify(expression(\n string(simplify(expression(q2terms[q2termidx]),[\"all\"]) )\n + \"+\" + \n string(simplify(expression(q2terms[mod(q2termidx+1,2)]),[\"all\"]))\n),\"basic\")", "description": "In these expressions, the common factor consists of one number and one variable.
", "templateType": "anything", "can_override": false}, "q2c": {"name": "q2c", "group": "question 2", "definition": "[random(-9..9 except 0), random(-9..9 except 0), random(2..9)]", "description": "", "templateType": "anything", "can_override": false}, "q2v": {"name": "q2v", "group": "question 2", "definition": "flatten([\n alphabet[10..13],\n [weighted_random([ [random(alphabet),0.5] , \n [random(alphabet[10..11]),0.5]\n ])\n ]\n])", "description": "", "templateType": "anything", "can_override": false}, "q2coeffs": {"name": "q2coeffs", "group": "question 2", "definition": "[q2c[0]*q2c[2],q2c[1]*q2c[2]]", "description": "", "templateType": "anything", "can_override": false}, "q2terms": {"name": "q2terms", "group": "question 2", "definition": "[\n[q2coeffs[0] +\"*\"+ q2v[0],\n q2coeffs[1] +\"*\"+ q2v[0] + \"*\" + q2v[1]],\n[q2coeffs[0] +\"*\"+ q2v[0] + \"*\" + q2v[3],\n q2coeffs[1] +\"*\"+ q2v[0] + \"*\" + q2v[1]],\n[q2coeffs[0] +\"*\"+q2v[0]+\"*\"+q2v[2],\n q2coeffs[1]+\"*\"+q2v[0]+\"*\"+q2v[1]+\"*\"+q2v[3] ],\n[q2coeffs[0] +\"*\"+q2v[0]+\"*\"+q2v[2],\n q2coeffs[1]+\"*\"+q2v[0]+\"*\"+q2v[3]+\"*\"+q2v[2] ],\n[q2coeffs[0] +\"*\"+q2v[0],\n q2coeffs[1]+\"*\"+q2v[1]+\"*\"+q2v[2]]\n][q2idx]", "description": "The two terms are randomly ordered, but can look like one of four cases:
\n* m.a + n.a.b
\n* m.a.b + n.a.c or m.a^2 + n.a.c
\n* m.a.b + n.a.c.d or m.a.b + n.a^2.c
\n* m.a.b + n.a.b.c or m.a.b + n.a^2.c
\n* m.a + n.b.c
\nHere m and n are numbers, and a,b,c are variables
", "templateType": "anything", "can_override": false}, "q2gcd": {"name": "q2gcd", "group": "question 2", "definition": "if( (q2c[0] < 0 & q2c[1] < 0),\n-1*gcd(q2c[0],q2c[1])*q2c[2],\ngcd(q2c[0],q2c[1])*q2c[2]\n)", "description": "", "templateType": "anything", "can_override": false}, "q2idx": {"name": "q2idx", "group": "question 2", "definition": "random(0..4)", "description": "", "templateType": "anything", "can_override": false}, "q2termidx": {"name": "q2termidx", "group": "question 2", "definition": "random(0..1)", "description": "This chooses the order in which the terms are written.
", "templateType": "anything", "can_override": false}, "q2fterms": {"name": "q2fterms", "group": "question 2", "definition": "[\n [string(q2coeffs[0]/q2gcd),\n q2coeffs[1]/q2gcd+ \"*\" + q2v[1] ],\n [q2coeffs[0]/q2gcd+ \"*\" + q2v[3],\n q2coeffs[1]/q2gcd+ \"*\" + q2v[1] ],\n [q2coeffs[0]/q2gcd+\"*\"+q2v[2],\n q2coeffs[1]/q2gcd+\"*\"+q2v[1]+\"*\"+q2v[3] ],\n [string(q2coeffs[0]/q2gcd),\n q2coeffs[1]/q2gcd+\"*\"+q2v[3] ],\n [string(q2coeffs[0]/q2gcd)+\"*\"+q2v[0],\n q2coeffs[1]/q2gcd+ \"*\" + q2v[1] + \"*\" + q2v[2] ]\n ][q2idx]", "description": "Terms with the common factors removed.
", "templateType": "anything", "can_override": false}, "q2ans": {"name": "q2ans", "group": "question 2", "definition": "expression(\nq2gcd + \n [\"*\" +q2v[0] , \"*\" +q2v[0], \"*\" +q2v[0], \"*\" +q2v[0] + \"*\" + q2v[2], \"\" ][q2idx]\n + \"*(\" +\n string(simplify(expression(\n string(simplify(expression(q2fterms[q2termidx]),[\"all\"]) )\n + \"+\" + \n string(simplify(expression(q2fterms[mod(q2termidx+1,2)]),[\"all\"]))\n ),\"basic\"))\n +\")\"\n)", "description": "", "templateType": "anything", "can_override": false}, "fullgcd": {"name": "fullgcd", "group": "question 2", "definition": "expression(\n if( tempgcd[length(tempgcd)-1]=\"*\", \n tempgcd[0..length(tempgcd)-1],\n tempgcd\n )\n)", "description": "", "templateType": "anything", "can_override": false}, "tempgcd": {"name": "tempgcd", "group": "question 2", "definition": "split(string(q2ans),\"(\" )[0]", "description": "A helping variable used to extract the alphanumeric gcd from q2ans.
", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["alphabet"], "variable_groups": [{"name": "question 2", "variables": ["q2c", "q2v", "q2coeffs", "q2terms", "q2fterms", "q2gcd", "q2idx", "q2termidx", "q2expr", "q2ans", "tempgcd", "fullgcd"]}], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "jme", "useCustomName": true, "customName": "Exercise 2", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "Factorise $\\var{q2expr}$. Check your answer by removing the brackets again.
", "answer": "{q2ans}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": true, "singleLetterVariables": true, "allowUnknownFunctions": false, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "// start with a number and possibly some variables\n`+- $n`? * $v`* * (\n// add 2 terms in brackets\n`+-($n;a;v1:1;v2:2 `| $n;a * $v;v1;v2:2 ^2`? \n `| $n;a * $v;v1 * $v;v2 `| $v;v1;a:1;v2:2 ^2`? \n `| ($v;v1 * $v;v2);a:1) +\n`+-($n;b;v3:3;v4:4 `| $n;b * $v;v3;v4:4 ^2`? \n `| $n;b * $v;v3 * $v;v4 `| $v;v3;b:1;v4:4 ^2`? \n `| ($v;v3 * $v;v4);b:1))\n// where the gcd inside the brackets = 1\n`where (gcd(a,b)=1)\n// and there are no common variables between the two terms.\n`where distinct([string(v1),string(v2),string(v3),string(v4)])=[string(v1),string(v2),string(v3),string(v4)]", "partialCredit": 0, "message": "You have not fully factorised this expression.", "nameToCompare": ""}, "valuegenerators": []}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "type": "question", "contributors": [{"name": "Merryn Horrocks", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4052/"}]}]}], "contributors": [{"name": "Merryn Horrocks", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/4052/"}]}