// Numbas version: exam_results_page_options {"name": "Order 1 Recurrence", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Order 1 Recurrence", "tags": [], "metadata": {"description": "

In this question the students have to solve a linear recurrence of order 1. The sequence is asked in recurrence form and the goal is to find its closed form.

", "licence": "Creative Commons Attribution-ShareAlike 4.0 International"}, "statement": "

Find the closed form of the relations:

\n

\\begin{cases} a_0 &= \\var{a0}\\\\ a_n &= \\simplify{{recurrence}} \\end{cases}

", "advice": "

To solve Order 1 recurrences, we need to apply the following steps:

\n
    \n
  1. Express the recurrence relation for the first difference (which will be a geometric sequence).
  2. \n
  3. Find the closed form for that geometric sequence.
  4. \n
  5. Find the closed form of the original sequence using its first difference.
  6. \n
\n

Finding the first difference.

\n

We need two things here: the first element, and the recurrence formula for the first difference.

\n

For the first element, we have \\(b_0 = a_1-a_0\\).

\n\n

So, \\(b_0 = \\var{a1} - \\var{a0} = \\var{b0}\\).

\n

For the recurrence formula, we have

\n

\\[\\begin{aligned} b_n &= a_{n+1} - a_{n}\\\\ &= \\var{bndiff}\\\\ &= \\var{bnrec} \\end{aligned}\\]

\n

Closed form of the first difference.

\n

Now we know that the first difference is a geometric sequence, and we know its recurrence form. From Activity 2, we can find the closed form: \\(b_0\\times k^n\\), where \\(k\\) is the multiplier in the recurrence. So \\[ b_0 = \\var{bnclosed} \\]

\n

Closed form for the sequence \\(a_n\\):

\n

Finally we can use the closed form of the first difference to find \\(a_n\\).

\n

\\[\\begin{aligned} b_n &= a_{n+1} - a_{n}\\\\ \\var{bnclosed} &= \\var{an1rec} - a_{n}\\\\ &= \\var{bnstep1}\\\\ \\var{bnstep2lhs} &= \\var{bnstep2rhs}\\\\ \\var{closedForm} &= a_n &\\text{divide both sides by }\\simplify{{k}-1} \\end{aligned}\\]

\n

And so we find the closed form for \\(a_n\\).

