// Numbas version: exam_results_page_options {"name": "Demo of \"pattern to match\" restriction", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Demo of \"pattern to match\" restriction", "tags": [], "metadata": {"description": "This question contains many examples of mathematical expression parts which require the student to enter their in a certain form, which is marked by applying a \"pattern to match\" restriction.
", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

In this question, each part has a pattern restriction, checking the student has given their answer in the required form.

", "advice": "", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"theta": {"name": "theta", "group": "Part c - modulus argument form", "definition": "arctan(si/sr)/pi+if(sr<0,si,0)", "description": "", "templateType": "anything", "can_override": false}, "jn": {"name": "jn", "group": "Part j - don't use decimals", "definition": "random(1..jd-1)", "description": "", "templateType": "anything", "can_override": false}, "kc": {"name": "kc", "group": "Part k - rationalise denominator", "definition": "random(1 .. 5#1)", "description": "", "templateType": "randrange", "can_override": false}, "d2": {"name": "d2", "group": "Part h - common denominator", "definition": "random(2..9 except d1)", "description": "", "templateType": "anything", "can_override": false}, "ka": {"name": "ka", "group": "Part k - rationalise denominator", "definition": "random(1 .. 9#1)", "description": "", "templateType": "randrange", "can_override": false}, "cB": {"name": "cB", "group": "Part g - polynomial", "definition": "random(1,2,3)", "description": "", "templateType": "anything", "can_override": false}, "n2": {"name": "n2", "group": "Part h - common denominator", "definition": "random(-1,1)*random(1..9 except map(n*d2,n,0..ceil(9/d1)))", "description": "", "templateType": "anything", "can_override": false}, "sr": {"name": "sr", "group": "Part c - modulus argument form", "definition": "random(-1,1)", "description": "", "templateType": "anything", "can_override": false}, "kn": {"name": "kn", "group": "Part k - rationalise denominator", "definition": "random(2,3,5,6,7,8)", "description": "", "templateType": "anything", "can_override": false}, "d1": {"name": "d1", "group": "Part h - common denominator", "definition": "random(2..9)", "description": "", "templateType": "anything", "can_override": false}, "si": {"name": "si", "group": "Part c - modulus argument form", "definition": "random(-1,1)", "description": "", "templateType": "anything", "can_override": false}, "modulus": {"name": "modulus", "group": "Part c - modulus argument form", "definition": "random(1 .. 10#1)", "description": "", "templateType": "randrange", "can_override": false}, "jd": {"name": "jd", "group": "Part j - don't use decimals", "definition": "2^random(0..3)*5^random(0,1)", "description": "", "templateType": "anything", "can_override": false}, "a": {"name": "a", "group": "Part b - expand brackets", "definition": "random(-5 .. 5#1)", "description": "", "templateType": "randrange", "can_override": false}, "bits": {"name": "bits", "group": "Ungrouped variables", "definition": "repeat(random(-3..3),3)", "description": "", "templateType": "anything", "can_override": false}, "lb": {"name": "lb", "group": "Part l - partial fractions", "definition": "random(-5..5 except [0,la])", "description": "", "templateType": "anything", "can_override": false}, "b": {"name": "b", "group": "Part b - expand brackets", "definition": "random(-5..5 except -a)", "description": "", "templateType": "anything", "can_override": false}, "cA": {"name": "cA", "group": "Part g - polynomial", "definition": "random(1,2,3)", "description": "", "templateType": "anything", "can_override": false}, "la": {"name": "la", "group": "Part l - partial fractions", "definition": "random(-5..5 except 0)", "description": "", "templateType": "anything", "can_override": false}, "n1": {"name": "n1", "group": "Part h - common denominator", "definition": "random(1..9 except map(n*d1,n,0..ceil(9/d1)))", "description": "", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Part a - write as sum of two integers", "definition": "random(4 .. 10#1)", "description": "", "templateType": "randrange", "can_override": false}, "p": {"name": "p", "group": "Part f - index notation", "definition": "random(0 .. 10#1)", "description": "", "templateType": "randrange", "can_override": false}, "coeffs": {"name": "coeffs", "group": "Ungrouped variables", "definition": "[\n bits[0]*bits[1]*bits[2],\n bits[0]*bits[1] + bits[0]*bits[2] + bits[2]*bits[1],\n bits[0] + bits[1] + bits[2],\n 1\n]", "description": "", "templateType": "anything", "can_override": false}, "kb": {"name": "kb", "group": "Part k - rationalise denominator", "definition": "random(ceil(sqrt(kc^2*kn))..15)", "description": "", "templateType": "anything", "can_override": false}, "z1": {"name": "z1", "group": "Part d - cartesian form", "definition": "random(-10..10 except 0) + random(-10..10 except 0)*i", "description": "", "templateType": "anything", "can_override": false}, "z2": {"name": "z2", "group": "Part d - cartesian form", "definition": "random(-10..10 except 0) + random(-2..2 except 0)*i", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["bits", "coeffs"], "variable_groups": [{"name": "Part a - write as sum of two integers", "variables": ["n"]}, {"name": "Part b - expand brackets", "variables": ["a", "b"]}, {"name": "Part c - modulus argument form", "variables": ["modulus", "sr", "si", "theta"]}, {"name": "Part d - cartesian form", "variables": ["z1", "z2"]}, {"name": "Part f - index notation", "variables": ["p"]}, {"name": "Part g - polynomial", "variables": ["cA", "cB"]}, {"name": "Part h - common denominator", "variables": ["n1", "d1", "n2", "d2"]}, {"name": "Part j - don't use decimals", "variables": ["jn", "jd"]}, {"name": "Part k - rationalise denominator", "variables": ["ka", "kb", "kc", "kn"]}, {"name": "Part l - partial fractions", "variables": ["la", "lb"]}], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

$\\simplify{{jn}x = {jd}y}$

\n

Find $y$. Don't use decimals. You'll get a penalty if you use a decimal in your answer.

\n

$y = $ [[0]]

", "gaps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "answer": "{jn}/{jd}x", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "`! m_anywhere(decimal:$n)", "partialCredit": 0, "message": "You must use fractions or integers, not decimals.", "nameToCompare": ""}, "valuegenerators": [{"name": "x", "value": ""}]}], "sortAnswers": false}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Write $\\var{2^p}$ in the form $2^n$.