", "rulesets": {}, "extensions": [], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"k": {"name": "k", "group": "Question Parameters", "definition": "random(-10..10 except 0 except 1)", "description": "", "templateType": "anything", "can_override": false}, "r": {"name": "r", "group": "Question Parameters", "definition": "random(-3..3 except 0 except -1)", "description": "", "templateType": "anything", "can_override": false}, "a0": {"name": "a0", "group": "Question", "definition": "k+d", "description": "", "templateType": "anything", "can_override": false}, "recurrence": {"name": "recurrence", "group": "Question", "definition": "expression(\"{k}*sub(a,n-1)+{d}\")", "description": "", "templateType": "anything", "can_override": false}, "closedForm": {"name": "closedForm", "group": "solution", "definition": "simplify(expression(\"{v}*({k})^n-{r}\"),[\"basic\"])", "description": "", "templateType": "anything", "can_override": false}, "v": {"name": "v", "group": "solution", "definition": "a0+r", "description": "", "templateType": "anything", "can_override": false}, "d": {"name": "d", "group": "Question", "definition": "r*(k-1)", "description": "", "templateType": "anything", "can_override": false}, "a1": {"name": "a1", "group": "Advice - part 1", "definition": "k*a0+d", "description": "", "templateType": "anything", "can_override": false}, "a1rec": {"name": "a1rec", "group": "Advice - part 1", "definition": "expression(\"{k}* sub(a,0) +{d}\")", "description": "", "templateType": "anything", "can_override": false}, "b0": {"name": "b0", "group": "Advice - part 1", "definition": "a1-a0", "description": "", "templateType": "anything", "can_override": false}, "an1rec": {"name": "an1rec", "group": "Advice - part 1", "definition": "simplify(expression(\"{k}*sub(a,n)+{d}\"),[\"basic\"])", "description": "", "templateType": "anything", "can_override": false}, "bnrec": {"name": "bnrec", "group": "Advice - part 1", "definition": "simplify(expression(\"{k}*sub(b,n-1)\"),[\"basic\"])", "description": "", "templateType": "anything", "can_override": false}, "anrec": {"name": "anrec", "group": "Advice - part 1", "definition": "simplify(expression(\"{k}*sub(a,n-1)+{d}\"),[\"basic\"])", "description": "", "templateType": "anything", "can_override": false}, "bndiff": {"name": "bndiff", "group": "Advice - part 1", "definition": "simplify(expression(\"({an1rec})-({anrec})\"),[\"basic\"])", "description": "", "templateType": "anything", "can_override": false}, "bnclosed": {"name": "bnclosed", "group": "Advice - part 2", "definition": "expression(\"{b0}*({k})^n\")", "description": "", "templateType": "anything", "can_override": false}, "bnstep1": {"name": "bnstep1", "group": "Adviced - part 3", "definition": "simplify(expression(\"{an1rec}-sub(a,n)\"),[\"basic\"])", "description": "", "templateType": "anything", "can_override": false}, "bnstep2lhs": {"name": "bnstep2lhs", "group": "Adviced - part 3", "definition": "simplify(expression(\"{bnclosed}-{d}\"),[\"basic\"])", "description": "", "templateType": "anything", "can_override": false}, "bnstep2rhs": {"name": "bnstep2rhs", "group": "Adviced - part 3", "definition": "simplify(expression(\"{k-1}*sub(a,n)\"),[\"basic\"])", "description": "", "templateType": "anything", "can_override": false}, "a2": {"name": "a2", "group": "Ungrouped variables", "definition": "k*a1+d", "description": "", "templateType": "anything", "can_override": false}, "a22": {"name": "a22", "group": "Ungrouped variables", "definition": "eval(closedForm,['n':2])", "description": "", "templateType": "anything", "can_override": false}, "test": {"name": "test", "group": "Ungrouped variables", "definition": "substitute([n:0],closedform)", "description": "", "templateType": "anything", "can_override": false}, "test2": {"name": "test2", "group": "Ungrouped variables", "definition": "subvalue(closedform,3)", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["a2", "a22", "test", "test2"], "variable_groups": [{"name": "Question Parameters", "variables": ["k", "r"]}, {"name": "solution", "variables": ["v", "closedForm"]}, {"name": "Question", "variables": ["a0", "d", "recurrence"]}, {"name": "Advice - part 1", "variables": ["a1rec", "a1", "b0", "an1rec", "bnrec", "anrec", "bndiff"]}, {"name": "Advice - part 2", "variables": ["bnclosed"]}, {"name": "Adviced - part 3", "variables": ["bnstep1", "bnstep2lhs", "bnstep2rhs"]}], "functions": {"subvalue": {"parameters": [["ex", "expression"], ["k", "number"]], "type": "expression", "language": "jme", "definition": "substitute([\"n\":k],ex)"}}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "azero (check that the student's answer is correct for n=0):\n assert(resultsequal(unset(question_definitions,eval(studentCompare,['n':0])),unset(question_definitions,eval(correctCompare,['n':0])),settings[\"checkingType\"],settings[\"checkingAccuracy\"]),\n negative_feedback(render(safe(\"Your formula fails for n=0. We expect that $a_0=\\\\var{a0}$, but with your formula we get $a_0=\\\\var{nex}=\\\\var{nv}$\"),[\"nex\":subvalue(studentCompare,0),\"nv\":eval(studentCompare,['n':0])])))\n \naone (check that the student's answer is correct for n=1):\n assert(resultsequal(unset(question_definitions,eval(studentCompare,['n':1])),unset(question_definitions,eval(correctCompare,['n':1])),settings[\"checkingType\"],settings[\"checkingAccuracy\"]),\n negative_feedback(render(safe(\"Your formula fails for n=1. We expect that $a_1=\\\\var{a1}$, but with your formula we get $a_1=\\\\var{nex}=\\\\var{nv}$\"),[\"nex\":subvalue(studentCompare,1),\"nv\":eval(studentCompare,['n':1])])))\n\nmark:\n apply(studentExpr);\n apply(failNameToCompare);\n apply(unexpectedVariables);\n apply(sameVars);\n apply(azero);\n apply(aone);\n apply(numericallyCorrect);\n apply(failMinLength);\n apply(failMaxLength);\n apply(forbiddenStringsPenalty);\n apply(requiredStringsPenalty);\n apply(failMatchPattern)", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Note the index! $a_n=$

", "answer": "{closedForm}", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "singleLetterVariables": false, "allowUnknownFunctions": true, "implicitFunctionComposition": false, "caseSensitive": false, "valuegenerators": []}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Julien Ugon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3575/"}]}]}], "contributors": [{"name": "Julien Ugon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3575/"}]}