", "answer": "2^{p}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "2^$n", "partialCredit": 0, "message": "Your answer must be in the form $2^n$, where $n \\in \\mathbb{R}$.", "nameToCompare": ""}, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Put $\\simplify[]{ {n1}/{d1} + {n2}/{d2}}$ over a common denominator.

", "answer": "{n1*d2}/{d1*d2} + {n2*d1}/{d1*d2}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "(`+-($n/$n;=d))`* + $z", "partialCredit": 0, "message": "All your fractions must be over the same denominator.", "nameToCompare": ""}, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Expand $\\simplify{(x+{a})(x+{b})}$

", "answer": "x^2+{a+b}x+{a*b}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": true, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "`! m_anywhere(?*(? + ?`+))", "partialCredit": 0, "message": "You must expand all brackets.", "nameToCompare": ""}, "valuegenerators": [{"name": "x", "value": ""}]}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Expand $\\simplify[basic]{ (x+{bits[0]})*(x+{bits[1]})*(x+{bits[2]})}$ and collect all terms.

", "answer": "{coeffs[0]}+{coeffs[1]}*x+{coeffs[2]}*x^2+{coeffs[3]}*x^3", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "`!(`+- (?`?*(x^?`?);=base) + `+- (?`?*(x^?`?);=base) + ?`*)\n`&\n`! m_anywhere(?*(? + ?`+))", "partialCredit": 0, "message": "You have not expanded and collected all terms.", "nameToCompare": ""}, "valuegenerators": [{"name": "x", "value": ""}]}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Write $\\var{n}$ as the sum of two positive integers.

", "answer": "{floor(n/2)}+{ceil(n/2)}", "answerSimplification": "basic", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "positive:$n + positive:$n", "partialCredit": 0, "message": "You must write your answer as the sum of two positive numbers.", "nameToCompare": ""}, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Factorise $\\simplify{x^2+{a+b}x+{a*b}}$

", "answer": "(x+{a})(x+{b})", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "m_nogather(\n ?;factors * ?`+;factors // at least two factors\n `where all(map( \n // where none of the factors are numerically equivalent to 1\n not numerical_compare(x,expression(\"1\")),\n x,factors)))", "partialCredit": 0, "message": "Your expression is not factorised.", "nameToCompare": ""}, "valuegenerators": [{"name": "x", "value": ""}]}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Complete the square: $\\simplify{x^2+{a+b}x+{a*b}}$.

", "answer": "(x+{a+b}/2)^2+{4*a*b-((a+b))^2}/4", "answerSimplification": "all", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "(?+?)^2+?`?", "partialCredit": 0, "message": "Your answer should be in the form $(x+a)^2+b$.", "nameToCompare": ""}, "valuegenerators": [{"name": "x", "value": ""}]}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Write $\\simplify{{sr*modulus}/sqrt(2) + {si*modulus}/sqrt(2) i}$ in modulus-argument form, $re^{\\theta i}$.

", "answer": "{modulus}*e^({theta} * pi*i)", "answerSimplification": "basic,fractionnumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "($n`? `: 1)*e^(((`*/ `+- $n)`*;x)*i)", "partialCredit": 0, "message": "Your answer is not in the form $re^{i\\theta}$, with $r \\geq 0$.", "nameToCompare": ""}, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "q: type(studentExpr)", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

$z_1 = \\var{z1}$

\n

$z_2 = \\var{z2}$

\n

Write $z_1+z_2$ in the form $a+bi$

", "answer": "{z1+z2}", "answerSimplification": "basic", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "((`+-integer:$n)`? `: 0);re + (`+-(i*real:$n`?)`? `: 0);im", "partialCredit": 0, "message": "Your answer must be in the form $a+ib$.", "nameToCompare": ""}, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Write the Maclaurin expansion of $\\simplify{sin({cA}x) + cos({cB}x)}$ up to the $x^4$ term.

", "answer": "1+{cA}x - {cb^2}/2x^2-{ca^3}/6x^3+{cb^4}/24x^4", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "(`+- $n`* / $n`* * ($v);=base^?`? `| $n/$n`?)`* + $z", "partialCredit": 0, "message": "Your answer must be a polynomial of the form $a_nx^n + \\ldots + a_1x + x_0$.", "nameToCompare": ""}, "valuegenerators": [{"name": "x", "value": ""}]}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Rationalise the denominator: $\\simplify{{ka}/({kb}+{kc}sqrt({kn}))}$

", "answer": "({ka*kb}-{ka*kc}*sqrt({kn}))/({kb^2-kc^2*kn})", "answerSimplification": "!basic", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "m_strictinverse(`+-?/(`!m_anywhere(sqrt(?) `| ?^(`! `+-integer:$n))))", "partialCredit": 0, "message": "Your answer must not have a square root on the bottom.", "nameToCompare": ""}, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Write the partial fraction decomposition of $\\simplify{{la-lb}/((x+{la})(x+{lb}))}$.

", "answer": "1/(x+{lb})-1/(x+{la})", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "mustmatchpattern": {"pattern": "m_nogather(m_gather(`+- (?;tops/?;bottoms));fractions`*+$z) `where len(fractions)>1 and all(map(not numerical_compare(x,expression(\"1\")),x,bottoms)) and all(map(not numerical_compare(x,expression(\"0\")),x,tops))", "partialCredit": 0, "message": "Your answer must be the sum of two or more fractions, with no denominators equivalent to 1 and no numerators equivalent to 0.", "nameToCompare": ""}, "valuegenerators": [{"name": "x", "value": ""}]}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"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/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "http://localhost:8000/accounts/profile/1/"}, {"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/"}]}